latpate.aniket92
Posts: 4
Joined: Sat Jun 22, 2019 5:47 pm

Python code for Maxbotix HrXL-Wr (MB7360) Ultrasonic Sensor in I2C with raspberry pi.

Sat Jun 22, 2019 9:40 pm

Hello,

I am still a newbie, I am trying to connect Maxbotix's MB7360 (ultrasonic Sensor) ( https://www.maxbotix.com/Ultrasonic_Sensors/MB7360.htm) in i2c with Raspberry Pi but could not find python program for it.
I am using ADS1115 to connect it in i2c to measure distance in Cm. Did anyone work on it before? Please help me with it, I attached a rough freehand drawing in the attachment. Thanks a million.
Freehand diagram-min (1).jpg
Freehand diagram-min (1).jpg (152.56 KiB) Viewed 870 times

pcmanbob
Posts: 6917
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Python code for Maxbotix HrXL-Wr (MB7360) Ultrasonic Sensor in I2C with raspberry pi.

Sun Jun 23, 2019 9:39 am

The first thing is that the pi gpio is 3.3v connecting 5v to it will almost certainly damage the gpio and cause the pi to stop working sooner or later.

also I don't see any address set up on the ADS1115 in your diagram ?

I suggest you go look at these web sites on how to connect your ADS1115 to your pi ( assuming your pi is still working )

https://learn.adafruit.com/raspberry-pi ... sh-ads1115
https://learn.adafruit.com/adafruit-4-c ... cuitpython

You should also be aware that the maximum voltage the ADS1115 can read is 3.3v when connected to a pi due to the 3.3v gpio.

and lastly are you sure you have a sensor with the correct output as there seems to be a selection of possible data outputs .
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

ghp
Posts: 1408
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Python code for Maxbotix HrXL-Wr (MB7360) Ultrasonic Sensor in I2C with raspberry pi.

Sun Jun 23, 2019 11:19 am

The distance sensor should work with 3.3V also, according to the datasheet. You could power both ads1115 and MB7360 from 3.3V.
You do not need R1, R2, as pullup are already provided on RPi for I2C signals.

Option1: power both chips from 3.3V, remove R1, R2.
Option2: power ADS1115 from 3.3V, remove R1, R2. Power MB7360 from 5V. Provide a voltage divider 5V to 2.048V (max scale setting from ads datasheet, Table3.PGAGainFull-ScaleRange, max scale which fits into 3.3V supply).
Option 3: power all chips from 5V, but then you need a level shifter for the I2C signals. Something like a "4-channel I2C-safe Bi-directional Logic Level Converter", example adafruit PRODUCT ID: 757. R1, R2 are then needed on 5V side.

Option 4: the MB7360 has a serial output, RS232 for 0, VCC. With a simple inverter, it should be possible to use serial input on RPi, eliminating the need for the AD-converter. This should also give better resolution. From the datasheet:

Pin 3-Analog Voltage Output: This pin outputs a single ended analog voltage scaled representation of the distance. ... The distance is output with a 5-mm resolution. The analog voltage output is typically within ±5-mm of the serial output.

Pin 5-Serial Output: The MB736X sensors have an RS232 data format (with 0V to Vcc levels) ... followed by four ASCII character digits representing the range in millimeters

User avatar
rpdom
Posts: 15184
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Python code for Maxbotix HrXL-Wr (MB7360) Ultrasonic Sensor in I2C with raspberry pi.

Sun Jun 23, 2019 3:42 pm

ghp wrote:
Sun Jun 23, 2019 11:19 am
Option 3: power all chips from 5V, but then you need a level shifter for the I2C signals. Something like a "4-channel I2C-safe Bi-directional Logic Level Converter", example adafruit PRODUCT ID: 757. R1, R2 are then needed on 5V side.
You shouldn't need to worry about a level shifter. I2C is an open collector bus, which means it will pull the lines down to 0V when active, but leave it to the pull-up resistors to set the high level. The Pi's on-board pull-ups pull to 3.3V. Most I2C devices that run from 5V will accept the 3.3V as a logic high.

latpate.aniket92
Posts: 4
Joined: Sat Jun 22, 2019 5:47 pm

Re: Python code for Maxbotix HrXL-Wr (MB7360) Ultrasonic Sensor in I2C with raspberry pi.

Sun Jun 23, 2019 8:07 pm

Thanks a million everyone, appreciate your help. I will try these options and update here.

Return to “Python”