Introduction: Use Arduino Due to Program and Test ESP8266
If you want to program an ESP8266 (Wifi SoC) you will normally use a USB to serial adapter like this one. In case you do not have one but you have an Arduino Due laying around you can rig the Arduino as a bridge to program and test the ESP8266. Please be aware it does not make sense to buy an Arduino Due just for this purpose because it is usually more expensive than the FTDI chip (USB to serial).
Arduino Due is in particular good for this purpose because it does not need any level shifters. Arduino Due works at 3.3V which is compatible with the ESP8266. Here you have the steps how to do this:
Step 1: Get Your Materials
This is easy. As the title of this project says, you need an Arduino Due, the ESP8266 chip and some wires.
Step 2: Wiring
The wiring is fairly simple. If you use a switch you can prepare the wiring for both programing and serial monitoring. The wiring is fairly simple. Vcc on ESP8266 goes to 3.3V on Arduino Due. GND from ESP8266 obviously goes to GND on Arduino Due. CH_PD from ESP8266 goes to 3.3V. RX from ESP8266 goes to TX1 on Arduino and the TX from ESP8266 goes to RX1 on Arduino. GPIO0 is connected to GND for programing or disconnected if it's just running the software.
Step 3: Program Arduino Due to Act As a Bridge
This is a very simple step. You need to know at what speed your ESP8266 works. In case you do not know it you can just try. In most of the cases the speed would be either 9600 or 115200. Set Serial1 on Arduino at that speed. Basically the program reads from Arduino main serial and transfer the data back and forth with Serial1 on Arduino Due.
Step 4: Test the Bridge
Once you programmed the Arduino Due you can test the connection with ESP8266. Just open the Serial Monitor and make sure the speed matches the speed you set for Serial (not Serial 1) which is the connection between the computer and Arduino and not between Arduino and ESP8266. ESP8266 is pre-programmed to support a series of AT commands. You can try them.
Step 5: Program the ESP8266
You can use any IDE to program the ESP withe Arduino bridge you just created. In case you want to use Arduino to program the ESP8266 you need to use this release of Arduino. Once installed and made sure you set the port to the one connected to Arduino you need to set ESP8266 as target and the programmer to esptool.
26 Comments
2 years ago on Step 2
Sorry to say, but this diagram only works under ideal circumstances. Please take a look here to add the necessary resistors, and if needed 3.3v power supply, to ensure proper voltage levels, and minimal interference of signals causing spurious errors: https://www.forward.com.au/pfod/CheapWifiShield/ESP2866_01_WiFi_Shield/index.html
5 years ago
I am using Node MCU Lolin v3 and connect directly through USB cable to PC, when i burned the example code of mdns in arduino 1.6.7 the wifi is not connecting or even not showing my device in my laptop and mobile.
After that when I burn the example code of esp8266 WiFi wifi ap then my node MCU wifi signal is showing in both my laptop and pc then what happens in case of mdns eg.
Please reply on my email
Pawanmandli414@gmail.com
7 years ago on Introduction
Nice. Why not just post the Due code as text, though?
Reply 5 years ago
It works with IDE 1.8.4. Thanks!!
Code:
void setup()
{
Serial.begin(115200); // opens serial port, sets data rate to 9600 bps
Serial1.begin(115200); // opens serial port, sets data rate to 9600 bps
delay(50);
}
void loop()
{
// send data only when you receive data:
if ( Serial1.available()>0 )
{
// read the incoming byte:
byte b = Serial1.read();
Serial.write(b);
b = '\0';
}
if ( Serial.available()>0 )
{
// read the incoming byte:
byte c = Serial.read();
Serial1.write(c);
c = '\0';
}
}
Reply 5 years ago
No need to select Programmer, just the correct serial port ;)
6 years ago
Hi,
I try to give AT commands to my ESP8266 through Arduino due,But its not responding,the connections are correct,i gave AT cmd via arduino ide serial monitor but esp8266 not showing anything,
Can you please help me,
Thanks for Advance
6 years ago
Can you plz look at this
https://www.instructables.com/community/security-s...
small help thanks
7 years ago
Alright I have officially tried everything and the conclusion that I am running into is that this is no longer a viable way to program the esp8266 and on top of that I dont think there is support for the esp8266 01. I could be wrong I hope I am but It just is not working. I have worked on this all day but I cant get it. I tried the 1.6.1 ide but I think the problem is the esp8266 core that you used is not gone, I cant find any older versions anymore. It really stinks tho this would have been a great way to program my esp8266. |: if anyone can help it would be appreciated.
Reply 6 years ago
Have you seen this:
I hope you are OK by now, but the video is very nice guys! Tony
Reply 6 years ago
Just got this working with Arduino IDE 1.6.11 but had to set the PC side speed to 57600 and the ESP side at 115200, the Due does the buffering.Tried it with 115200 both ways and it looked like it uploads but never runs. Had some problems synchronizing the upload and held the due in reset until the UPLOADING starts when re-programming the Due. Took a few goes to program the ESP but it works repeatably now.
Reply 6 years ago
can u help me? i tried all the rates but due dont sees the serial1 as available
6 years ago
I'm using arduino 1.6.12 and just cant get it working. The firmware uploads into arduino due but serial monitor shows nothing. can someone helpe me?
7 years ago
I was wondering if maybe you could update this tutorial I am trying to do this very thing and It wont work because esptool is no longer an option for a programmer.
7 years ago
try use Arduino IDE 1.6.1
I have same error to program Atty86.
Reply 7 years ago
How did you add the board support for the arduino 1.6.1 I have always used the boards manager
8 years ago
Thanks for this article!
Arduino 1.6.4 keeps no "programmer" "esptool" any longer. All other settings under "programmer" don't work with the DUE!
Always get
"warning: espcomm_sync failed"
"error: espcomm_open failed"
Any help?
Reply 7 years ago
Has anyone figured this out yet?? I am running into this problem now as well
Reply 7 years ago on Introduction
I get this error also :(
Reply 7 years ago on Introduction
Any news? I really need this for my project...
Rainer from Germany
8 years ago on Introduction
Some information I missed:
1. The code works with the Arduino IDE 1.6.1 (now obsolete) specially created for ESP8266. I have not tested this with 1.6.4.
2. This works exclusively with Arduino Due. Other Arduino boards supporting multiple UART work only at 5V and the ones working at lower voltages (3.3) do not support multiple UART (Serial1 not working).