Answer the question
In order to leave comments, you need to log in
Why does JSN-SR04T not work beyond 60cm?
A month ago I bought everything I need for the JSN-SR04T test. Everything worked correctly. 1.5 meters showed. Even 2 meters showed.
Today I opened the IDE, some updates were - updated. Didn't matter.
I launched the program, but it does not show values beyond 55cm.
Program code
#include <NewPing.h>
#define TRIGGER_PIN 11
#define ECHO_PIN 12
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
void setup() {
pinMode(12, INPUT);
pinMode(11, OUTPUT);
Serial.begin(115200);
}
void loop() {
delay(1000);
int cm = sonar.ping_cm();
Serial.print("Ping: ");
Serial.print(cm);
Serial.println("cm");
}
Ping: 58cm
Ping: 65cm
Ping: 65cm
Ping: 66cm
Ping: 62cm
Ping: 68cm
Ping: 65cm
Ping: 59cm
Ping: 67cm
Ping: 64cm
long request_dist(int echo, int trigger) {
digitalWrite(trigger, LOW);
delayMicroseconds(2);
digitalWrite(trigger, HIGH);
delayMicroseconds(10);
digitalWrite(trigger, LOW);
long duration = pulseIn(echo, HIGH);
long distance_cm = duration /58;
return distance_cm;
}
Answer the question
In order to leave comments, you need to log in
Problems in power, or rather due to the connection of autonomous power + USB in arduino.
If you power JSN
-SR04T from arduino - order
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question