Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more.
0

Proximity sensor using VL53L0x
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Proximity sensor using VL53L0x

by Hailer on Thu Mar 19, 2020 3:47 am

Hello

I am trying to use the VL53L0x and a Trinket M0 to sense the presens of a person.

I have got it to work meassuring distance with the given CircuitPhyton code:

import board
import busio
import adafruit_vl53l0x

i2c = busio.I2C(board.SCL, board.SDA)
vl53 = adafruit_vl53l0x.VL53L0X(i2c)
vl53.measurement_timing_budget = 20000

while True:
print('Avstand: {0} mm'.format(vl53.range))
time.sleep(1.0)

But rather than meassuring distance I would like it to give a signal on any of the io pins of the Trinket M0,
when somebody is in front of the sensor. (to drive a relay or a transistor) .
I have spent the day looking for such a code with limited sucsess.
Can anybody help :?:

Regards Jan S

Hailer
 
Posts: 2
Joined: Thu Mar 19, 2020 3:36 am

Re: Proximity sensor using VL53L0x

by dastels on Thu Mar 19, 2020 10:34 am

All you get from the sensor is the range reading. You can take that and compare it with how close something should get in order to trigger the output. You can do something like:

Code: Select all | TOGGLE FULL SIZE
output_pin.value = (vl53.range <= threshold)

dastels
 
Posts: 1906
Joined: Tue Oct 20, 2015 3:22 pm

Re: Proximity sensor using VL53L0x

by Hailer on Thu Mar 19, 2020 1:20 pm

Thanks a lot for this,
I was lost :)

Hailer
 
Posts: 2
Joined: Thu Mar 19, 2020 3:36 am

Please be positive and constructive with your questions and comments.