Connect with us

Esp8266 wifi module on avr gcc

Discussion in 'Microcontrollers, Programming and IoT' started by Areeha Durrani, Mar 10, 2016.

Scroll to continue with content
  1. Areeha Durrani

    Areeha Durrani

    Jul 8, 2015
    Hello..I am working on the esp82666 WiFi Module and want to use it as acess point but since I am new to avr gcc I am having issues withits coding.. my code is giving errors..kindly help me with this..
    This is my code...for using my wifi module as an access point..
    #include <avr/io.h>
    #define F_CPU 16000000UL
    #include <avr/io.h>
    #include <util/delay.h>

    #define BAUDRATE 9600
    #define BAUD_PRESCALLER (((F_CPU / (BAUDRATE * 16UL))) - 1)
    #define DEBUG true
    #define String espmode
    #define espmode "3"
    #define SSid "KFRL-4"
    #define password "RFID5678"

    void Esp_init(void);
    unsigned char Esp_receive(void);
    void Esp_send( unsigned char data);
    void Esp_putstring(char* StringPtr);
    void wifiSetup(String,String,String);
    void sendData(String,const,boolean);

    char String[]="Hello world";
    unsigned char data;

    int main(void)
    wifiSetup(String espmode,SSid,password);
    if (Esp_receive()!=0X00)
    int ConnectionId=Esp_receive()-48;
    return 0;
    void sendData(String Command,const int timeout,boolean debug)
    String response="";
    long int time=millis();
    char c=Esp_receive();
    return response;
    void wifiSetup(String mode,String SSid,String pass)
    sendData("AT\r\n",2000,DEBUG); //reset mode
    String mode0= "AT+CWMODE=";
    mode0 += mode;
    mode0 += "\r\n";
    sendData(mode0,2000,DEBUG); // configure as access point
    String ssidset="AT+CWJAP=\"";
    ssidset += SSid ;
    ssidset += "\",\"" ;
    ssidset += pass ;
    ssidset += "\"" ;
    ssidset += "\r\n" ;


    void Esp_init(void)
    //UBRRn is a baudrate register
    //UMSELn bit in USART Control and Status Register C (UCSRnC) selects
    //between asynchronous and synchronous operation
    UBRR0H = (uint8_t)(BAUD_PRESCALLER>>8); // Baud Rate Register upper 4 bits
    UBRR0L = (uint8_t)(BAUD_PRESCALLER); // Baud Rate Register lower 4 bits
    //enable the transmission and receive functionality independently.
    //Both the RXENn bit (Receive Enable) and the TXEN(TXENn) bit (Transmitter Enable)
    //are both located in the B Register (UCSRnB)
    UCSR0B = (1<<RXEN0)|(1<<TXEN0);
    //All of our configuration options are located in Register C
    UCSR0C = (3<<UCSZ00); //Set frame


    unsigned char Esp_receive(void){

    while(!(UCSR0A & (1<<RXC0)));//Wait until data is received
    return UDR0; // Read the data from the RX buffer


    void Esp_send( unsigned char data) //write byte to serial port

    while(!(UCSR0A & (1<<UDRE0)));// Wait until buffer is empty
    UDR0 = data;// Send the data to the TX buffer


    void Esp_putstring(char* StringPtr){

    while(*StringPtr != 0x00){

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day