ESP8266 connection on Arduino RX / TX Ports ( Ports 0 / 1 )

Hi folks,

I’m struggling with ESP8266 connection on Arduino with connection to Blynk

WORKING:

  • original connection:
    ESP8266 > Arduino:

CHPD > 3,3V
VCC > 3.3V
GRND > GRND
RX > TX
TX > RX

This connection is absolutely working fine…

PROBLEM:
In the event I have to update my sketch on Arduino, this won’t work with the above connection as RX / TX (Ports 0/1) are connected. To upload a sketch I HAVE TO remove cables from ports 0/1…
On my project disconnecting these cables is extremely complicated… so in general not an option

NOT WORKING:
I found to a “solution” to bypass ports 0/1 to - as an example - to ports 5/6:

#include <SoftwareSerial.h>                     // to use pin 4 and 5 as RX and TX ports

#define sw_serial_rx_pin 4 //  Connect this pin to TX on the esp8266
#define sw_serial_tx_pin 5 //  Connect this pin to RX on the esp8266

Now uploading a sketch is working fine BUT now the connection between the App and Arduino ISN’T working anymore…

Any hints / tips / tricks are appreciated,:relaxed:

this is my complete sketch…

//#define BLYNK_DEBUG
#define BLYNK_PRINT Serial                      // Comment this out to disable prints and save space
#include <ESP8266_HardSer.h>
#include <Servo.h>                              // include the Servo library
#include <BlynkSimpleShieldEsp8266_HardSer.h>   // include Blynk ESP8266
#include <SoftwareSerial.h>                     // to use pin 4 and 5 as RX and TX ports

#define sw_serial_rx_pin 4 //  Connect this pin to TX on the esp8266
#define sw_serial_tx_pin 5 //  Connect this pin to RX on the esp8266

// Set ESP8266 Serial object
#define EspSerial Serial                        // serial output
Servo Motor;                                    // create the servo objects

ESP8266 wifi(EspSerial);

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

void setup()
{
  // Set console baud rate
  Serial.begin(9600);
  delay(10);
  // Set ESP8266 baud rate
  EspSerial.begin(115200);
  delay(10);
  Motor.attach(10);                                           // attaches the servo on pin 13 to a servo object
  Blynk.begin(auth, wifi, "WlanhomeU", "8302147849164771");  // Wifi connection
  Motor.write(90);                                            // 90 is neutral, so neither of the servos should turn

}
  
  BLYNK_WRITE(3) 
  {
    Motor.write(param.asInt()); 
}


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

Code snippet should be formatted. Edit your post!

Wrap the code by adding 3 Backtick: ``` symbols:

Example:

 ``` cpp <--put 3 backticks BEFORE your code starts  (cpp means C++ language) 

   //Put your code here
   //..................
   //..................

 ``` <--insert 3 backticks AFTER your code

**This makes your code readable and with highlighted syntax, like this:**
//comment goes here 
void helloWorld() { 
   String message =  "hello" + "world"; 
}

First of all, 115200 is way too fast for software serial! Try and reduce that to 9600. I see you problem though, I have something similar going on, but I can reach my wires easily. Hence, can you build in maybe a little switch or jumper which you can use to set upload function or running function? That may be an option.

Look at my sketch fragment below, its work

#include <SoftwareSerial.h>
#include <ESP8266_SoftSer.h>
#include <BlynkSimpleShieldEsp8266_SoftSer.h>

SoftwareSerial EspSerial(11, 12); // RX, TX
ESP8266 wifi(EspSerial);
char auth[] = "";

but you must use 9600 baund rate

Hi Lichtsinaal,
thanks for your answer, to build in a switch to manually disconnect pins 0 and 1 is my last option and not easy to install.
found a small dip switch which will fit, will test it on my test config, but thats my last option…

Hi vganin,

I tried it many many times, but it is not working with SoftSer “setttings”
serial monitor is not really communicative with softser config, just:

[19] Blynk v.0.3.4
[520] Connecting to Wlan
[1540] Failed to disable Echo

that’s all, ping is working fine, but on App it`s always … ESP8266 is not in network / offline (depending on Android or Apple)

And YES, Blynk token is correct. I copied the token from my sketch with the HardSerial config…(which indeed is working fine…)

I have absolut no clue why SoftSer is not working…

P.S.: Also tried different Pins, like 2/3; 4/5 and your option 11/12)
Think have to read docs again, maybe I missed an important thing…

DId you try lowering the speed? And how do you feed the ESP power? They tend to consume much more than a Arduino can feed them.

@ Lichtsignaal
Sure, serial speed is set to 9600 baud and wiring is same when using HardSer config.

ESP8266 > Arduino:

CHPD > 3,3V (breadboard) VCC > 3.3V (breadboard) GRND > GRND RX > TX (in my last case Pin 8 in SoftSer config) TX > RX (in my last case Pin 7 in SoftSer config)

I followed this picture for cabling…

As I mentioned above, with this cabling and HardSer config its working brilliant… no problem at all, no issues like “… first start Arduino then ESP…” or similar tricks

And I tried it with first starting the Arduino and then ESP… same issue here…

And I’m using the example "ESP8266_Shield_SoftSer out of the box, just changing token and wifi credentials, that’s all.
Same with ESP8266_Shield_HardSer examlpe, NO additional changes, no code added etc…

I still recommend you to use an external power supply to power the ESP. The 01’s are notoriously instable powered by the Arduino. It may also be needed to pull the RST high for normal operation.

1 Like

Do you mean arduino serial speed or esp?
You must change both for arduino and esp.
To change esp speed use AT command AT+UART_DEF=9600,8,1,0,0 from AT console

@vganin
first on Arduino only…
since I changed speed to 9600 ESP8266 doesn’t want to talk anymore…
will flash ESP8266 again, then try it again with my HardSer config which worked… and try it again…

fingers x-ing… :pray:

I’ve had success with ESP+Arduino using hard serial and the 5V pin with a voltage regulator/voltage divider instead of using the 3.3V. The 3.3V often can’t handle the ESP.

@nolmath
yes, I know, but that’s the strange thing here, with the HardSer config its working fine without any issues and without regulator
Once I changed it to SoftSer config the ESP seems not to work properly… (with the same hardware config…)
really strange…

So re-flashed ESP8266 succesfully, uploaded sketch with HardSer. config and correct token to arduino, and BING it’s working …
Will try again with SoftSer config, still hope I’ll get it running …

Hi !
Have you managed it ?
Hood to hear any sokution you would have found.

Chris

Hi Chris,
no SoftSer does not work. For my project it rather would be the dot on the I… So I’m still running it with HardSer config without any problems.
I had to re-program arduino only once, when they changed the IP of the online Blynk Server… disassembled my project, did the re-programming and reassembled it. Working fine since then…
If you want to see it… https://www.youtube.com/watch?v=gi5bxf0agNc

Golo

So you managed to connect esp8266 module on arduino via hardser ? Like arduino sensing and sending data to esp8266 which transmit over wifi?

Can you please please please share your code ?

1 Like

Hi Chris,

keep in mind HardSer was with an older Blynk Library, so I adapted the code to run it with the actual Library. The arduino ESP8266 config as shown above is still the same and working…

#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include <Servo.h> // include the Servo library
#include <ESP8266_Lib.h>
#include <BlynkSimpleShieldEsp8266.h>

// Set ESP8266 Serial object
#define EspSerial Serial // serial output
Servo Motor; // create the servo objects

ESP8266 wifi;

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

void setup()
{
// Set console baud rate
Serial.begin(9600);
delay(10);
// Set ESP8266 baud rate
EspSerial.begin(115200);
delay(10);
Motor.attach(10); // attaches the servo on pin 13 to a servo object
Blynk.begin(auth, wifi, “WlanhomeU”, “8302147849164771”); // Wifi connection
Motor.write(90); // 90 is neutral, so servo will not turn

}
BLYNK_WRITE(3)
{
Motor.write(param.asInt());
}

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

oh bad, there are the # missing…
will try it later…

That is because you need to format any code inserts as per these directions: