Hello,
I have a ESP8266 nodemcu v3 with a AJ-SR04M connector attached.
I am having issue to read any serial output in the Arduino IDE on different baud rates.
This is the sketch:
#define echoPin 11 // attach pin D2 Arduino to pin Echo of JSN-SR04T
#define trigPin 12 //attach pin D3 Arduino to pin Trig of JSN-SR04T
// defines variables
long duration; // variable for the duration of sound wave travel
int distance; // variable for the distance measurement
void setup() {
pinMode(trigPin, OUTPUT); // Sets the trigPin as an OUTPUT
pinMode(echoPin, INPUT); // Sets the echoPin as an INPUT
Serial.begin(74880); // // Serial Communication is starting with 9600 of baud rate speed
Serial.println("Ultrasonic Sensor HC-SR04 Test"); // print some text in Serial Monitor
Serial.println("with Arduino UNO R3");
}
void loop() {
// Clears the trigPin condition
digitalWrite(trigPin, LOW); //
delayMicroseconds(2);
// Sets the trigPin HIGH (ACTIVE) for 10 microseconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back)
// Displays the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");// working code for aj-sr04m
}
Serial monitor is set on the same baud rate (74880) and seeing following output:
rf[112] : 0��@q|!5�P��X�(~Q�sYI�"8�t�e/����T����DP@�����nzA )i~�#D!yu�R���)DP���1 �N|��)�~�Pza�~�PZ�P���1/Q"�rf cal sector: 1020
I have tried multiple baud rate both Serial.input as the serial monitor but doesn't help.
Any advice?
Thank you!