Arduino Mega 2560 with ESP8266 (ESP-01) Wifi, AT Commands and Blynk
HTML-код
- Опубликовано: 20 июл 2024
- In this video, I show how to connect an ESP8266 to the Arduino Mega 2560, and I send data to my phone which is running the Blynk app. I can also control an LED from the Blynk app. This tutorial assumes that you already know how to create simple Arduino projects. Aside from that, no special skills are needed.
Yes, you really DO need an external 3.3V supply to make this circuit work. Or you need an adapter like the one I use in the video. The 3.3V supply from the Arduino Mega does not provide enough current to run the ESP module.
If you want to know how to connect an Arduino Uno to an ESP-01, watch my "sequel" video:
• Arduino+ESP8266 Follow...
This is a pretty long video, so I have included a "table of contents" below:
0:00 Introduction
1:54 Project Hardware
8:38 Download AT Command firmware for the ESP8266
12:53 Download the app to flash the firmware to the ESP8266
16:42 Wiring up the circuit to flash the ESP8266
19:17 Flashing the AT Command firmware to the ESP8266
24:01 Wiring up the Arduino Mega 2560 + ESP8266
27:05 Setting up the Blynk app to send and received data
33:17 Write Arduino code for the LED and millis
38:46 Confirm Wifi is working and connected to the Blynk cloud server
39:19 Confirm the LED button works and Millis is displayed
39:49 Add code to run the temperature sensor and push data to the Blynk app
43:18 Confirm the temperature data is being sent to the phone
44:16 Conclusion - Bye!
There are several websites that I use in the video. The links are below:
This is the first link I show in the video. It takes you to the documentation page of the Blynk website.
docs.blynk.cc/#hardware-set-up...
This is the link to get the AT_Command firmware
github.com/Edragon/esp_firmwa...
This is the link to get the flasher app that I used in the video:
drive.google.com/file/d/1frCA...
This page shows an example sketch for the DS18b20 sensor:
www.sunfounder.com/learn/Sens...
The Arduino sketch (sketch_nov25a.ino) shown near the end of the video can be found here:
drive.google.com/drive/folder...
********************
This project requires certain libraries to be loaded into your Arduino IDE. To get the ESP8266 and Blynk libraries, go to this site:
help.blynk.cc/en/articles/5121...
… click on "Download Blynk Library", and follow the instructions
The temperature sensor used in this video requires two libraries that can be downloaded from SunFounder. The zip folder can be found here:
www.sunfounder.com/learn/down...
Open the zip folder and navigate to find…
\Sensor_Kit_V2.0_for_Arduino.zip\Sensor Kit V2.0 for Arduino\Library\Ds18b20
… and…
\Sensor_Kit_V2.0_for_Arduino.zip\Sensor Kit V2.0 for Arduino\Library\OneWire
Copy those two library folders into your Arduino library folder.
********************** Наука
You did very well. Please do more. You’re complete, clear and modest. None of that is common on RUclips. You have another subscriber.
Definitely the best tutorial on using ESP to connect to MEGA as WiFi shield! I'm honestly very doubtful of the other channels as they just show you the steps and wouldn't let you know if their method works. I followed your steps and get it connected to Blynk!
I used a different firmware and the alternative way of flashing showed, and it worked either.
Helped me a lot + all the time saving and headcracking going through info of flashing etc, cheers for more videos like this.
Possibly the best tutorial on RUclips , thank you.
True I watched so many videos and that’s the only one wich worked
I have been struggling on this for days and couldn't find videos that explained it as thoroughly as you did/I needed. Thanks so so very much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Excellent video tutorial with complete clear and beautiful explanation. One of the best tutorial I have ever seen on youtube. Keep it up sir.
Great tutorial Man ! spending 45 minutes to explain good ideas with a very beautiful way that means you are awesome.Thanks a lot
Thank you so much for this. I spent days trying to get this to work and your tutorial is the only one that managed to do so!!
Nathan, your presentation is just perfect! Thanks a lot.
a very well explained video - thanks a lot.... i was really frustrated in search for a proper video and got a big relief in seeing this video. it worked very well.
There are no words to describe how much you have helped me, thank you very much
One of the best videos on this topic.Cleared all my doubts.
Wow, thank you so much for such a detailed tutorial!! You're awesome!
The best tutorial about Blynk ESP8266 and Arduino
This is the most underrated RUclips Channel!
THE BEST AND CLEAR TUTORIAL ON THIS TOPIC! I GET LOST WITH INCORRECT AT Firware links founded in variuois Internet sites but the one you linked in perfect! About the version of the firmware (8M) or (32M) depends on the size of your ESP flash memory. I have a 8M and work nice with the AT 8M Firmare
OMG so helpful. I wish more people would be as detailed as you have been in this video. Thank you so much
Most useful video i have ever watched. Much thanks for sharing the video sir! Survived my college thesis through this 😊
Wow. Congratulations. Glad I could help.
Sir u deserve a statue! U saved me from madness with my esp8266.. A BIG THANK YOU!
thanx! you can flash ESP using arduino, w/o flasher. Need just to connectc txtx, rx and on Arduino connect RST to GND.
This video really help me up on my project. Thanks for helping me.
Very useful video, thanks for taking the time to create it.
Thanks Nathan - A most useful tutorial - Cheers :)
Thanks a lot for this amazingly detailed tutorial
This tutorial is so well done! I was migrating a project from a nano to a mega and just couldn't get the serial connection to work. One look at your sketch and it was sorted, perfect! Two things I'd like to mention: First, you made an effort to conceal your wifi login in the video but neglected to remove it from the sketch you shared! Second: I found the AT command firmware way too glitchy and the connection kept going down especially after trying to send certain packets. I sorted this by using the micropython firmware. I think I had to rebuild the firmware in docker to get it to talk to the Arduino - baudrate -, but my connection is now rocksolid. I also let the ESP do some of the lifting and just trigger python functions via serial. So much more reliable and intuitive!
Cool. So you only changed the firmware on the ESP module, and there were no changes to the Arduino code?
@@duntyou8 Well, I had to change the commands being sent to the ESP. Different application. I had to send an XOR encrypted packet to a specific IP address in the network and whenever I did that with the AT firmware the first one would go through but the next one would reset the network connection. The encryption had to happen on the Arduino which is a pain in C. With python networking functions are super easy to build, so instead of building the packet on the Arduino I used the ESP for that and just sent the plain string over to the ESP via serial. Works great!
Whoa… totally over my head :)
But still, I’m glad that my video helped in a tiny way!
The best video I've ever seen. Awesome keep up the good work!!!!!!!!!!!!!!!!!!!!!!
Your method worked for me, I didn't use a TTL to USB or any kind of adapter.
Instead I connected to Arduino Uno - RX->RX, TX->TX, EN->3.3V, VCC->3.3V, GND->Ground, GPIO-0->Ground, Arduino RESET->Ground (to bypass the ATMEGA, do this AFTER the Arduino is powered on). For power source I used the Arduino's 5V pin with 2 diodes for their voltage drop instead of a resistor voltage divider, for some reason it didn't work for (current probably or bad connection on my side).
Also, very important! the moment I started flashing the firmware, I put the ESP-01's RST pin to ground in and out quickly and the GPIO-0 to ground only after I connected power to the ESP.
Thanks! Turning an LED on and off with the Arduino is fun, doing it over WiFi got me stoked!
Along with the LED I connected DC motors to L293D with their own power source (I had trouble connecting it to Arduino's ground / 5V) and it worked perfect with the Blynk Slider widget!
Happy hacking!
Nice video.. from those two versions 8M and 32M stands for modules flash storage esp 01 comes with 8Mbits storage that is 1MBytes and esp12e comes with 32Mbits that is 4MBytes.so you need to choose the right one for your module. By change u chose the right one and it worked.☺️👍
Thanks for the info.
Great
YOU'RE AMAZING!!
Thanks a lot for amazing video.
Your tutorial greatly helped, thank you!
I totally agree with the last comment. Awesome job. Thank you so much for investing your time to help us out :-)
I have created a similar project to turn on and off my aquarium heater that I watch with blank and it notifies me through text message if my parameters get out of range. But you're project here made it much more simple for me and I'm going to change my setup :-) thank you.
perfect one i was looking for it.thank you
Great Video! Continue inspiring us!
excellent wifi controlled working video
12:14 The 8M stands for 8Mbit, which is equivalent to 1MB (Megabyte). 32M stands for 32Mbit, which is equivalent to 4MB (Megabyte). This refers to the flash memory size of the ESP module. Some have 1MB, some have 4MB. I believe the ESP8266 (ESP-01) that you have has 1MB of flash memory, so the 8M flash version should be appropriate.
Side note: If you are working on a Linux distribution, you can use esptool to flash the firmware onto the ESP module.
Very helpful. It took me 2 days to setup the esp8266 XD
Thanks. Very good and instructive. You saved me a lot of time collecting information.
I know what you mean. Nothing in the video is difficult, but it took a week for me to find all the info, which was scattered across the internet. I hope the video ties it all together and saves other people time.
Thankyou soo much! I had been pulling my hair out over this
At last it works thank you for your sharing.
thanks, I was wondering why my esp chip wasnt responding to any of my AT commands; turns out I needed to download firmware onto it first. Same for a similar bluetooth module btw. Nice job
this is the best tutorial by far that i have found on the web!
Your video is great. Very good explanation that even beginnerst will understand. I had a lot of Issues for example uploading the AT Firmware (dont know why but it alwasy said that there is no connection but there was... i tried it a lot of times even with 3 different Flasher softwares and sometimes it worked) the last problem was the it did not show me the Blynk sign in the Seriell Monitor but after i changed da Baud rate to 9600 it worked. Maybe i can help someone with that information but again i am very thankfull for this awesom video
im glad i found this tutorial
Bro you're a lifesaver. Thanks
Thanks for this tutorial!
nice and detailed info for beginners
this is the best tutorial i've ever seen.
Thanks a lot, man. Best tutorial ever.
omg just realised you were my teacher at SLB!! El Tigre 2001!! =)
thanks dude for your great explanation..
great videao very very well explained - one of the best. you got the talent
Marvelous work thanks
Also, well written description :)
Great video thank you so much man, that's fantastic
AMAZING !!!!! you are the best
Dude. Thank you so much. I've been following this tutorial for almost 2 days now and I finally got it working.
A few things to add for someone who may face the same problem as me:
1. for some reason, I couldn't get pin 18 and 19(TX1 and RX1) to work the way I want to so I ended up using pin 0 and 1.(RX0 and TX0). The only thing to keep in mind while doing that is, while uploading the code to the Arduino, you need to keep RX0 and TX0 free. After uploading the data, you can reconnect them. Also, in the code that you copy from the Blynk website, change ' #define BLYNK_PRINT Serial1 ' to ' #define BLYNK_PRINT Serial' because you're working with Serial and not Serial1.
2.Also while flashing the firmware to the ESP module, I connected the RESET of the Arduino board to GND. It helped me, it may not help you.
3. Also while flashing firmware, connect RX of ESP to RX of Arduino and TX to TX of Arduino.
That's awesome. Two days ain't bad. It took me five days to work out all the problems prior to making the video. It is strange that Serial1 did not work for you. Did you try Serial2 or Serial3?
Thanks, man. That really helps me.
many thanks it works very well !!! i try many pojects on the net, but no one function. this it work on first try. i do alimentation of esp8266, direct from arduino mega, on pin 3,3v and it work very well
That should work. Just make sure the supply can handle at least 500 mA.
i got a nano that reads some data from a bike and i want that data to be transfered online how can i use esp to comunicate with nano ?
that was so helpful
Hi When I want to connect Esp8266 to the wireless network with AT codes, I get MEM CHECK FAIL error on the serial port monitor screen. It is stated in some sources that esp8266 may be corrupted. Do you have experience in this regard? Or can you give me some advice? I wish you convenience in your work.
I got it all working with an UNO and an Adafruit Huzza esp8266 breakout module.
If you are using Mac and esptool.py...I had some trouble getting the right command arguments. This ended up working for me "--baud 115200 --after no_reset write_flash --flash_mode dout 0x00000". Changing flash_mode from dio to dout seemed to be the key.
thank you sir! God bless you! ♥
HI WHEN I USE THE FLASHER INORDER TO UPLOAD THE FIRMWARE ONTO THE ESP-01 IT STATES 'INVALID HEAD OF PACKET ' YOU KNOW THE SOLUTION FOR THIS?
You need the "8M-8M...bin"
i dont have the "#include " ive included the library getting an error
Is it possible to connect without the WiFi module? Pretty sure the Arduino mega 2560 already has one built in? Might be wrong tho
Thnx Awsome teachin ... Hope u will upload n teach us more
Can I use a step down converter for 3.3v??
Great video! Just a notice that at 40:58, the Wire.h library isn't necessary here, because in the code bit you imported, it is for the lcd that uses I2C, and you're not using any I2C devices as far as I know in this project.
Thanks for the tip. I probably had an LCD connected in another version of the circuit.
8M is for the esp module with 8mbit flash memory n the 32M is for 32mbit flash memory module of the esp
Hello, Nathan can you tell more about the 4 pin breadboard adapter you use? Is it possible to program esp with it? Thanks!
The four pin adapter does not have a convenient way to connect GPIO to ground, so it is not very helpful for flashing the ESP. I thought that was an annoying design flaw. If you are really determined, you could probably find a way to hack the adapter board and add wire connected to GPIO, and then you could flash the ESP.
Please help for esp connection to LCD, ultrasonic sensor,
me too
FYI, I have 2 different chinese chips that I bought this year, one blue one black. They came with AT version 1.2.0.0, SDK version 1.5.4.1. I needed to set the baud rate to 9600 for the black one and 74880 for the blue one in order to communicate with them.
Interesting. I guess 115200 isn't as universal as I thought it was.
Sir, i can upload the program to UNO board, but in Blynk it shows project not online yet. I am not able to control it. What should i fix?
Make sure you have changed the Arduino code to include your wifi settings and the Auth Token.
If you are using an Uno, you will have to change the code and the TX and RX connections.
In my code for the Mega, we have this:
// Hardware Serial on Mega, Leonardo, Micro...
#define EspSerial Serial1
// or Software Serial on Uno, Nano...
//#include
//SoftwareSerial EspSerial(2, 3); // RX, TX
If you are using the Uno, you should change the code to this:
// Hardware Serial on Mega, Leonardo, Micro...
//#define EspSerial Serial1
// or Software Serial on Uno, Nano...
#include
SoftwareSerial EspSerial(2, 3); // RX, TX
On the Mega, I connected
ESP-01 RX to Mega pin 18
ESP-01 TX to Mega pin 19
On the Uno..
ESP-01 RX to Uno pin 3
ESP-01 TX to Uno pin 2
If you already did those things,
Send a photo of your circuit.
Send your sketch
Send a screen shot of the serial monitor.
nathan_church@hotmail.com
"Millis" = "Mill-ees" as in Milli-seconds
Hello sir I followed these procedures but in my serial monitor [1527]ESP is not responding. Like this coming please give me a solution for this error sir 🙏
Hi Mr Nathan,
I had gotten this error from the Serial Monitor upon attempting to connect to the Wifi using ESP8266
[1590] Failed to disable Echo
and..
[14611] Failed to enable MUX
[15621] Failed to set STA mode
after which it just goes to..
[1579] ESP is not responding
(after multiple reset)
Thank you for your advise.
The message Failed to enable MUX is probably nothing to worry about. I see it from time to time, and it does not seem to cause any problem… my ESP still works and I can connect to wifi.
I don’t remember seeing the messages about Echo and STA mode. I don’t know what they mean.
The message ESP not responding is a very common problem. It can be caused by many things. Usually it is caused by a wiring or setup problem.
Check/confirm these things:
Are you using and ESP-01? If yes, that is fine. If not, then the setup might be different than what I show in the video.
Which Arduino are you using? If it is a mega, that is fine. If it is an Uno or something else, then a lot of things change in the setup.
Make sure the ESP module is powered with a separate 3.3V power supply that can provide at least 400 mA. Do not try to power the ESP module with the Arduino 3.3V output.
Were you able to flash AT commands to the ESP module? If yes, that is a good sign that the ESP module is working. It also ensures that the baud rate of the ESP module is set to the default value of 115200.
Make sure you can flash the ESP before trying the rest of the project.
After flashing, make sure you disconnect GPI0 from ground.
Make sure the power supply ground, the Arduino ground and the ESP module ground are all connected.
How are you doing the level conversion from 5V to 3.3V? Is it the same as in the video?
Send a photo or a schematic of your circuit: nathan_church@hotmail.com
thanks bro. really helpfull
Plz solve my problem :- Connect minimum 3 Nodemcu devices with one Arduino-Uno OR Raspberry Pi( As
controller ) to Established connection between all the Nodemcu.
And on the basis of some range of virtual keys( like 10 keys per Nodemcu ) of Blynk
App, the controller communicates with there respected Nodemcu and do the work as per
data provided by Blynk App.
Hi Sir, I have problem when I flash the ESP8266-01, I follow your instruction after the flashing but when I'm in the Serial monitor, there are continues flowing of garbage data horizontaly in serial monitor. Thanks Sir.
I already sent a video of my work sir. Thank You sir.
yah I hope its the great tutorial on esp01 and arduino mega....
Good stuff.... Good stuff...
I have a claw machine, which i would like to setup something like this to move the claw and drop the claw by using my computers keyboard. Any ideas, where to start?.
I would try ThingSpeak. I have not used it myself, but it might be what you are looking for.
A little help, sir ?
i have this error, and have been looking everywhere online but to no avail. Thank you in advance!
[1616] ESP is not responding
you are the best
life saver!!!
A question I have is why do you need the 5v to 3.3v adapter for the second circuit? Can't you use the breakout board for the ESP-01 along with your external 3.3v power supply that you used in the first circuit?
Regarding the 3.3V power supply, when I received the power supply in the mail, it came with a female power jack connector… probably identical to yours. I cut the jack off, stripped the wires and added the pins that you see in the video. I do not remember where I got the pins from, but I probably just pulled them off of some jumper wires that were in my tool kit. I suggest you do the same with your 3.3V supply. When flashing, I sometimes get the “failed to connect” message. It is usually a setup problem. See this video, at time 4:00 : ruclips.net/video/knYVIo8kNkA/видео.html
You are right. You can use the breakout board and the 3.3V supply for flashing and for the Blynk project. Functionally, they work the same. The 5-3.3V adapter board is a little more convenient for projects, but it cannot be used for flashing because it does not provide access to all the pins on the ESP-01.
@@duntyou8 Thank you for the prompt and informative response
Sir, does flashing firmware and flashing app work on esp8266 12E/F ? And how bout the wiring, does it same ? Thx for the help
I have not used the -12, but I think the app will work and the wiring will be the same.
but for me it says...failed to disable echo
Nice video
Hi, im not finish watching the tutorial yet but wanted to ask why you didnt use the 3v from arduino to the esp , thank you
The 3.3V supply from Arduino Mega and Uno cannot provide enough current to run the ESP module reliably. The ESP can draw up to 430 mA. The 3.3V supply on the Mega and Uno is only rated to 50 mA.
Hi Nathan, does it happen to work with newer versions of the firmware? I currently have this one T version:1.3/0.0(Jul 14 2016 18:54:01)
SDK version:2.0.050
For all of my projects, I have used AT version:1.1.0.0(May 11 2016 18:09:56) SDK version:1.5.4(baaeaebb). I don't know what happens when newer versions are used. The Blynk website simply states that 1.1.0.0 works best. This is the link that I am referring to:
help.blynk.cc/how-to-connect-different-hardware-with-blynk/arduino/esp8266-with-at-firmware
@@duntyou8 Thank you for the detailed tutorial! It is working now! I was having a lot of trouble trying to update the firmware(the first part of your tutorial), and didn't even check the version my module had, I believed it was old. When I checked I noticed I had AT version:1.3.0.0(Jul 14 2016 18:54:01)
SDK version:2.0.0(5a875ba), so I decided to skip that part, and yay! It is working now :D Thank you very much.
Great tutorial, never seen like this before so clear information. But i have a question, my esp8266 connected to wifi but there no reply from blynk, do you know why?
Hi. It could be your wifi has a firewall that prevents communication with Blynk. If possible, try a different wifi network. Other people have had problems similar to yours, in my third ESP8266 video, I discuss this more. Go to this video, ruclips.net/video/ghylNSjYdMs/видео.html , and jump to time 38:50.
@@duntyou8 thanks for your kind reply. I'll try another wifi, Thanks Nat.
very good!!!
Hello
what is the range of esp8266 and the phone.I mean without home wifi router just the range between phone and esp module .did u test this?
I did not test the range. In the video, the ESP module and phone are about about 20 m from my wireless router.
U SAVED MY F ING LIFE
hii sir at 20.46 sec in a video, it is showing WIFI Connected after ready. I followed the exact same steps but I am getting WIFI DISCONNECT after ready. Could you please help me.
Hi,
Many people asked about that. Don't worry if don't see the Wifi messages. As long as you see "ready", then you are good to go. If you want a longer explanation, go to my other video:
ruclips.net/video/knYVIo8kNkA/видео.html
at time 1.05.
we can use the arduino mega itself for flashing the firmware to esp 8266..... why did you use FTDI, 3.3v adapter etc.... there is no such need if we have arduino....Arduino mega can work as serial interface between esp8266 and computer
in my case 115200,with MEGA ,Many Thanks to you.. God Bless You.. :)
Do we have to download the upgrade for the firmware, doesn't the esp8266 already have a firmware installed on it !!
A lot of ESP modules come with AT commands firmware installed. Some do not. Even the modules that come with AT commands installed, the firmware version may not be compatible with Blynk. So it is always best to check the version, as demonstrated in the video. The Blynk website lists the tested versions of AT commands that are compatible.help.blynk.cc/how-to-connect-different-hardware-with-blynk/arduino/esp8266-with-at-firmware