ESP8266 (ESP-01s) with Arduino Uno and Blynk

I know this has been covered many many times, and I have read many topics on this but I am quite lost still.

I have the Arduino Uno and the ESP connected together properly (I believe). I have run an external 3.3V source to power the ESP and a voltage divider for the TX pin. But I had dramas with getting it to work.

I have since removed the voltage divider for the RX as many reports of running the logic on 5V shouldn’t cause problems. I removed that in case I was creating more problems, and it was difficult with switching the TX and RX around.

I’ve managed to flash the firmware of the ESP to the latest using ESP8266 Flash Downloader. That went well. I then sent the “BareMinimum” sketch to the Arduino and then opened a serial monitor. Sent AT and it returned OK. This is with the RX and RX connected, and TX and TX (pin 0 to RX on esp, and pin 1 to TX on esp. I then set the baud rate on the esp to 9600 as I read that was best for software serial. I had to change the baud rate in the serial monitor to 9600 to see the command returned from the AT command… I then sent the command to connect to my hotspot and it connected there (phone showed device connected, as well as it returning the ip address when asked in the serial monitor. SO all appeared OK. (this has taken me a while to get here mind you, with lots of reading).

SO I moved to the Blynk examples, of which I tried the ESP8266_Shield one. Did the following;

  • Set my network and password
  • removed the // in front of the software serial part
  • set all baud rates (2 places) to 9600 as per the arduino settings and the confirmed baud rate for the esp
  • changed the rx pin to 0 and the tx pin to 1, as the default were my digital pins (2 and 3 I think from memory)
  • Sent the code and it uploaded, but the serial monitor says ESP not responding.
  • The blue light on the esp board flashes like something is happening after the code is uploaded.
  • The led for TX and RX on the arduino uno also lights up… But the serial monitor says the ESP is not responding.

I am somewhat lost now. I tried swapping the TX and RX around (so its RX to TX) but that yields the same results. The TX-TX is required for the AT commands when I have uploaded the bareminimum sketch however.

I have also put this on the Arduino forum, as I was already a member there but realised this is probably more helpful here seeing the AT commands work… and I am stuck at the Blynk Sketch.

You said you confirmed the ESP baud rate. I assume you have a USB-Serial convertor which you attached to the ESP to upload the firmware? If you connect that and use a terminal program, does it respond to an AT command? It should respond with OK.

Confirmed by the need to change to 9600 baud rate in the serial monitor only. When the baud rate was at 115200 it returned jiberish after I changed the baud rate.

I have only got an arduino uno and the esp8266, no usb to serial converter as I’d need to order one online which takes time, and figured it appeared like the arduino uno seemed to work OK for firmware update and AT commands…

In the arduino ide I have left the connected board as “arduino uno” for both the AT commands (with blank sketch uploaded) and also for the esp8266_shield sketch.

I do not plan to run Blynk on only the ESP at this stage, so want to try and get the arduino/esp8266 combo working as first choice (I hope to use analogue signals at some stage in this project).

Did you follow these directions?

http://help.blynk.cc/how-to-connect-different-hardware-with-blynk/arduino/esp8266-with-at-firmware

When using separate power supplies, make sure to share all ground connections between PSUs and devices.

The only place you need a voltage divider is from the TX pin of the Arduino (which is 5v) to the RX pin of the ESP (which only wants 3.3v). The ESP’s TX signal will work fine with a direct connection to the Arduino’s RX pin.

and you can use the Arduino to program (and/or confirm setup on) the ESP this way:

https://create.arduino.cc/projecthub/ROBINTHOMAS/programming-esp8266-esp-01-with-arduino-011389

1 Like

My power for the arduino is through the input plug (not USB plug), and is a 12V regulated power source rated at 3A I think. I use the V-Pin (or whatever the voltage output pin is labelled as) on the arduino uno to a 3.3V regulator. All my switch, ESP, regulator etc go through the ardiuno ground… I have removed everything but the ESP to ensure my digital inputs and outputs aren’t causing any problems.

I started with only the TX pin on the arduino with the voltage divider to the same ground, but I have removed that after having no luck to ensure that didn’t cuase the problem. I only did this because there are so many reports of it being OK for while… I understand the 5V digital logic may ruin the esp due to it rated at 3.3V so will put it back in. I only removed it to ensure it wasn’t the problem… The AT commands all work as is.

Yes I followed those directions, but loosely, as it didn’t cover using only an arduino uno (with no serial/usb converter) so I got that from elsewhere. But I did follow the steps for getting started, more specifically making sure I know the correct baud rates for both settings (both 9600 now I sent the baud rate to the esp via serial monitor which said “OK”.

I used a newer firmware (my board was already December 2016 firmware) for flashing (was an AT firmware) as the version in that link i sold and not easy to find. Supposedly the newer firmwares should all be OK though I believe. Well the AT commands work at least for my firmware so thats a start yes?

What pins on the UNO are you using for the SoftwareSerial connection to the ESP?

And what, if any, messages are you seeing via the IDE serial monitor from the UNO when running a basic Blynk sketch?

One thing I didn’t do is make the rst high (3.3v) or the gpio0 high however.

Although the AT commands work and it connects to my hotspot through AT commands so wouldn’t think that’s a problem huh? I had to ground the gpio0 when I flashed it.

I’m using pin 0 and pin 1. Labelled as RX and TX. I have tried reversing thise two around just in case (so rx to TX on each device which requires the voltage divider to stay with the TX pin of the arduino)

The default pins are 2 and 3 in the sketch which are the digital pins on my uno. I tried them as well but still left it as software serial in, the Blynk sketch (should they be the hardware pins? That bit confuses me). The rx and TX pins (0 and 1) on the arduino are the software serial yes?

I’m ok with software serial or whatever makes it easier to get it to work initially.

the ESP reset pin can hook directly to the Arduino’s reset pin (that’s how I have mine… OK it should als go through a voltage divider, but not quite as critical as a data pin) that way it will reset both when resetting the Arduino.

1 Like

You could use the Hardware pins on the Arduino (using Serial instead of SoftwareSerial) but you would have to keep disconnecting the ESP every time you program the Arduino… and you would not have the benefit of the IDE serial monitor for debug purposes.

Best to use the SoftwareSerial pins 2&3 as per the sketch. Other pins can also be used, but easier to stick with commonly used ones.

The term SoftwareSerial stems from using digital pins to emulate a UART (True Hardware Serial)… of which there is only the one on an UNO (pins 0&1): https://www.arduino.cc/en/Reference/SoftwareSerial

#define BLYNK_PRINT Serial
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";

#include <SoftwareSerial.h>
SoftwareSerial EspSerial(2, 3); // RX, TX

// Your ESP8266 baud rate:
#define ESP8266_BAUD 9600

ESP8266 wifi(&EspSerial);

void setup()
{
  // Debug console
  Serial.begin(9600);

  // Set ESP8266 baud rate
  EspSerial.begin(ESP8266_BAUD);
  delay(10);

  Blynk.begin(auth, wifi, ssid, pass);
}

void loop()
{
  Blynk.run();
}
1 Like

For some reason the software serial doesn’t work. I tried the rx from the esp to pin 2 and tx on the esp to pin 3, and tried rx on esp to pin 3 and tx on esp to pin 2…

But thanks to you, I tried hardware connection (had to change “serial1” to “serial” in the sketch) and disconnected the esp while I uploaded… Then disconnected usb, connected the rx to tx and tx to rx, reset the board and I can now ping the esp from my PC. Blynk app now says the unit is online and clicking a virtual pin switch in the app makes the blue light flicker on the esp so looks like its working… Except using hardware, so can’t debug as easily like you said.

I think I am happy with the results. After this I may post up a thing where the other instructions weren’t clear, or detailed enough for a newby like myself.

1 Like

A massive thanks for that. I wasted sooo much time on this part. Learning the Arduino code took less time :slight_smile:

I now have virtual pins working. I am surprised how fast the infomration gets tranfered from my phone to the arduino (through the esp). It makes my autoremote (a tool for tasker) I use in my home automation look like a dial up internet.

On that note, I might see how Blynk integrates with tasker as I am impressed with the speed of Blynk.

1 Like

thanks! this post was my salvation! for debug i put an i2c lcd and done!

1 Like

Hello the link you provided is not found, can you send anther source?

@11148 please create a new " need help with my project " topic and make sure to provide as much details as possible like blynk legacy or IOT, library version, sketch etc.

1 Like