I've been trying to get my newly acquired esp8266-01 to work. After some trial and error, I successfully managed to connect it to my WiFi and make an HTTP Post Request to turn off my smart lamps.
But I feel like I am missing some further understanding now.
The way I got it is that to program my wifi into the esp I set it into program mode and upload the code that initializes that over the Arduino, which has the ATMEGA328P removed (still don't know why that is needed, but It has to be removed for all to work).
But afterward should be able to connect the ESP to the Arduino without having to program it every time and just connect it in normal mode (i.e. not doing the shenanigans with RST and GP0, which takes about a minute).
If that understanding is correct, shouldn't I be able to have two programs, one for the ESP programming and for my actual project where I can use the ATMEGA328P again? Since I want to connect buttons and an LCD display which doesn't work without the ATMEGA. I'm kinda lost about how to get that to work or where I can find more info for it.
Thank you all very much, and I am also happy to share some code and discuss this.
Have you been following some tutorials? Provide a link. Where did you get your esp? Provide a link. I don't know what hardware you have in hand and how you are connecting them. It may be obvious what you have but I don't have your eyes. I find the part where you remove atmega328 weird and logic levels don't match between arduino uno and esp so there should be no direct connections.
The ESP8266-01 module is a lousy way to learn about WiFi. The only good thing about the module is that it is cheap as dirt. It has virtually no I/O and the pins it does has as dual purpose (as you discovered).
When you remove the ATMega328 from an Uno and connect it to an ESP8266 using pins 0 and 1 of the Uno, you’re simply using the Uno as a USB to serial converter and power supply. This is the only way you can program an ESP8266 without a dedicated USB to serial module like an FDTI or SilLabs 2102 USB module.
Once you have the ESP8266 programmed with your WiFi code, you can re-insert the ATmega328 and then connect the ESP to the Uno using any two I/O pins and software serial.
You’ll find it’s far easier to use other versions of the ESP8266, for example the Wemos D1, NodeMCU or the clone versions of the Uno with an ESP8266 added as a co-processor. Just be aware that any board that has only the ESP8266 will be a 3.3 volt only I/O board.
You don't have to remove the 328P from the Uno. You can connect the Uno's reset pin to GND; that will keep the 328P in reset so it does not interfere with whatever you're doing.
liuzengqiang:
Have you been following some tutorials? Provide a link. Where did you get your esp? Provide a link. I don't know what hardware you have in hand and how you are connecting them. It may be obvious what you have but I don't have your eyes. I find the part where you remove atmega328 weird and logic levels don't match between arduino uno and esp so there should be no direct connections.
This was my main source of information, especially the comment by dbush3721 on there helped me alot.
sterretje:
You don't have to remove the 328P from the Uno. You can connect the Uno's reset pin to GND; that will keep the 328P in reset so it does not interfere with whatever you're doing.
Thanks a lot, this works and saves me a little bit of time!
WattsThat:
The ESP8266-01 module is a lousy way to learn about WiFi. The only good thing about the module is that it is cheap as dirt. It has virtually no I/O and the pins it does has as dual purpose (as you discovered).
When you remove the ATMega328 from an Uno and connect it to an ESP8266 using pins 0 and 1 of the Uno, you’re simply using the Uno as a USB to serial converter and power supply. This is the only way you can program an ESP8266 without a dedicated USB to serial module like an FDTI or SilLabs 2102 USB module.
Once you have the ESP8266 programmed with your WiFi code, you can re-insert the ATmega328 and then connect the ESP to the Uno using any two I/O pins and software serial.
You’ll find it’s far easier to use other versions of the ESP8266, for example the Wemos D1, NodeMCU or the clone versions of the Uno with an ESP8266 added as a co-processor. Just be aware that any board that has only the ESP8266 will be a 3.3 volt only I/O board.
I already considered buying a more advanced module, might do that then. But I am still interested in fully understanding my current version.
Could you elaborate more on how I would use a programmed ESP with my Arduino afterward? My biggest problem rn is, that to program the ESP I need to switch the board to ESP Generic (which makes sense to me), that board also includes libraries like the ESP8266WiFi.g lib for example that I can use in the code I program onto the ESP (that part is also working well already).
But how would I trigger e.g. an HTTP request from a normal Arduino program over the ESP? How can I address the ESP in code and where should the logic for the request sit? In the Arduino code or the ESP code? Additionally, would the ESP then only be connected over its RX and TX pins to some I/O ports? (plus VCC ofc)
I've made a new discovery that got me further. After programming the ESP and giving it the HTTP Request instructions inside the setup(), I've connected CH_PD and VCC to 3.3V, GND to Ground, and hooked the RST up with a pull-up button. Now when I run my Arduino code and press the button it starts up the ESP and successfully turns off my lamp, also working multiple times as I desired.
Anything here I am still missing? How could I use the GPIO's for multiple functionalities? Maybe for two different events that trigger from two different buttons.