EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Esp8266 interfacing with Atmega 8/16

Esp8266 interfacing with Atmega 8/16

|

Microcontroller › AVR › Esp8266 interfacing with Atmega 8/16

  • This topic has 1 reply, 2 voices, and was last updated 7 years, 10 months ago by Hari Prasaath K.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • September 25, 2017 at 9:07 am #4692
    rohini
    Participant
    I am not getting OK response when I am sending "ATrn" command to ESP8266. I am working on 9600bps and my module(esp) is also working on 9600bps, I checked it through Hyper terminal and it works fine.
     
     
     
     
    //************************************************************
    //Project: ESP-8266 with Atmega8(16Mhz)
    //Author: Bivashkumar singh
    //Module description: 4-bit Lcd 
    //************************************************************
     
     
    #include <stdio.h>
    #include <avr/io.h>
    #include <util/delay.h>
    #include <stdlib.h>
    #include "lcd.h"
    unsigned char recive[50] = {0};
     
    #define LCD_DPRT PORTC
    #define LCD_DDDR DDRC
    #define LCD_DPIN PINC
    #define LCD_CPRT PORTB
    #define LCD_CDDR DDRB
    #define LCD_CPIN PINB
    #define LCD_RS 0
    #define LCD_RW 1
    #define LCD_EN 2
     
    int i=0;
    void lcdcommand(unsigned char cmnd)
    {
    unsigned char chr = cmnd;
    chr = (cmnd>>4); 
            LCD_DPRT = chr;
            LCD_CPRT &= ~(1<<LCD_RS);
            LCD_CPRT &= ~(1<<LCD_RW);
            LCD_CPRT |= (1<<LCD_EN);
            _delay_ms(1000);
            LCD_CPRT &= ~(1<<LCD_EN);
            for(i=0;i<=2;i++)
            _delay_ms(500);
            LCD_DPRT = (cmnd & 0x0f);
            LCD_CPRT |= (1<<LCD_EN);
            _delay_ms(1000);
            LCD_CPRT &= ~(1<<LCD_EN);
            for(i=0;i<=3;i++)
            _delay_ms(500);
     
    }
     
     
     
     
    void lcd_init()
    {
            LCD_DDDR = 0XFF;
            LCD_CDDR = 0XFF;
            LCD_CPRT &=~(1<<LCD_EN);
    for(i=0;i<=1;i++) 
            _delay_ms(1000); 
            lcdcommand(0x33);
    _delay_ms(1000);
    lcdcommand(0x32);
    _delay_ms(1000);
    lcdcommand(0x28);
    _delay_ms(1000);
            lcdcommand(0x0e);
    _delay_ms(1000);
            lcdcommand(0x01);
            for(i=0;i<=1;i++)
            _delay_ms(1000);
            lcdcommand(0x06);
    }
     
     
    void lcddata(unsigned char data)
    {
           unsigned char chr = data;
            chr = (data>>4); 
            LCD_DPRT = chr;
            LCD_CPRT |= (1<<LCD_RS);
            LCD_CPRT &= ~(1<<LCD_RW);
            LCD_CPRT |= (1<<LCD_EN);
            _delay_ms(100);
            LCD_CPRT &= ~(1<<LCD_EN);
    LCD_DPRT = (data & 0X0F);
    LCD_CPRT |= (1<<LCD_EN);
            _delay_ms(500);
    LCD_CPRT &= ~(1<<LCD_EN);
            for(i=0;i<=4;i++)
            _delay_ms(500);
    }
     
     
    void lcd_gotoxy(unsigned char x,unsigned char y)
    {
            unsigned char firstchar[]={0x80,0xc0,0x94,0xd4};
            lcdcommand(firstchar[y-1]+x-1);
            _delay_us(500);
    }
     
    void lcd_print(char *ch)
    {
            unsigned char i = 0;
            while(ch !=0)
            {
            lcddata(ch);
            i++;
            }
    }
     
     
    int lcd(unsigned char *recive)
    {
            lcd_init();
            lcd_gotoxy(1,1);
    // while(recive)
            lcd_print(recive);
            while(1);
    return 0;
    }
     
     
     
     
    //****************************************ESP-8266***************************
    //***************************************************************************
    unsigned char recive[10] = {0};
    //____________________________UART INIT______________________________________
    //___________________________________________________________________________
    void usart_init(void)
    {
            UCSRB = (1<<TXEN) | (1<<RXEN);
            UCSRC = (1<<UCSZ1) | (1<<UCSZ0) | (1<<URSEL);
            UBRRL = 103; //baud rate 9600 (atmega8 16MHz)
    }
     
     
    //____________________________UART SEND_______________________________________
    //____________________________________________________________________________
    void usart_send(char *ch)
    {
    char i=0;
    while(ch != 0) 
    {
            while(!(UCSRA & (1<<UDRE)));
            UDR = ch;
    i++;
    }
    }
     
     
    //_____________________________UART RECIVE_____________________________________
    //_____________________________________________________________________________
    void usart_recive()
    {
    while(UDR)
    {
    while(!(UCSRA &(1<<RXC)));
    recive[i++] = UDR;
    }
    }
     
     
     
    //


    main


    //


    int main(void)
    {
    int i=0;
    cahr ch[50] = "ATrn"
     
        usart_init();
        usart_send(ch);
    usart_send("rn");
    _delay_ms(500);
    for(i=0;i<=20;i++)
    recive=usart_recive();
     
    lcd(recive);
     
     
    return 0;
    }
     
    //################################### END ###########################################
    //###################################################################################
    July 17, 2018 at 5:14 pm #14861
    Hari Prasaath K
    Participant

    Check with below link to have look on more details about ESP interfacing

    electronicwings.com/avr-atmega/atmega16-interface-with-esp8266-module

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • reviving old swordfish program but? May 17, 2026
  • Assistance locating a 'trail' camera gadget, please ? May 16, 2026
  • Analog multiplexer has gone obselete May 16, 2026
  • Difference between TTL, RS232 and RS485 May 16, 2026
  • Smart Buoy project May 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise