Use ESP8266 with SoftwareSerial on pins 10 and 11

Hi to all,

I’m using an board based on atmega328p (smd version) and I would like to test my ESP8266 Wi-Fi module.
Since I would like to read the serial output from the standard RX and TX pins, I connected the ESP8266 module to pin 10 and pin 11.

I would like to use SoftwareSerial to emulate a virtual serial port on pins 10 and 11.

How can I verify that everything is working well? I’d like to send some AT commands to the module and read the answer.

I tried with this code:

#include <SoftwareSerial.h>
// software serial #1: RX = digital pin 10, TX = digital pin 11
SoftwareSerial portOne(10, 11);
int incomingByte = 0;    // for incoming serial data

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; 
  }


  // Start each software serial port
  portOne.begin(115200);
 
}

void loop() {
 
  portOne.listen();

 // read the incoming byte:
    incomingByte = Serial.read();
  
    // say what you got:
    portOne.print((char)incomingByte);
  
  Serial.println("Data from port one:");
  // while there is data coming in, read it
  // and send to the hardware serial port:
  while (portOne.available() > 0) {
    char inByte = portOne.read();
    Serial.write(inByte);
  }

 
  Serial.println();


  Serial.println();
}

but I get no answer from the module when I write “AT+RST” from the serial monitor.

Can you give me some suggestions, please?

I just would like to know if it is possible to communicate with the ESP module by using a virtual serial port and read the answer from the standard RX and TX pins provided by the atmega328p.

Thank you!

Software serial will not work at 115200 baud. 38400 is the best that you can hope for. If you want 115200 you could use a Mega. The Mega has 4 hardware serial ports (Serial for upload and 3 extra).

Thank you for your reply.

Is the module originally set a specific data rate?

Can I use it at 9600 baud without problems or do I have to change the module configuration ?

I believe ESP is merely default at 115200, and can be configured to run at 9600, thereby enabling you to use software serial. I'm not sure you really need to do this, and you might simply run ESP at 115200 on harware serial where it belongs.

Nick_Pyner: I believe ESP is merely default at 115200, and can be configured to run at 9600, thereby enabling you to use software serial. I'm not sure you really need to do this, and you might simply run ESP at 115200 on harware serial where it belongs.

If I well understood I need to run it at low speed since I'm using a virtual serial port.

Is it possible to set the speed of the module to 9600?

As I understand it, you just use software serial like you would on a Uno. There is a fair bit of discussion around on this. Just make sure you use sensible pins. 9600 is a normal speed for software serial. I was wrong with what I said above, in that it is the Hardware Serial that is at 115200, I don't think there is anything special about that, and it is quite separate from Software Serial.

Should I set the module to work at 9600, too?

If it expects to work at 115200 and the virtual port works at 9600, the serial monitor will output only garbage, is it correct? In this case, I think I should set the same velocity also in the ESP module.. but I do not know how to do that.

It is not correct. Device will work on Hardware Serial @ 115200 to another device at 115200, and on software serial @ 9600 to another device at 9600. It is quite normal to work on two different ports at different speeds. The thing that matters is that the devices at the other end must match accordingly.

If the ESP module works at 115200 as standard, I need to set it to work at 9600 since software serial will work at 9600. Is it correct?

If so, how to set the module to work at 9600?

Which exact ESP8266 module do you have? Do you have a USB to TTL converter module (FTDI)? Do you know what version of firmware is installed on the ESP?

I attached the photo of my module which is a little bit different from the common ESP modules that I found on Google.

On the smd chip there is written this code “nrf24l01”.

I am not sure about the pinout because my module layout seems to be different from the standard ESP8266 modules.

20180901_152803-756x1008.jpg

"nrf24l01".

That is not a Wifi module. It is a 2.4 GHz radio module. It is a very handy part for communicating between 2 Arduinos (for instance) but will not do Wifi.

Here is a tutorial for the RF24 radios if you are interested.

If you are going to buy an ESP8266 Wifi module, there are modules that include USB and some other features that make them easier to use.

So i purchased the wrong module, since I bought this one: https://www.robot-italy.com/it/wifi-serial-transceiver-module-w-esp8266-1mb-flash.html

However, this one should be the right one: https://www.robot-italy.com/it/wifi-module-esp8266.html

Is it correct?

Neither of those URL links work for me. I can get to the site but can't, easily, find what you bought.

Can you take photos (as close and clear as possible and both sides, please) of the Wifi module and post it here? How to post an image.

This is the module I've bought:

|375x500

|375x500

I've bought the module from this link, code 808419. Please, note that the module I've received is not the module that is showed in the product description's page and this is very strange to me.

If this is not the correct module, I 'm thinking to buy this other one from this link, code 713678.

The module that you posted photos of is a RF24 radio module. Not for WiFi.

The module in the first link is an ESP8266 module, but is not what the photos show.

The module in the second link is a ESP8266-01 module. If you buy that module I would recommend that you also buy a USB to TTL serial converter (FTDI). Like I said in a previous post, there are ESP8266 modules with the USB to TTL built in. I can't recommend any particular module as I have only used the bare ESP modules (ESP8266-12 is my favorite).

Fortunately, I found another module and I'm trying to use it right now.

This is the photo of the module I've just found in laboratory.

|375x500

Do you think it can be a good module to start with?

I'm trying to figure out how to connect it to Arduino and check if it works.

That is an ESP8266-01 module. Be aware that the ESP is a 3.3V device. Connecting any ESP input directly to an Uno (5V) ouput can damage the ESP pin. You can safely connect an ESP output directly to an Uno input.

There is lots of information on the net about connecting ESP to Uno.

I was able to successfully connect the module to arduino and to communicate with it at 115200 by using standard RX and TX pins on arduino.

Now I would like to communicate with it by using pins 10 and 11 with software serial.

Can I set the speed of the module at 9600 by using arduino? Or do I need a serial to USB adapter?

If you can communicate with the ESP you should be able to use the AT command to change the ESP baud rate. I leave it to you to find the proper AT command. I never have used AT commands so don't know them.