Interfacing ESP8266 with Atmega32

Go To Last Post
41 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please help me with interfacing atmega32 with esp8266.

Last Edited: Fri. Oct 27, 2017 - 04:18 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's an open issue to add a terminal server (serial port server) to ESP8266.

Alternatively, ESP32 (ESP8266 follow on) can run MicroPython; then, use pySerial to get to the mega32.

Would need to connect a TCP socket or WebSocket to pySerial; that's relatively simple.

But ... MicroPython has been ported to ESP8266 and there's a tutorial on ESP8266 I2C (so TWI to mega32)

 


https://github.com/chilipeppr/serial-port-json-server/issues/4

Lightweight port to ESP-8266? #4

by JamesNewton

Apr 2, 2016

http://micropython.org/ 

http://docs.platformio.org/en/latest/platforms/espressif32.html#frameworks

...

Pumbaa is Python on top of Simba

...

http://pythonhosted.org/pyserial/

https://pypi.python.org/pypi/websockets

Adafruit Learning System

MicroPython Hardware: I2C Devices

https://learn.adafruit.com/micropython-hardware-i2c-devices?view=all

...

 

https://learn.adafruit.com/micropython-hardware-i2c-devices?view=all#hardware

...

ESP8266 board running MicroPython, ...

...

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

That's a broad question. If you Google esp8266 arduino

Then the same techniques apply.
Remember - we have no idea of what you want to achieve so you need to tell us.
In terms of the hardware interface, there are three wires. The software side is a bit more involved. So do some Googling and see what you find.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am not using arduino. I am using avr studio 4 and gcc compiler. I just getting started. i want to know HOW TO INTERFACE AVR ATMEGA32 WITH ESP8266. I need help in hardware interface and sample code.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Mega32 is an AVR. No surprise, perhaps, so is Meta328 which is the core of an Arduino. They are quite similar. Sure, you would not use the wire library and the pin access functions. But, other than those details, it is VERY similar.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

All ESP8266 modules are 3.3V
You can communicate from a mega32 if you run the AVR at 3.3V
You can use whatever protocol you like e.g. UART Serial, SPI, I2C, ...
SPI is probably the easiest interface.
.
You can add an ESP8266 core to Arduino. Then many Arduino sketches and libraries will work straight out of the box.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Google esp8266 arduino - Then the same techniques apply.
 

Hari_22 wrote:
I am not using arduino.

So??

 

As Kartman said, the techniques are the same - whether you use arduino or not.

 

I am using avr studio 4 and gcc compiler. I just getting started.

Any particular reason for getting started with such an old version?

 

Surely, Arduino is an ideal platform for getting started?

 

Also, TCP/IP networking seems a bit advanced for a beginners project.

 

For beginner's getting started steps, see: http://www.avrfreaks.net/comment...

 

i want to know HOW TO INTERFACE AVR ATMEGA32 WITH ESP8266.

How to interface anything to anything elsehttp://www.8052.com/forum/read/1...

 

http://www.lmgtfy.com?q=INTERFACE+AVR+ATMEGA32+WITH+ESP8266

 

 

EDIT: fix broken quote

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hello friends,

my issue is same, i've used arduino uno as serial to TTL converter to configure ESP module.

But i want to use ESP8266 with atmega32A.

 

Now the problem i am facing right now is,

 

Rx-Rx

Tx-Tx

Vcc-3.3V

CH_PD-3.3v

GPIO0 - GND

GND-GND

 

and in arduino i've done RESET to GND so it will become serial to TTL only.

 

That one works for me. 

But next day it won't i don't know what is the problem,

issues i am facing now is,

1. when i remove Vcc-3.3v RED LED on ESP ain't stop glowing(means contionous glowing after removing VCC)

2. when i remove RX pin out of arduino of ESP RED LED STOP Glowing(Seems like ESP VCC is coming from RX pin ?)

3. when i try to send AT nothing happens but when i switch Rx and Tx pin some symbols shown up once then nothing happen no response.

4. when i remove Rx and VCC, ESP STOPS but once i Connect RX pin BLUE AND RED LED GLOWs continously.

 

PLease help me out whats going on. 

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

2. Yes, that is probably what is happening. This is a design feature.
Is the arduino 3V or 5V? Hopefully not 5V as the esp8266 won’t like that voltage.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Yes arduino uno having both 5 and 3.3 but i m using 3.3v.

 

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

staring.net@gmail.com wrote:
 i've used arduino uno as serial to TTL converter 

That seems enormously over complicated!

 

Why not just use a simple USB-to-TTL converter to connect direct to the PC?!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hmmm... actually i tried that one as well.

problem i am facing using USB - TTL converter.

It shows connection works fine.(RX-RX,Tx-Tx,Vcc-3v3,gnd-gnd,GPI0-Gnd)

but no response,

using arduino serial port COM5 and sketch for AT commands

..

whenever type anything and send. Blue Led on USB-TTL converter blinks and some small disturbance felt on ESP like RED led getting low power or something no blue light glows on ESP

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

staring.net@gmail.com wrote:
It shows connection works fine.(RX-RX,Tx-Tx,Vcc-3v3,gnd-gnd,GPI0-Gnd)

but no response,

Err - if there's "no response" then the connection is not "works fine" - is it?!?!

 

Are you sure about this:

 

RX-RX,Tx-Tx

That means that the TX on one device (the Arduino?) must be an output, and the TX on the other (the ESP?) must be an input - doesn't it?

 

Now, strictly speaking, this is correct by the original definitions of DTE & DCE;  but, nowadays, it is more common to find that "RX" is always the input and "TX" is always the output - in which case you need:

TX (output) -----> RX (input)

RX  (input) <----- TX (output)

 

Also, are you sure that the USB-to-TTL converter can provide enough power for the ESP module to operate correctly?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ASIDE:

 

awneil wrote:
strictly speaking, this is correct by the original definitions of DTE & DCE

See: http://www.8052.com/forum/read/1...

 

And: http://www.8052.com/forum/read/1...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

as per your suggestion i did what you said.....but all i get is Blue and 2 RED LEDs on USB-TTL glowing contionusly and ESP RED AND BLUE LED not glowing.

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

 

Also, are you sure that the USB-to-TTL converter can provide enough power for the ESP module to operate correctly?

 

 

 

i don'y know whether it provide enough power or not....please tell me how to acheive that much power ?

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Go to esp8266.com
A zillion others have had the same problems methinks.

My guess is your 3V supply is not up to scratch.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

staring.net@gmail.com wrote:
i don'y know whether it provide enough power or not

So find out, then!

 

RTFM!

 

Read the documentation for your ESP module - what does it require ?

 

Read the documentation for your USB-to-TTL converter - what can it provide ?

 

It should be obvious that the USB-to-TTL converter must be specified to provide at lease as much as the ESP module requires - isn't it?

 

One thing to beware of is that any radio-based device - such as the ESP - tends to have very high peak power requirements.

You need to ensure that your supply can meet the peak requirement.

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But try to understand the problem is,

It WORKED perfectly very first day i used ESP module with arduino uno board. without using any converter TTL -USB or any thing just some wires and ESP and Arduino,.

But now i facing this problem i don't understand why its happening.

I tried seraching on google but there is nothing related to it.. all is about connections and configurations with arduino not even with Atmega32A and some thing like that.

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You jumped onto this old thread saying:

staring.net@gmail.com wrote:
my issue is same

 

So, if you issue is the same, then the answer is the same - and that answer was:

 

Kartman wrote:
arduino

 

ka7ehk wrote:
Arduino

 

david.prentice wrote:
Arduino

 

awneil wrote:
Surely, Arduino is an ideal platform for getting started?

 

As you are clearly stuggling with the very basics, why do you not simply use an Arduino and an ESP8266 shield ??

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ahhh ....

Cmon anweil i do have Arduino UNO and ESP8266-01 and USB-TTL converter but not that shield......

If you know how to analyise my problem then please tell me the process what to do and where to start. because i did everything possible for me to do...checked voltages of every pin (all correct).

Checked connections 100 times(all correct)

but now its not working and i don't know y.

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

staring.net@gmail.com wrote:
but now its not working and i don't know y.

Neither do we. We don't do magic here.

I can tell you the esp8266 modules are unreliable if the power supply is not right. Sometimes it works, sometimes it doesn't. Go to esp8266.com and read about the zillion others that have learnt the hard way.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

staring.net@gmail.com wrote:
please tell me the process

The process is to start with known-good hardware.

 

That would be an Arduino and a shield.

 

Then you have a reference point.

 

At the moment, we know nothing about what module, exactly, you're using; what USB-to-TTL converter you're using; how you've it wired up; what you may have done to break stuff.

 

It is virtually impossible to debug this stuff remotely.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
I can tell you the esp8266 modules are unreliable if the power supply is not right.

That applies to most things!

 

laugh

 

But, as I mentioned earlier, anything radio-based is particularly susceptible to this kind of "misbehaviour" - because of the high peak currents encountered.

 

Only this morning we have another example right here: http://www.avrfreaks.net/forum/r...

 

This is why you should at least start with a shield from a reputable supplier with a good body of support.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here we go,

 

Solution -

 

Rx       -RX

Tx       -Tx

Gnd     -Gnd

Vcc      -3.3 v

CH_PD -3.3 V

 

thats it nothing more .....

 

just put this connection with your arduino UNO board. 

 

And you can work on AT commands as UNO can afford that much current to communicate via AT, But once you are enabling its wifi you have to use external supply.

 

Thanks 

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

​Hello friends,

I need your help again now I'm stuck again.

Achieved:-

1. AT commands using Arduino uno board.

2. Configure as an client and server using AT commands(data sent and received using AT commands).

But now I need to connect that ESP8266-01 with Atmega32A.

Need to program atmega32 so I don't have to type again and again.

and for that I need your help.

 

 

please help.

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So what is your actual problem?

 

As has already been mentioned in this thread, and the many other ESP8266-related threads, there are loads of resources for this all across the interwebs - have you studied them?

 

For startters: http://www.esp8266.com/

 

http://www.lmgtfy.com?q=ESP8266+Atmega32A

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil its really complicated out there, i've already tried on some stuff but all are waste they compiled succesfully but failed to respond.

And my main problem is whenever i try to send AT commands through atmega32 program it ain't respond. i am pretty sure about my USART stuff becoz i tried debugging it using leds. 

Apart from this my AT commands working perfectly but i ain't get any response when using program.

Please help me, i'll give you every information i have but you have to tell me what to say because there are mostly waste and i don't wanna waste your precious time.

 

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

staring.net@gmail.com wrote:
my AT commands working perfectly but i ain't get any response when using program.

How can you possibly say they are working "perfectly" when you get no response?!

 

If you get no response, then your AT commands are clearly not working at all!

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:

staring.net@gmail.com wrote:
my AT commands working perfectly but i ain't get any response when using program.

How can you possibly say they are working "perfectly" when you get no response?!


If you get no response, then your AT commands are clearly not working at all!


 

AT commands working while i am using arduino serial monitor and typing manually.

But not working while sending AT commands through program.

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

staring.net@gmail.com wrote:
AT commands working while i am using arduino serial monitor and typing manually.

But not working while sending AT commands through program.

So think what's different between when you type manually, and when you send from your program.

 

Also:

 

  • Have you confirmed that your program is actually sending correctly? How?
  • Is the module not responding at all, or is it just your code not "seeing" the response?
  • Have you tested your code against a simple terminal?

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Read this post: http://www.avrfreaks.net/comment...includes a link to an ESP8266 AT Command handler

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hey awneil i tried what u said and fortunately i've got some progress.

I put Rx pin of FTDI cable to Tx of Atmega32A and i've got OK as i am sending 'AT' only.

But now i am trying to send 'AT+CIPMUX' after receiving 'ok' on serial monitor but it aint happening i dont know why.

please help

Manish verma

Last Edited: Thu. Oct 26, 2017 - 10:45 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please reply...

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How can we reply when you've given us little information. We're not mind readers nor do we have crystal balls that magic tell us exactly what you're doing. You need to tell us and show us. Where is your code?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sorry sir, 

Here is my codes

#define F_CPU 8000000UL               //using 8 MHz crystal
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <stdlib.h>
#include <stdio.h>

unsigned char interface_var = 0;
unsigned char counter[34];
unsigned char var = 0;
unsigned char receive_data;         //variable to store received data

void usart_init(void)
{
    UCSRB |= (1<<TXEN) | (1<<RXEN) | (1<<RXCIE) ; //  enable receive transmit of usart
    UCSRC = (1<<UCSZ1) | (1<<UCSZ0) | (1<<URSEL);
    UBRRL = 51; //  baudrate = 9600 , Fosc=8MHz
}
void usart_send( unsigned char ascii)
{
    while(!(UCSRA & (1<<UDRE)));              //Usart sending function
    UDR = ascii;

}
unsigned char usart_receive(void)
{
    while (!(UCSRA & (1<<RXC)));             // usart receiving function
    return UDR;
}
void send_AT( unsigned char message[])
{
    unsigned char i=0;
    while(message[i] != '\0')                 // for send AT commands like AT+CIPMUX
{
    usart_send(message[i]);   // This sends data to esp-01
    i++;

}
}
int main()
{
    //OSCCAL = 0xA9;
	MCUCSR=1<<JTD;
    MCUCSR=1<<JTD;                  // to disable jtag for proper fuctioning of PORTC
   DDRC=0xFF;
   PORTC=0XFF;
    unsigned char AT[] = "AT\r\n";
    unsigned char CIPMUX[] = "AT+CIPMUX=1\r\n";
    unsigned char CWSAP[] =  "AT+CWSAP=\"ESP_002\",\"1234test\",4,3\r\n";         // commands 

    _delay_ms(200);

    usart_init(); // initialize usart
    _delay_ms(500);
    sei();

    _delay_ms(200);
    send_AT(AT);                    // sending AT\r\n

    send_AT(CIPMUX);   

    _delay_ms(2000);
    send_AT(CWSAP);

    while(1)
    {   

    }//while(1) close

}// main close

ISR(USART_RXC_vect)    // Every time an AT command is sent correctly type OK on the LCD (Logic analyzer works better though :-p)
{

}

Above code is just to send AT,AT+CIPMUX and AT+CWSAP.

only first one responds back rest were not even shown that either they were transmitted or not.

 

if i send any command like AT+CWSAP its working properly. but when i send all these three together the first one responds and rest were like untouched.

Manish verma

Last Edited: Thu. Oct 26, 2017 - 11:34 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Apart from this i tried serial communication Between ATmega32A and Computer , when i ai'nt used ESP module it prints all 3 commands but when i use ESP it responds to 1st command and then nothing happen, neither i can see my controller sending something nor esp receiving something just freezed there.

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AWNEIL PLEASE RESPOND BACK HOW TO WAIT FOR ESP RESPONSE BECAUSE, 

1. if i gave delay in program it stucks after responding to first command 

2. if i aint give delay it prints all commands but responds to 1st one only

3. so last option is to wait for respond not using delay but a loop which will be in process untill the expected result recieved.\

please help

Manish verma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you need to set the ESP aside for a while, and just concentrate on getting your serial comms working.

 

  1. Send a string - any string - to a terminal program running on your PC.
    I suggest TeraTerm: https://ttssh2.osdn.jp/index.htm...
     
  2. Receive a string - any string - from a terminal program running on your PC.
     
  3. Recognise different string received from the terminal program running on your PC.
     

 

A useful feature of TeraTerm is that it can record a log of all sent & received data with timestamps.

 

So, with two USB-to-Serial adaptors, and two instances of TeraTrm, you can capture both sides of the conversation between your AVR and ESP - and use the timestamps to make a single log of the entire conversation:

 

EDIT

 

+------+                                        +-------+
|      |                                        |       |
|    TX+-------+------------------------------->+RX     |
|AVR   |       |                                |   ESP |
|    RX+<--------------------------+------------+TX     |
|      |       |                   |            |       |
+------+       |                   |            +-------|
               V                   V
          +----+-----+----+   +----+-----+----+
          |    RX   TX    |   |    RX   TX    |
          | USB-to-Serial |   | USB-to-Serial |
          |       1       |   |       2       |
          +-------+-------+   +-------+-------+
                  |                   |
                  |                   |
                  |                   |
                  V                   V
          +-------+-------------------+-------+
          |   TeraTerm            TeraTerm    |
          |   Instance            Instance    |
          |       1                   2       |
          |                 PC                |
          +-----------------------------------+

 

 

Last Edited: Thu. Oct 26, 2017 - 02:22 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Apparently, after Post #38 staring.net@gmail.com jumped to:

http://www.avrfreaks.net/comment/2305986#comment-2305986

for some (unknown) reason...

 

Edit: typo

David (aka frog_jr)

Last Edited: Fri. Oct 27, 2017 - 01:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

This posting to two different threads (both apparently hijacks) is getting ridiculous. I can't be the only one who is having problem following the chronology of this and also getting all the salient details IN ONE PLACE.

 

So to encourage things I will simply lock this - continue in the "other" thread.

Topic locked