Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial Driver for SR04 v2 ultrasonic rangefinders #19961

Closed
geofrancis opened this issue Feb 1, 2022 · 1 comment
Closed

Serial Driver for SR04 v2 ultrasonic rangefinders #19961

geofrancis opened this issue Feb 1, 2022 · 1 comment

Comments

@geofrancis
Copy link

geofrancis commented Feb 1, 2022

Almost all SR04 ultrasonic sensors and their derivatives now support a serial mode natively, instead of just the trig echo the old SR04 used to use. This DRAMATICALLY increases the accuracy of these sensors to almost millimeter precision since its no longer subjected to timing problems as its all processed internally on the sensor now and it just spits out a value over serial. it will also make a big difference when using them underwater where errors are multiplied.

Mode 2: R27 = 47K is the welding 47K resistance. The pattern is described below
Serial output format for the TTL level, that: 100MS module for the cycle of automatic output distance
value, the unit is mm. Serial baud rate: 9600, n, 8,1.
After the module is powered on, it will enter the working mode directly, and the range will be carried out
every 100ms within the module and one frame will be output from the pin TX, including four 8-bit data.
The frame format is: 0XFF + H_DATA + L_DATA + SUM

Product response FF 07 A1 A7

1.0XFF: for a frame to start the data, used to judge;
2.H_DATA: the upper 8 bits of the distance data;
3.L_DATA: the lower 8 bits of the distance data;
4.SUM: data and, for the effect of its 0XFF + H_DATA + L_DATA = SUM (only low 8)

Note: H_DATA and L_DATA synthesize 16-bit data, that is, the distance in millimeters
E.G:

Where the check code SUM = A7 = (0x07 + 0xA1 + 0Xff) & 0x00ff
0x07 is the high data of the distance;
0xA1 is the lower data of the distance;
Distance value is 0x07A1; converted to decimal for 1953; unit: mm
Description: The module outputs the nearest distance value in the dead zone, and outputs 0 if the
module does not measure the data or is out of range.
LED indicator, LED non-power indicator, the module connected to work after the light, then the module
is working

Mode 3: R27 = 120K that is welding 120K resistance. In the serial port mode
After the module is powered on, the module enters standby mode. The serial output format is TTL level, serial
port baud rate: 9600, n, 8,1. When the RX port receives the 0X55 instruction, the module starts a ranging and
outputs one frame from the pin TX with four 8-bit data. The frame format is: 0XFF + H_DATA + L_DATA + SUM
1.0XFF: for a frame to start the data, used to judge;
2.H_DATA: the upper 8 bits of the distance data; 3.L_DATA:
the lower 8 bits of the distance data;
4.SUM: data and, for the effect of its 0XFF + H_DATA + L_DATA = SUM (only low 8) Note:
H_DATA and L_DATA synthesize 16-bit data, that is, the distance in millimeters
Description: The module outputs the nearest distance value in the dead zone, and outputs 0 if the module
does not measure the data or is out of range.
LED indicator, LED non-power indicator, it will receive the 0X55 trigger signal after the module will be lit, then the
module is working.

https://discuss.ardupilot.org/uploads/short-url/bhOKTSUrHmvAc5FZEEgQpVT27nf.pdf

https://wiki.dfrobot.com/_A02YYUW_Waterproof_Ultrasonic_Sensor_SKU_SEN0311

@geofrancis
Copy link
Author

geofrancis commented Feb 16, 2022

I have edited the Benewake serial driver to the best of my ability to work with a sr04 in serial mode but I need somone that knows what they are doing to make it work and remove the last of the benewake parts

https://tutorials.probots.co.in/communicating-with-a-waterproof-ultrasonic-sensor-aj-sr04m-jsn-sr04t/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant