Urban Edge Smart Campus

Smart Campus solution to Monitor Crowd Movement and Energy

IntermediateFull instructions providedOver 2 days49
Urban Edge Smart Campus

Things used in this project

Hardware components

Gravity: Analog CH4 Gas Sensor (MQ4) For Arduino
DFRobot Gravity: Analog CH4 Gas Sensor (MQ4) For Arduino
×1
FireBeetle ESP32 IOT Microcontroller (Supports Wi-Fi & Bluetooth)
DFRobot FireBeetle ESP32 IOT Microcontroller (Supports Wi-Fi & Bluetooth)
×1
Gravity: Digital 10A Relay Module
DFRobot Gravity: Digital 10A Relay Module
×1
Gravity: DHT11 Temperature Humidity Sensor For Arduino
DFRobot Gravity: DHT11 Temperature Humidity Sensor For Arduino
×1
Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1
Camera Module V2
Raspberry Pi Camera Module V2
×1
Seeed XIAO BLE nRF52840 Sense
Seeed Studio Seeed XIAO BLE nRF52840 Sense
×2
MR24BSD1 24GHz mmWave Module - Respiratory Sleep Detection | Doppler radar | Sync Sense | Privacy Protect
Seeed Studio MR24BSD1 24GHz mmWave Module - Respiratory Sleep Detection | Doppler radar | Sync Sense | Privacy Protect
×1
60GHz mmWave Sensor - Breathing and Heartbeat Module
Seeed Studio 60GHz mmWave Sensor - Breathing and Heartbeat Module
×1
ZMPT101B - Voltage Sensor
×1
SCT 013 - Current Sensor
×1
NXP Hovergames drone kit
×1
QNX Decawave UWB
×1

Software apps and online services

OpenCV
OpenCV
AWS IoT
Amazon Web Services AWS IoT

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Schematics

Powermonitoring schematic

Power monitoring

MMwave schematic

Fall and human presence MMwave schematic

Code

PowerCode

C/C++
#include<WiFi.h>; 
#include<DHT.h>; 
#include<AWS_IOT.h>; 
#include "EmonLib.h"

#define WIFI_SSID "ReneraiPhone" // SSID of your WIFI 
#define WIFI_PASSWD "renera97" //your wifi password 
#define CLIENT_ID "ESP32_Client"// thing unique ID, this id should be unique among all things associated with your AWS account. 
#define MQTT_TOPIC "$aws/things/ESP32/shadow/name/ESP32" //topic for the MQTT data 
#define AWS_HOST "akx1mya7kuo6k-ats.iot.ap-southeast-1.amazonaws.com" // your host for uploading data to AWS

unsigned long lastTime = 0;
unsigned long timerDelay = 3000;
unsigned long lastmillis = millis();

EnergyMonitor emon;
#define vCalibration 115.9
#define currCalibration 11.3
float kWh = 0;

AWS_IOT aws;
void setup(){
  Serial.begin(9600);
  emon.voltage(35, vCalibration, 1.7); // Voltage: input pin, calibration, phase_shift
  emon.current(34, currCalibration); // Current: input pin, calibration.
  Serial.print("\nInitializing thing ESP32\n");
  Serial.print("\n  Initializing WIFI: Connecting to ");
  Serial.println(WIFI_SSID);
  WiFi.begin(WIFI_SSID, WIFI_PASSWD);
  Serial.print("  ");
  while(WiFi.status() != WL_CONNECTED){
    Serial.print(".");
    delay(500);
  }
  Serial.println("\n  Connected.\n  Done");
  Serial.print("\n  Initializing Power Monitoring...");
  Serial.println("  Done.");
  Serial.println("\n  Initializing connetction to AWS....");
  if(aws.connect(AWS_HOST, CLIENT_ID) == 0){ // connects to host and returns 0 upon success
    Serial.println("  Connected to AWS\n  Done.");
  }
  else {
    Serial.println("  Connection failed!\n make sure your subscription to MQTT in the test page");
  }
  Serial.println("  Done.\n\nDone.\n");
}
void loop(){
//power calculations
    emon.calcVI(20, 2000); // Calculate all. No.of half wavelengths (crossings), time-out. This is FIXED 
    float voltage = emon.Vrms;
    float current = emon.Irms;
    float power = emon.apparentPower;
    kWh = kWh + emon.apparentPower*(millis()-lastmillis)/3600000000.0; //(1 hour = 3.6x10^9 microseconds)

  
  if(voltage == NAN || current == NAN){ // NAN means no available data
    Serial.println("Reading failed.");
  }
  else{
    //create string payload for publishing
    String voltage_current = "Vrms: ";
    voltage_current += String(voltage);
    voltage_current += "V Irms: ";
    voltage_current += String(current);
    voltage_current += "A Power: ";
    voltage_current += String(power);
    voltage_current += " W";   
   
    char payload[40];
    voltage_current.toCharArray(payload, 40);
    Serial.println("Publishing:- ");
    Serial.println(payload);
     if(aws.publish(MQTT_TOPIC, payload) == 0){// publishes payload and returns 0 upon success
      Serial.println("Success\n");
    }
    else{
      Serial.println("Failed!\n");
    }
  }
delay(1000);
}

Credits

NARENDRAN

NARENDRAN

12 projects • 9 followers
Sharen Perera

Sharen Perera

0 projects • 1 follower
Yazan Mansour Aldali

Yazan Mansour Aldali

0 projects • 0 followers
Rohit Thomas

Rohit Thomas

1 project • 0 followers
Kannan Uthaya Kumar

Kannan Uthaya Kumar

0 projects • 0 followers
Ravivarma Sivathasan

Ravivarma Sivathasan

0 projects • 1 follower
Sarim Ahmed Khalil

Sarim Ahmed Khalil

0 projects • 1 follower

Comments

Add projectSign up / Login