G
G
geebv2016-09-10 15:10:28
Arduino
geebv, 2016-09-10 15:10:28

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");
}

Gives random at a distance of more than 60cm
Ping: 58cm
Ping: 65cm
Ping: 65cm
Ping: 66cm
Ping: 62cm
Ping: 68cm
Ping: 65cm
Ping: 59cm
Ping: 67cm
Ping: 64cm

In the range from 20 to 55 cm, the value is stable - not jumping.
What happened? Is the iron broken? Is there something wrong with the program or could the libraries have been updated so that such an effect turned out?
I would be grateful for any thoughts. Thank you.
UPD
I’m lying, a month ago I measured the distance with such a function
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

2 answer(s)
G
geebv, 2016-09-20
@geebv

Problems in power, or rather due to the connection of autonomous power + USB in arduino. If you power JSN
-SR04T from arduino - order

O
Ocelot, 2016-09-12
@Ocelot

An oscilloscope in the teeth - and see what happens at the output of the sensor. If all signals are normal, the problem must be sought in the software part. If the sensor itself produces something wrong, then it is broken.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question