0

I'm trying to understand how to think about ESP01 devices and arduino connectivity

I purchased one of the USB programmers from Ebay to program the ESP01 - this works nicely, I can see the ESP doing things (I have it pinging a server sending data back and forth)

Obviously, the ESP01 has very few GPIO pins, so I'm interested in connecting to an arduino so I can combine the Arduino's IO with the Wifi on the ESP, and this is where I'm getting a little stuck. I'm assuming I have to connect the RX pin on the Uno to the TX on the ESP and the TX on the Uno to the ESP RX to set up the connection, but I'm confused as to which serial port to use on the Uno.

Specifically:

  • are the TX/RX pins on the arduino actually the same serial port as the USB connector - i.e if my intent is to plug the arduino into a computer to talk to it over USB, should I not then re-use the TX/RX pins to talk to the ESP

  • if so, should I look to software serial or something similar and use other IO pins on the arduino to connect to the ESP01

... Also, as an aside, if I get this all working, do I still need the USB programmer, or can I then program directly from the arduino?

8
  • yes and yes. and you can use the Arduino to upload to esp-01, but it is not so simple. I recommend you to upload a firmware to esp-01 with the programmer and use a corresponding library in Arduino. for example github.com/jandrassy/WiFiEspAT
    – Juraj
    Jun 11 '20 at 12:40
  • Cool - thanks, so the first yes, is that the RX/TX pins are the same serial connection the USB port uses? (just making sure I fully understand)
    – phatmanace
    Jun 11 '20 at 12:47
  • yes. Atmega328p has only one UART peripheral for hardware Serial.
    – Juraj
    Jun 11 '20 at 13:28
  • It's a pity that all newbies get hooked on the artificial (and false) necessity of combine ESP01 and Arduino in a single project. A newbie should let the complexities of attaching one device to another to the future, and just start with a ESP8266 version with more GPIOs, like ESP12.
    – mguima
    Jun 12 '20 at 16:35
  • @mguima, esp8266 was developed to be used as WiFi adapter, not as standalone MCU. do you want to write sketches for CC2541 on HC-11 BLE adapter? it is a MCU too.
    – Juraj
    Jun 17 '20 at 16:36
1

The Arduino UNO only has one serial port. That is pins 0/1 (RX and TX), which is mapped to the Serial object.

Those pins and that object are also used for communication with the PC through the USB connection. That means you can't easily use them for both PC communication and ESP8266 communication. It's possible, but it gets messy.

That is why many people use SoftwareSerial because that can work on any combination of pins on the Arduino that you like.

... Also, as an aside, if I get this all working, do I still need the USB programmer, or can I then program directly from the arduino?

Again, that is possible, but very messy. You could possibly get things to pass through from Serial to a SoftwareSerial instance, but it's not reliable (SoftwareSerial in general is not reliable for sustained transfers of data), and using the Arduino as a dumb UART interface would entail changing the wiring to pins 0/1 when you wanted to program.

So it's far simple to just use your USB interface for programming. Either that or set up OTA programming for the ESP8266 so you don't even have to use wires.

1
  • This is great, thanks for the guidance.
    – phatmanace
    Jun 11 '20 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.