-->
Page 1 of 1

Interfacing with Atmega16/32

PostPosted: Sat Apr 23, 2016 7:37 pm
by Pranav2310
Hello guys
I am in desperate need of help with interfacing the esp8266 with an avr microcontroller. I have learnt how to use the esp8266 with a terminal software via a usb to serial module where i can set it up as a sever, connect devices to the module and communicate using the AT commands. I also setup the microcontroller to communicate via usart (with the specs needed to communicate with the wifi ,module) and was tested using hyperteminal. When I am sending the AT commands as strings to the module from the microcontroller nothing is happening(the module should send back "OK" or ERROR. How do I go about sending the AT commands to the wifi module from the micro? I have uploaded the code i am testing with below



/*
* Uart9600TxRx.c
*
* Created: 4/20/2016 1:09:32 AM
* Author: Pranav
*/


//Uart working for bytes at baud of 9600 Tx and Rx

#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <string.h>
#ifndef F_CPU
#define F_CPU 16000000
#endif
volatile char rec;

void usart_msg(char *c)
{
while (*c != 0) //--- Check for null
UartTx(*c++); //--- Increment the pointer
}
void Usart_Init(){
UCSRB = (1 << RXEN ) | (1 << TXEN );
UCSRC = (1 << URSEL ) | (1 << UCSZ0 ) | (1 << UCSZ1 );
UBRRL = 103 ;
UBRRH=0;
UCSRB |= (1 << RXCIE );

}
void UartTx(char send){
UDR=send;
while (!(UCSRA & (1<<UDRE)));
}
int main(void)
{
Usart_Init();
DDRC=0XFF;
DDRB=0x00;
PORTB=0xFF;
sei();
char send;
//int x=0;
//SOME AT COMMANDS TO SETUP THE ESP8266 AS A SEVER
usart_msg("AT");
usart_msg("AT+CIPMUX=1");
usart_msg("AT+CIPSEVER=1,1003");

while(1)
{


}
}
ISR (USART_RXC_vect){
//char Rec;
//PORTC=0xFF;
_delay_ms(1000);
if(UDR=='O'){
PORTC=0xFF;
}
rec=UDR;
//UDR=rec;
//return(rec);
}

Re: Interfacing with Atmega16/32

PostPosted: Sat Apr 23, 2016 9:13 pm
by Mmiscool
This might not be the right section of the forum for your post. This is the esp8266 basic firmware section.