Twitter icon
Facebook icon
LinkedIn icon
Google icon
Reddit icon
StumbleUpon icon
Del.icio.us icon

Pocket Distance Alarm: Keep 1m Away from Me - Seeeduino Xiao

Added to IoTplaybook or last updated on: 04/27/2020
Pocket Distance Alarm: Keep 1m Away from Me - Seeeduino Xiao

Story

According to a press release from the Ministry of Health on Thursday, Singapore has announced stiff fines and jail for those who do not observe social distancing measures put in place to contain the coronavirus outbreak. People who do not observe physical distancing of one meter in “non-transient” interactions can be fined up to 10, 000 Singapore dollars ($6, 985) or be jailed up to six months, or face both penalties.

Such interactions include people on seats not fixed to the floor, who intentionally sit less than one meter from another seated individual in a public place. People standing in a queue in public places who are less than one meter away from the next person will also be prosecuted, according to the rules.

It is necessary for this critical period to keep a distance from others. However, it is not that easy to keep this in mind every second or remind those careless people who used to be too close with others. I made this little pocket distance alarm to solve this problem, which could give out light and sound warning when people getting into your one-meter circle.

Things used in this project

Hardware components

 
Seeeduino XIAO
 
× 1

Seeed

 
Seeed Grove - LED Pack
 
× 1

Seeed

 
Seeed Grove - Buzzer
 
× 1

Seeed

 
Seeed Grove - Time of Flight Distance Sensor(VL53L0X)
 
× 1

Seeed

Software apps and online services

Arduino IDE
Arduino IDE
 
  Arduino

Hand tools and fabrication machines

 
Electric Soldering Iron

Step 1: Hardware Connection

Since it is a small wearable product that could not have too big size, I choose to use Seeeduino Xiao as the mainboard. Seeeduino Xiao is the new release product of Seeedstudio, and the smallest board I could ever have.

The hardwired connection could be found as followed.

P.S.: I draw this as 1:1 ratio, and Seeeduino Xiao is really xiao!!!

BTW, “Xiao” means “Small”(小) in Chinese.

Step 2: Soldering

Though Xiao is really tiny and cute, the sodering part needs patience. It is said that the breakout board of Xiao will be released soon, therefore hopefully we could enjoy both the tiny size of Xiao and easy grove connection without sodering soon.

My sodering skill is far from excellent. As the outcome, you could see.


1/2


2/2

Step 3: Upload the Code and Test

  • First you need to download the VL53L0X Library from Github.
  • Extract the Grove-Ranging-sensor-VL53L0X-master.zip file into the Arduino library folder.
  • Upload the demo. If you do not know how to upload the code, check How to upload code.
  • Open the Serial Monitor of Arduino IDE by click Tool-> Serial Monitor. Or tap the Ctrl+Shift+M key at the same time. Choose 115200 serial, if everything goes well, you will get the distance result from the monitor.

Step 4: Design the Shell and Laser Cutting

Note: The grey line is for indicating the module position, only the black line should be cut.

Of course, you could design more shapes of the shell as long as you could fit all things in.

Step 5: Assembling the Parts

 

Step 6: Finish!

Pocket Distance Alarm: Keep 1m Away from Me - Seeeduino Xiao

Schematics

_f3YT9f5yAJ.png

 

Code

Distance_Alarm_Makerming.ino

Arduino

 

const int Buzzer = 8;// D8
const int LED = 7;//LED D7

#include "Seeed_vl53l0x.h"
Seeed_vl53l0x VL53L0X;  //tof   IIC D4 D5   

#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
    #define SERIAL SerialUSB
#else
    #define SERIAL Serial
#endif

void setup() {

    pinMode(Buzzer, OUTPUT);
    pinMode(LED, OUTPUT);
    digitalWrite(Buzzer, LOW);   // turn the Buzzer on (HIGH is the voltage level)
    digitalWrite(LED, LOW);   // turn the LED on (HIGH is the voltage level)
            

    VL53L0X_Error Status = VL53L0X_ERROR_NONE;
    SERIAL.begin(115200);
    Status = VL53L0X.VL53L0X_common_init();
    if (VL53L0X_ERROR_NONE != Status) {
        SERIAL.println("start vl53l0x mesurement failed!");
        VL53L0X.print_pal_error(Status);
        while (1);
    }

    VL53L0X.VL53L0X_long_distance_ranging_init();

    if (VL53L0X_ERROR_NONE != Status) {
        SERIAL.println("start vl53l0x mesurement failed!");
        VL53L0X.print_pal_error(Status);
        while (1);
    }

}

void loop() {

    VL53L0X_RangingMeasurementData_t RangingMeasurementData;
    VL53L0X_Error Status = VL53L0X_ERROR_NONE;

    memset(&RangingMeasurementData, 0, sizeof(VL53L0X_RangingMeasurementData_t));
    Status = VL53L0X.PerformSingleRangingMeasurement(&RangingMeasurementData);
    if (VL53L0X_ERROR_NONE == Status) {
        if (RangingMeasurementData.RangeMilliMeter >= 2000) {
            SERIAL.println("out of range!!");
            digitalWrite(Buzzer, LOW);   // turn the Buzzer on (HIGH is the voltage level)
            digitalWrite(LED, LOW);   // turn the LED on (HIGH is the voltage level)
            
        } 
           else if (RangingMeasurementData.RangeMilliMeter <= 1000) {
            digitalWrite(Buzzer, HIGH);   // turn the Buzzer on (HIGH is the voltage level)
            digitalWrite(LED, HIGH);   // turn the LED on (HIGH is the voltage level)
            SERIAL.print("Distance:");
            SERIAL.print(RangingMeasurementData.RangeMilliMeter);
            SERIAL.println(" mm");
           } 
              else {    
                  digitalWrite(Buzzer, LOW);   // turn the Buzzer on (HIGH is the voltage level)
                  digitalWrite(LED, LOW);   // turn the LED on (HIGH is the voltage level)
                  SERIAL.print("Distance:");
                  SERIAL.print(RangingMeasurementData.RangeMilliMeter);
                  SERIAL.println(" mm");
              }

    }
    else {
        SERIAL.print("mesurement failed !! Status code =");
        SERIAL.println(Status);
        digitalWrite(Buzzer, LOW);   // turn the Buzzer on (HIGH is the voltage level)
        digitalWrite(LED, LOW);   // turn the LED on (HIGH is the voltage level)
        
    }

    delay(250);
    
    
}

Credits

Makerming Makerming

 

 

Hackster.io

This content is provided by our content partner Hackster.io, an Avnet developer community for learning, programming, and building hardware. Visit them online for more great content like this.

This article was originally published at Hackster.io. It was added to IoTplaybook or last modified on 04/27/2020.