Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
zyqzyq
Published

Monitor your pet with XIAO BLE+mmWave sensor

Use XIAO BLE and mmWave radar to catch when my pets show up in balcony and record when they potty so I can clean it correctly.

BeginnerWork in progress11 hours568
Monitor your pet with XIAO BLE+mmWave sensor

Things used in this project

Hardware components

Seeed XIAO BLE nRF52840 Sense
Seeed Studio Seeed XIAO BLE nRF52840 Sense
×1
Seeed Studio MR24BSD1 24GHz mmWave Sensor
×1
Male-Male Jumper Wire
×1
XIAO BLE battery
×1

Software apps and online services

LightBlue App (Apple)
Arduino IDE
Arduino IDE

Story

Read more

Schematics

XIAO BLE and mmWave sensor

Code

Code

Arduino
//Human_State_Data_Decoding_Example.ino
#include <ArduinoBLE.h>
#include <sleepbreathingradar.h>

int old_val;

BLEService radarService("19B10000-E8F2-537E-4F6C-D104768A1214");
BLEStringCharacteristic switchCharacteristic("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLENotify, 20);
 
SleepBreathingRadar radar;
 
void setup()
{
  radar.SerialInit();
  Serial.begin(9600);
  delay(1500);
  if (!BLE.begin()) {
    Serial.println("starting Seeed Studio XIAO nRF52840 with 60GHz radar sensor demo failed!");
    while (1);
  }
  
  BLE.setLocalName("Seeed Studio XIAO nRF52840");
  BLE.setAdvertisedService(radarService);
  radarService.addCharacteristic(switchCharacteristic);
  BLE.addService(radarService);
 
  // start advertising
  BLE.advertise();
 
  Serial.println("Seeed Studio XIAO nRF52840 active, waiting for connections...");
}
 
void loop()
{
 BLEDevice central = BLE.central();

 if (central) {
    Serial.print("Connected to central: ");
    // print the central's MAC address:
    Serial.println(central.address());

    while (central.connected()){

     radar.recvRadarBytes();                       //Receive radar data and start processing
     
     if (radar.newData == true) {                  //The data is received and transferred to the new list dataMsg[]
        byte dataMsg[radar.dataLen+1] = {0x00};
        dataMsg[0] = 0x55;                         //Add the header frame as the first element of the array
        for (byte n = 0; n < radar.dataLen; n++)dataMsg[n+1] = radar.Msg[n];  //Frame-by-frame transfer
        radar.newData = false;                     //A complete set of data frames is saved
        radar.Situation_judgment(dataMsg);         //Use radar built-in algorithm to output human motion status

        if(radar.sign = 1 && old_val != radar.sign){
          switchCharacteristic.setValue("somedog");
          Serial.println(old_val);
          old_val = radar.sign;
        }
     }
//      if(radar.sign = 1 && old_val != new_val){
      
    }
 }
}

Credits

zyqzyq

zyqzyq

1 project • 0 followers

Comments