detection_chute.ino
In free fall the acceleration vector norm collapses below 0.3 g: this sketch watches it at 200 Hz and lights the red LED three seconds after the event. The dropped-parcel, torn-off-sensor or fall-of-person detector.
Hardware
An Arduino Nicla Sense ME (nRF52832, BLE only) with Bosch BHI260AP hub, BMM150, BMP390, BME688 sensors, RGB LED on an I2C driver and LiPo charger. The board alone. Test: drop it 30 cm onto a cushion — the norm dips below 0.3 g during the fall.
Wiring
No wiring. Mount the board firmly if the goal is detecting an object falling, not its own.
How it works
The 5 ms loop samples fast enough for sub-second falls; the 0.3 g threshold avoids false positives in normal motion. The RGB LED (IS31FL3194) gives the visual signal.
Running it
Programmed from the Arduino IDE (ArduinoCore-mbed); Arduino_BHY2 and Nicla_System libraries; USB through a serial bridge.
Variants
Notify the fall over BLE to a watch, cross with pressure (detect impact), or log shock timestamps to memory for a shipping report.
detection_chute.ino
// Détection de chute : la norme d'accélération tombe sous 0,3 g
// en chute libre. Usage : colis fragile, capteur tombé au sol,
// alerte homme-couché. La LED RVB passe au rouge sur événement.
#include "Arduino_BHY2.h"
#include "Nicla_System.h"
SensorAccel accel(0);
unsigned long derniereChute = 0;
void setup() {
Serial.begin(115200);
nicla::begin();
nicla::leds.begin();
BHY2.begin();
accel.begin();
BHY2.update();
}
void loop() {
BHY2.update();
if (accel.checkNewData()) {
float n = sqrtf(accel.x() * accel.x() +
accel.y() * accel.y() +
accel.z() * accel.z());
if (n < 0.3) { // quasi-impesanteur = chute
derniereChute = millis();
Serial.print("CHUTE detectee (norme=");
Serial.print(n);
Serial.println(" g)");
}
}
// Signal visuel 3 s après l'événement
if (millis() - derniereChute < 3000) {
nicla::leds.setColor(red);
} else {
nicla::leds.setColor(green);
}
delay(5); // boucle rapide : la chute dure < 1 s
}