RX doesn't work on ESP8266-E12 AI

Hello everybody, i have a problem with my esp8266 e12 wifi module. When I use a TX pin to send data, data are successfully sent, but if i would like to receive data from arduino uno, via my RX pin ( numer 21 ) it doesn’t work. The code is for sure correct, because on another device, this one is properly working, but on my ESP8266 NOT ! :frowning:

I use a serialsoftware : it’s my sketch to receive data:

#include <SoftwareSerial.h>

SoftwareSerial portTwo(21, 22);

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


  // Start each software serial port
 
  portTwo.begin(9600);
}

void loop() {
 
  Serial.println();

  while (portTwo.available() > 0) {
      Serial.println("Data from port two:");

    char inByte = portTwo.read();
    Serial.println(inByte);
  }

  Serial.println();
}

On my console Serial i get this :

lrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrLrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrlrll

I think that : portTwo.available() > 0 is not working correct… but WHY ? TX is ok, but not RX …

[/url]

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

I know that it is very simply way to receive data, but i use my scatch who is very similar, (the same idea), but ii doesn't work on esp8266-E12... When i use it on arduino uno, the same code is working good...

I don't know where is the problem, because, when i use esp8266 to send by TX then it is ok.. but when i would like to receive data via RX pin ( number pin - 21 ) - it doesn't work...

So strange... If i set a RX pin to pin number 22 ( normally its a TX pin ) , and moreover i connect a RST pin on ESP8266 with VCC on Arduino uno .. than receiving data work good... but i don't have now a pin with TX ...

Like Robin2 suggested, “Serial Input Basics” is a good place to start.

The problem is that you are trying to print 24 characters for each character you receive. And you are trying to print two new lines (4 more characters) every time loop is called. loop is called many, many times.

After just 16 calls to loop, the output buffer for Serial will be full. This could happen before any characters have been received on portTwo. Then, when you try to print one character from portTwo, it will have to wait for the 24 characters of “Data from port two:\r\n” to be printed. During that time, 24 more characters may have been received on portTwo. Eventually, the input buffer for portTwo will be full, and all other received characters will be dropped (ignored).

Have you tried a simple echo test?

void loop() {
  while (portTwo.available() > 0) {
    Serial.println( portTwo.read() );
  }
}

Cheers,
/dev

yes i've tried it but if i set SoftwareSerial(RX,TX) , and if i send data, it is working but i getting data on TX port... So strange ... If i change the pins number, situation is the same... RX doesn't work...

yes i've tried it but if i set SoftwareSerial(RX,TX) , and if i send data, it is working but i getting data on TX port... So strange ... If i change the pins number [to something], situation is the same... RX doesn't work...

Obviously, it doesn't work because of something.

When you get a sketch like "Serial Input Basics" running on the Arduino, try it on the ESP8266. Then show us the code and data that does and/or doesn't work.

Ambiguously, /dev

I used a sketch like a Serial Input Basic and the result is the same like above ... I suppose that this ESP8266 can be broken ..

@/dev

I tried use another ESP8266 and the result is the same… Only TX working…

This is my sketch on ESP8266, he gets data from Arduino UNO, and when i connect wire to TX so, it’s working, but, when i connect wire to RX it doesn’t work… So strange… becouse, when i change pins (21,22) → (22,21) , the result is the same… only TX working…

/*
  Software serial multple serial test

 Receives from the two software serial ports,
 sends to the hardware serial port.

 In order to listen on a software port, you call port.listen().
 When using two software serial ports, you have to switch ports
 by listen()ing on each one in turn. Pick a logical time to switch
 ports, like the end of an expected transmission, or when the
 buffer is empty. This example switches ports when there is nothing
 more to read from a port

 The circuit:

 
 Two devices which communicate serially are needed.
 * First serial device's TX attached to digital pin 10(RX), RX to pin 11(TX)
 * Second serial device's TX attached to digital pin 8(RX), RX to pin 9(TX)

 Note:
 Not all pins on the Mega and Mega 2560 support change interrupts,
 so only the following can be used for RX:
 10, 11, 12, 13, 50, 51, 52, 53, 62, 63, 64, 65, 66, 67, 68, 69

 Not all pins on the Leonardo support change interrupts,
 so only the following can be used for RX:
 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

 created 18 Apr. 2011
 modified 19 March 2016
 by Tom Igoe
 based on Mikal Hart's twoPortRXExample

 This example code is in the public domain.

 */

#include <SoftwareSerial.h>
// software serial #1: RX = digital pin 10, TX = digital pin 11


// software serial #2: RX = digital pin 8, TX = digital pin 9
// on the Mega, usae other pins instead, since 8 and 9 don't work on the Mega
SoftwareSerial portTwo(21,22);

void setup() {
 
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  portTwo.begin(9600);


  // Start each software serial port
 
 
}
void loop() {
  while (portTwo.available() > 0) {
    
    char c=portTwo.read();
    Serial.print(c);
  }
}

when i connect wire to [u]TX[/u] so, [u]it's working[/u], but, when i connect wire to [u]RX[/u] [u]it[/u] [u]doesn't work[/u].... So strange.. becouse, when i change pins (21,22) --> (22,21) , [u]the result[/u] is the same.. only [u]TX[/u] working...

Ambiguous. Both the ESP8266 and the UNO have pins and wires. Both the ESP8266 and the UNO can send (TX) and receive (RX) to each other. What do you mean "working"? What "doesn't work"? What do you see that tells you it doesn't work?

Please read Section 11 here.

For example, you haven't provided a circuit diagram. So I have to [u]ask[/u], "Are you shifting the voltage levels?" The ESP8266 is a 3.3V device. The UNO is a 5V device. The UNO voltages could damage the ESP8266.

Ok, sory friend, so look:

This is my schematic: |362x500

And what is the problem :

ESP8266 Nodemcu V2 : RX - pin 20, TX - pin 21 ARDUINO UNO - RX pin 1, TX - pin 0

Two connection wire : -connection one : pin 0 with pin 20 -connection two : pin 1 with pin 21

Send data from ESP8266 to UNO - working ok via connection two Send data from UNO to ESP8266 - not working ! via connection one

When i change the wires and pins :

-connection one : pin 0 with pin 21 (tx - tx) - when i send data from UNO to ESP8266 , data send are good. IT's working

-but connection two - pin 1 with pins 20 - not working .

ALWAYS, when i use to transmit data via pins 20 on esp8266, always it isn't working...nothing when i use a pin 21 on ESP8266, to send or receive data, it's working good... so strange .. everything is ok but no pins/port number 20 on ESP8266.

I need transmit data in both side, so i need a pin RX and TX on esp8266.. pin 21(TX) isn't enough....

I think that it is so weird, because, it can see like a broken pin RX on Esp8266, but i tried a another ESP8266 and it is the same problem...

The ESP8266 is a 3.3V device. The UNO is a 5V device. The UNO voltages could damage the ESP8266.

Connecting UNO pin 0 (~4.8V TX) to the ESP8266 pin 20 (RX with ~3.6V limit) may have damaged the ESP8266.

There are lots of ways to do the level shifting. I prefer level-shifting modules, because they can handle higher speeds than some of the simpler ways (a few resistors).

Friend, i bought today a Logic Level Converter 3.3/5V and when i connect everything, the result is the same... :/ Help :/

AlvaroFacando: ...when i connect everything, the result is the same...

How is everything connected? Take a picture, draw another paint image, or try one of these schematic web sites:

Scheme-It CircuitLab circuits.io CircuitBee

It may never work, though. You may have damaged that pin. (That's the 3rd time I've said that. -_- )

There may be something specific to the ESP8266, I don't know. That would be a question for a ESP8266 forum. They would also want to see your code and your schematic.