Hackster is hosting Impact Spotlights highlighting smart energy storage. Start streaming on Thursday!Stream Impact Spotlights on Thursday!
Prasanna Vijay
Published © GPL3+

HomeEase: Smart Power Monitoring System

This project presents a smart power monitoring system aimed at mobility-impaired individuals, enabling real-time tracking of electricity.

IntermediateWork in progressOver 2 days119

Things used in this project

Hardware components

Blues Swan
Blues Swan
×1
Blues Notecarrier A
Blues Notecarrier A
×1
Blues Notecard (Cellular)
Blues Notecard (Cellular)
×1
INA219 Power Supply Monitoring Module
×1
4-CHANNEL RELAY CONTROLLER FOR I2C
ControlEverything.com 4-CHANNEL RELAY CONTROLLER FOR I2C
×1
Polymer Lithium Ion Battery - 2200mAh 3.7V
Seeed Studio Polymer Lithium Ion Battery - 2200mAh 3.7V
×1

Software apps and online services

Blues Notehub.io
Blues Notehub.io
Datacake
Datacake
SMS Messaging API
Twilio SMS Messaging API

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Jumper Wire, Bundle
Jumper Wire, Bundle
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Custom parts and enclosures

STL FILES OF 3D PRINTED BOX

3D Model for Top Portion

Sketchfab still processing.

STL FILES OF 3D PRINTED BOX

3D Model for Bottom Portion

Sketchfab still processing.

Schematics

Schematics of Project HomeEase

Code

BLUES SWAN V3 FIRMWARE

C/C++
Make sure you use platform io and downloaded the required libs.
#include <Arduino.h>
#include <Wire.h>
#include <INA219.h>
#include <Notecard.h>

#define usbSerial Serial
#define productUID "YOUR-UID" // ENTER YOURS FROM NOTEHUB
Notecard notecard;

#define CURRENT_THRESHOLD 800

unsigned long lastSendTime = 0;  // Last time data was sent to the cloud
const unsigned long sendInterval = 60000;  // 60 seconds

INA219 ina219; // Create an INA219 object

void setup() {
    delay(2500);
    usbSerial.begin(115200);
    notecard.begin();
    notecard.setDebugOutputStream(usbSerial);

    J *req = notecard.newRequest("hub.set");
    JAddStringToObject(req, "product", productUID);
    JAddStringToObject(req, "mode", "continuous");
    notecard.sendRequest(req);

    Wire.begin(); // Initialize I2C
    ina219.begin(); // Initialize INA219 sensor
}

void loop() {
    unsigned long currentTime = millis();

    // Read current from INA219 sensor
    float current_mA = ina219.getCurrent_mA();

    // Send CURRENT value to the cloud regularly every 60 seconds
    if (currentTime - lastSendTime >= sendInterval) {
        J *req = notecard.newRequest("note.add");
        if (req != NULL) {
            JAddStringToObject(req, "file", "sensors.qo");
            JAddBoolToObject(req, "sync", true);
            J *body = JAddObjectToObject(req, "body");
            if (body) {
                JAddNumberToObject(body, "current_mA", current_mA);
            }
            notecard.sendRequest(req);

            // Update the last send time
            lastSendTime = currentTime;
        }

        // Print CURRENT value to the serial monitor
        usbSerial.print("POWER (mA): ");
        usbSerial.println(current_mA);
    }

    // Check if the CURRENT value exceeds the threshold at any time
    if (current_mA > CURRENT_THRESHOLD) {
        // Send special JSON payload with "device" data
        J *specialReq = notecard.newRequest("note.add");
        if (specialReq != NULL) {
            JAddStringToObject(specialReq, "file", "sensors.qo");
            JAddBoolToObject(specialReq, "sync", true);
            
            J *specialBody = JAddObjectToObject(specialReq, "body");
            if (specialBody) {
                JAddNumberToObject(specialBody, "current_mA", current_mA);
                JAddStringToObject(specialBody, "Alert type", "Energy overload");
                JAddStringToObject(specialBody, "description", "Current threshold exceeded, data of a device sent.");
            }
            notecard.sendRequest(specialReq);

            // Print a message to indicate that the "current" data has been sent
            usbSerial.println("Current threshold exceeded. Device data sent.");
        }

        // Send a Twilio message when the Overload is detected
        J *twilioReq = notecard.newRequest("note.add");
        if (twilioReq != NULL) {
            JAddStringToObject(twilioReq, "file", "twilio.qo");
            JAddBoolToObject(twilioReq, "sync", true);
            
            J *twilioBody = JAddObjectToObject(twilioReq, "body");
            if (twilioBody) {
                JAddStringToObject(twilioBody, "customMessage", "Alert - Power Overload Occurred - Device name");
                JAddStringToObject(twilioBody, "customTo", "your number");
                JAddStringToObject(twilioBody, "customFrom", "your twilio number");
            }
            notecard.sendRequest(twilioReq);

            // Print a message to indicate that the Twilio message has been sent
            usbSerial.println("Twilio message sent: Overload detected.");
        }
    }

    delay(1000);  // Short delay to prevent overwhelming the serial output
}

Credits

Prasanna Vijay

Prasanna Vijay

2 projects • 1 follower

Comments