Chat freely about anything...

User avatar
By torjays455
#96085 In case someone else comes looking for an answer in the future, I figured out how to make this sensor work with an ESP8266 and ESP32. It turns out that you have to provide some signal/random noise on the RX pin of the A02YYUW sensor before taking a reading. I found this out by randomly jiggling the RX wire of the sensor after being frustrated for hours trying to get the sensor to output any measured distance values. The change of voltage levels on the RX pin made it magically work. So I added the following code to make the sensor get actual readings instead of ERRORing out.

Code: Select allvoid GetReading()
sensorSoftwareSerial.println("1"); // ** Put this line before your sensor reading code is **

// Code to perform the sensor reading goes here

Note that the value passed into println() doesn't matter. You can put any text in there (or even an empty string). This code line will cause the TX line on the ESP8266/ESP32 (which is connected to the RX of the sensor) to generate signals and thus "activating" the sensor.
User avatar
By nathan3000
#96198 Hello,
I have been unsuccessful so far despite following you advice.
Could you please have a quick look?
Thanks a lot
Code: Select all#include <SoftwareSerial.h>

// Ultrasonic Sensor
SoftwareSerial mySerial(10,9); // RX, TX

unsigned char data[4]={};
float distance;

void setup() {

void loop() {

  mySerial.println("1"); // ** Put this line before your sensor reading code is **

  //distance sensor start

     for(int i=0;i<4;i++)


      int sum;
               Serial.println("Below the lower limit");
      }else Serial.println("ERROR");

  //distance sensor end