Sonar JSN-SR04T

It shows the vehicle height above the terrain when set to orientation 25.

why do you need it negative? there might be other solutions

I created a budget fishing boat from what was. I’m using the old one FlySky FS i6 and there is no lua script. and having received a negative, I could roughly see the relief of the bottom without much expense .

ah ok so you want the graph inverted so it shows the profile of the bottom. how have you got the sensor connected to ardupilot?

using the example given above

using bot ChatGPT added data output to the port monitor.and added add a minus sign to the value of the reading_cm variable ```cpp
#include <Wire.h>
#include “SR04.h”

#define TRIG_PIN 12
#define ECHO_PIN 11

SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
int16_t reading_cm;
uint16_t tempread;

void setup()
{
reading_cm = 0;
Wire.begin(0x70); // join i2c bus with address #2
Wire.onRequest(requestEvent); // register event

Serial.begin(9600); // Start serial communication
}

void loop()
{
tempread = 1 * sr04.DistanceAvg(25, 1);
if (tempread < 1500)
reading_cm = tempread;

Serial.print(“-”); // Print “-” before the reading_cm value
Serial.println(abs(reading_cm)); // Print the absolute value of reading_cm to serial monitor
}

void requestEvent()
{
byte sendhi;
byte sendli;
byte sendbyte[2];
uint16_t tempreading_cm = abs(reading_cm); // Get the absolute value of reading_cm
sendhi = tempreading_cm >> 8;
sendli = tempreading_cm & 0xff;
sendbyte[0] = sendhi;
sendbyte[1] = sendli;
Wire.write(sendbyte, 2);
}

at the request to add a minus sign to the i2c submission, the bot suggested adding reading_cm = -tempread to the line; // setting the minus sign

as a result, Mission Planner outputs values not from negative but 32786

Rangefinders don’t work with negative values, they only show distance to an object .

you could use a lua script to invert the value and create a virtual sensor with the value you want. I was using it to scale the rangefinder for the spee of sound in water but it would work if you want to invert it.

see here

thank you so much I will try

I tried to test the aj-sr04m in water. I lowered it from a boat into the water at different depths. The readings are always minimal (200 mm). This is without correction for the speed of ultrasound in water. If the sensor is pulled out of the water, the readings change, everything works. I tried it in two modes - the default - when we measure the duration of the Echo pulse (R19 is missing) and in the M2 mode R19 = 120 kOm). I used code examples from here: How to Communicate Waterproof Ultrasonic Sensor AJ-SR04M/JSN-SR04T with Arduino/ESP32 – Probots Blog
Doesn’t work in water, regardless of depth. Tell me what to pay attention to?

how deep was the water, the single transducer wont get readings under 1.5 meters when in water. you need a dual transducer version to get readings down to 15cm.

I understand this, I read on forums about minimum depths. And I tried it at greater depths and not in barrels, but on the lake. Apart from the minimum depth, are there any special features? Does everything work in any mode (M1, M2, …)?

it should work, it has been tested here

Thanks, I’ll try again

Was this test somewhere? I want to do it :slight_smile:
I need to use this sonar?
Capture d’écran 2023-10-25 204608

yes thats the sonar I used.

today was the first time i had a chance to test this sonar is some deep water. as far as I know the pond is an old mine that’s covered in weeds so i suspect the vegetation was inhibiting the sonar, but still it was getting intermittent returns, the deepest reading was at 21 meters. I would like to do some testing over a cleaner bottom like sand or concrete to see if it improves its performance.

I have got a fishing sounder that im going to take next time to verify the depth readings as i dont think the pond is that deep, I think 21 meters is a false reading.

1 Like

I have been doing some more investigation with the dual transducer sonar. I needed to space them apart by at least 25cm before it would start to give reliable readings.

This is strange because I am sure i have tested the sensors last year in the bath and they worked fine with almost no spacing, so I think the board has been changed somehow and its the new versions causing issues. I think the issue is that because of the speed of sound is so much faster and incompressible, A strong signal is arriving at the receiver directly causing interference and the sensor to miss the echo.

I think this is why I’m getting such intermittent returns from my sonar when testing it.

Perhaps it’s all about the purity of the water, it’s clean in the bathroom and the signal is not re-reflected. And in natural conditions, the water is not so clean. And yet these are just parking sensors, you can’t expect a good signal from them.

I am going to install one of the single transducer sonar boards to test if the issues are specific to the dual transducer model.

This could explain a lot, I was probably using version 1 sensors when i installed them in my first boat, now I’m using a mix of v2.0 and v3.0 sensors that are apparently very unstable. from the video it looks like the changed the crystal from 8mhz to 11mhz so the frequency has probably also shifted slightly.

It looks like you can still find original modules by looking for the AJ-SR04M and checking its got a 8mhz crystal.

I found this new sonar module. its a RCWL-1655 and it looks like it could be a updated version of the AJ-SR04T that supports uart and i2c

some reading here indicates that it can have issues with soft targets so its possible the weeds were inhibiting the sonar return /

These little led displays make testing much easier as i don’t need any other electronics connected to get a reading

the A02YYUW should still work

I totally forgot you had made this video. it shows it working how I remember these sensors operating, I wonder what has changed. Im going to have to get my old boat out to test as it should still have v1 sensors in it.

1 Like