In this project we’ll developed a Bluetooth-enabled security system using StackyFi. The system will detect motion and send alerts to your smartphone.
What's StackyFi?Meet StackyFi—a revolutionary microcontroller board designed to empower your projects with ease and flexibility. Housed in a compact Raspberry Pi Zero form factor, StackyFi packs a powerful ESP32-S3 WROOM 1 microcontroller, featuring a dual-core 32-bit LX7 processor running up to 240 MHz.
StackyFi stands out with its seamless support for Raspberry Pi HATs, allowing you to directly stack and integrate various HATs without needing a separate Raspberry Pi board. Equipped with built-in 2.4 GHz Wi-Fi, Bluetooth® 5 (LE), and an onboard accelerometer, StackyFi offers dynamic connectivity and sensor integration options for a wide range of IoT and automation applications.
Fully open-source and highly customizable, StackyFi is perfect for developers and hobbyists looking to create innovative and versatile projects with ease.
Components Needed:
- StackyFi board
- Motion sensor HAT
- Bluetooth-enabled alert system (e.g., buzzer or notification module)
- Power supply
- Smartphone with Bluetooth capability
Step-by-Step Guide
1. Setting Up the Hardware:
- Connect the Motion Sensor HAT to StackyFi.
- Connect the Bluetooth alert system to StackyFi.
2. Preparing the Software Environment:
- Install the Arduino IDE and libraries as needed.
3. Writing the Code:
#include <BluetoothSerial.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
BluetoothSerial SerialBT;
// Define sensor and alert pins
const int motionPin = 34; // GPIO pin for motion sensor
const int alertPin = 27; // GPIO pin for alert
void setup() {
Serial.begin(115200);
SerialBT.begin("StackyFi_Security"); // Initialize Bluetooth
pinMode(motionPin, INPUT);
pinMode(alertPin, OUTPUT);
// Initialize alert system
digitalWrite(alertPin, LOW);
}
void loop() {
int motionValue = digitalRead(motionPin);
if (motionValue == HIGH) {
SerialBT.println("Motion detected!");
digitalWrite(alertPin, HIGH); // Trigger alert
} else {
digitalWrite(alertPin, LOW); // Turn off alert
}
delay(1000); // Check every second
}
4. Uploading the Code:
- Follow the standard upload process.
5. Accessing and Testing:
- Use a Bluetooth-enabled device to connect to StackyFi.
- Monitor for motion detection alerts on your smartphone.
Overview: Create a smart attendance system that uses StackyFi to log attendance via RFID or barcode scanning.
Components Needed:
- StackyFi board
- RFID or barcode scanner HAT
- Database or cloud service for storing records
- Wi-Fi connection
Step-by-Step Guide
1. Setting Up the Hardware:
- Connect the RFID or barcode scanner HAT to StackyFi.
2. Preparing the Software Environment:
- Install Arduino IDE and libraries for RFID or barcode scanner.
3. Writing the Code:
#include <WiFi.h>
#include <HTTPClient.h>
#include <MFRC522.h> // For RFID
// Replace with your network credentials
const char* ssid = "Your_SSID";
const char* password = "Your_PASSWORD";
// Define RFID pins
#define RST_PIN 22
#define SS_PIN 21
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("Connected to Wi-Fi");
SPI.begin(); // Init SPI bus
mfrc522.PCD_Init(); // Init MFRC522
Serial.println("Scan an RFID tag");
}
void loop() {
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
String tagID = "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
tagID += String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : "");
tagID += String(mfrc522.uid.uidByte[i], HEX);
}
tagID.toUpperCase();
Serial.print("Tag ID: ");
Serial.println(tagID);
HTTPClient http;
http.begin("http://your-server-url/record_attendance?tag=" + tagID);
int httpResponseCode = http.GET();
if (httpResponseCode > 0) {
String response = http.getString();
Serial.println(response);
} else {
Serial.println("Error in HTTP request");
}
http.end();
delay(5000); // Check every 5 seconds
}
4. Uploading the Code:
- Follow the upload procedure.
5. Accessing and Testing:
- Use the RFID or barcode scanner to test attendance logging.
- Verify data is recorded in the database or cloud service.
Comments
Please log in or sign up to comment.