Maxbotix ultrasonic sensor with serial port

Hello I’m trying to get a maxbotix ultrasonic sensor working with ardupilot on a bbblue linux system. the signal is inverted but i have inverted this so that the serial line gives the ‘Rxxx’ on the bbb serial device where xxx is the ground distance in inches. I am unsure how to get this into ardupilot. Could anyone give me some pointers? I’ve tried configuring the sensor in apmplanner, but I don’t really understand how ardupilot figures out where the sensor should be.

Hello @SuzL

You need to have ArduPilot (ArduCopter or other vehicle) running on the Blue
You can refer to this: BeagleBone Blue released, Linux-enabled autopilot for 80$

Then you Use Mission Planner to connect to BeagleBone and go to

and you should get your reading when looking at

thanks for the speedy reply. I can get ardupilot running fine, I’ve experimented with ground station parameters without success, but i’ll give it another go tomorrow.

btw Does the driver code transmit anything to the sensor? currently i’ve only implemented an inverter on the sensor to board line, the other being disconnected, so that might be the reason no joy as yet if it is trying to send it a signal. weird that the sensor works fine on the board otherwise though.

Can you sketch a simple diagram of your connection on the Blue and what ttyOx port you are using ?
This inverter thing seem not common, and I suapect there is is something wrong.

A very important note is that you need to map the ttyOx pot to the Ardupilot Serial device like for example:

Parameter mapping:

start parameter ArduPilot serial port
Check to set the right value for SERIALx_BAUD == Maxbotic default is 9600 bauds (i think)
and SERIALx_PROTOCOL == 9 for RangeFinder (LIDAR)

For example:
If you want to set Maxbotix to Ardupilot SERIAL1 and connected to BBLUE UART4 add -C /dev/ttyO4.

Hello, I attach some photos. The specific sensor is the LV-MaxSonar EZ4 MB1040, tucked away in the data sheet for it is the information that it inverts the serial line, and this is why the inverter is implemented. As demonstrated, it works fine with this if plugged in. I’m not using the ttyOx port, but the ttyS5 port, referencing this as ttyO5 doesn’t work.

Ardupilot doesn’t seem to find it at all, so apmplanner2 doesn’t display or put it in the status bar.

thankyou very much for your help!

OK I looked at specs : Serial output: asynchronous, logic-level, inverted, 9600 bps 8N1

So you have to set in APM PLANNER:
Baud =9 9600
Protocol = 9 Lidar

RNGFND_TYPE = 13 MaxbotixSerial

If you can read ttyS5 with SCREEN or MINICOM , you should read it with Arducopter/ArduPlane

Thankyou, at this time I can’t get it talking to ardupilot (with these settings it doesn’t appear to recognise it, I’ve had some issues with the bbb device tree configuration, so I haven’t as yet isolated the solution. I’m trying analogue input which is better documented. I’ll document here any progress made.

I suggest you try with MINICOM to see if you can read signal on a serial port of the BBB

Well previously it worked with screen, a console program to read the serial ouput, I understand from googling Minicom this is another terminal editor, so I would expect it to give the same output (unfortunately I have to prioritise other ardupilot work). The terminal editor recognised the connection, but the Ardupilot code HAL didn’t recognise it as a valid sensor for reasons I have not been able to determine. I will revisit this and post when I have this working.

NB in the images above, the screen result is the ‘R082’ in the right hand window. This shows the sensor is working - this is a distance in inches picked up by the sensor.

Ok so I guess you set screen to /dev/ttyS5 and 9600 bauds to make it work.
Setting SERIAL4 to Baud =9 9600 and Protocol = 9 Lidar
RNGFND_TYPE = 13 MaxbotixSerial

should work, I suggest you try with Mission Planner, just in case

Ok I have tried this with mission planner. when it is connected to any port (via the ardupilot launcher) other than the correct one I get bad lidar health. when connected to the correct one I get this bug However I have checked and it is generating a non zero sonarrange. I will check in other gcs.


That’s normal , we call it the ‘‘radar’’ screen (btw its now a CTRL-F feature on new releases of MP), this mean that your range finder reads OK but in a direction that is not DOWN , look in the parameters and you should see the orientation

thx, i think it is maybe a hardware interaction bug, as initially as well as opening millions of those windows (it wouldn’t stop), when i initially opened apmplanner2, it spammed that startup window. that has stopped, and i am getting something approaching sensible readings from it. I’ll update when it has been soldered into an airframe and tested on a vehicle. I am dubious of the quality, and especially running it completely without the tx line connected, but it sort of works now! Thx for your help :slight_smile: