Room Occupancy Counter with VL53L0X

General project help for Adafruit customers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
carsonf
 
Posts: 9
Joined: Mon May 08, 2017 1:40 pm

Re: Room Occupancy Counter with VL53L0X

Post by carsonf »

Ok what the heck. I switched USB ports and it started working. :facepalm:

Thanks for your help Frank!

User avatar
frankrnichols
 
Posts: 13
Joined: Mon Mar 27, 2017 7:02 pm

Re: Room Occupancy Counter with VL53L0X

Post by frankrnichols »

No ideas except this general idea that I've used whenever troubleshooting code - since 1979,

Reduce your code to the simplest (fewest) lines you can that still exhibit the problem, and go from there.

Meanwhile, if I were you, I would slavishly copy my code (the clips I post/will post), which has been working just fine for months, and see where you get. If that works, then you can start looking for how your code differs.

Here is my simplest complete working code that spits out the ranges for TWO sensors in a loop.

I tested this (compiled, loaded my dual sensor Adafruit Feather M0 with 2 sensors) - FIVE MINUTES AGO
- 1 had one VL53L0X board's XSHUT/SHDN floating
- 1 had the other board's XSHUT/SHDN tied to '9' on the Feather M0
and as I moved my hand back and forth, just now, I saw this:
29,8190,23,170
29,8190,23,219
29,8190,23,8190
29,8190,23,8190
29,8190,23,8190
29,8190,23,226
29,8190,23,187
29,8190,23,159
29,17,23,141
29,0,23,128
29,59,23,126
29,111,23,8190
29,111,23,285
29,116,23,8190
29,134,23,8190
29,8190,23,8190
29,8190,23,8190
29,8190,23,8190
What follows is the ENTIRE SKETCH

Code: Select all


#include <Arduino.h>
#include <SPI.h>
#if not defined (_VARIANT_ARDUINO_DUE_X_) && not defined (_VARIANT_ARDUINO_ZERO_)
  #include <SoftwareSerial.h>
#endif

#include <Wire.h>
#include <VL53L0X.h>

VL53L0X sensor29;
VL53L0X sensor23;

#define XSHDN_OF0X29  9

void setup()
{
  while (!Serial);  // required for Flora & Micro
  delay(500);
  Serial.begin(9600); 
  
  Wire.begin(); 
  pinMode(XSHDN_OF0X29, OUTPUT);
  digitalWrite(XSHDN_OF0X29, LOW);
  delay(100);
  
  sensor23.setAddress(0x23);
  delay(10); // for good luck?
  digitalWrite(XSHDN_OF0X29, HIGH); // should now have two addresses on the I2C

  sensor23.init();
  sensor23.setTimeout(500);
  sensor23.startContinuous();
  
  sensor29.init();
  sensor29.setTimeout(500);
  sensor29.startContinuous();
}

void loop(void)
{
  Serial.print("29,");
  Serial.print(sensor29.readRangeContinuousMillimeters());
  if (sensor29.timeoutOccurred()) 
  {
    Serial.print(" TIMEOUT 29"); 
  }
  Serial.print(",23,");
  Serial.println(sensor23.readRangeContinuousMillimeters());
  if (sensor23.timeoutOccurred()) 
  {
    Serial.print(" TIMEOUT 23"); 
  }
  delay(100);
}

User avatar
frankrnichols
 
Posts: 13
Joined: Mon Mar 27, 2017 7:02 pm

Re: Room Occupancy Counter with VL53L0X

Post by frankrnichols »

Cool.
Glad you got it working.

User avatar
chipou
 
Posts: 1
Joined: Mon Jun 05, 2017 7:14 pm

Re: Room Occupancy Counter with VL53L0X

Post by chipou »

Hello everybody,
I am working on the same issues with the sensor VL53L0X with arduino. For the moment I am making the test with only one sensor but I am getting the same result 65535
and it doesn't change.
I read your comments but I didn't really understand what I need to change.
Any help please?
Thank you very much

User avatar
toasterking
 
Posts: 2
Joined: Thu Jun 15, 2017 11:36 pm

Re: Room Occupancy Counter with VL53L0X

Post by toasterking »

@carsonf, I'm curious how this project worked out for you. I had read the same blog entry you linked about people counting and had the same thought, that I could do it better with ToF sensors rather than infrared. I was thinking I would try mounting 2 of these VL53L0X sensors on the ceiling on each side of the doorway for a total of 4 per door. In addition to checking the direction of movement, the distance detection could be used to judge whether the movement is an adult, child, or pet traversing the doorway (based on their height), or just the door being closed or opened.

Did this approach work out for you? Did you hit any snags other than setting up initial communication and sensor IDs?

Thanks!

User avatar
adafruit2
 
Posts: 22411
Joined: Fri Mar 11, 2005 7:36 pm

Re: Room Occupancy Counter with VL53L0X

Post by adafruit2 »

guide and source code have been updated with multi-sensor support

https://learn.adafruit.com/adafruit-vl5 ... le-sensors

User avatar
toasterking
 
Posts: 2
Joined: Thu Jun 15, 2017 11:36 pm

Re: Room Occupancy Counter with VL53L0X

Post by toasterking »

adafruit2 wrote:guide and source code have been updated with multi-sensor support
Thanks, @adafruit2! You're a hero! :D

I no longer have any reasons not to buy some VL53L0X units. :-)

Locked
Please be positive and constructive with your questions and comments.

Return to “General Project help”