Skip to content

Repository contains circuit diagram, PCB design, device case model and firmware for Smart Socket, a device which is hardware part of Grid Management System.

Notifications You must be signed in to change notification settings

wybieracz/GMS-Firmware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Grid Management System - Device and Firmware

IoT class system of electricity management based on a cloud interface

The project involves the design and development of a device that allows remote control the power supply of the connected receiver. Powering the receiver on and off should be possible on demand, after a certain period of time, during designated periods. In addition, the device will conduct measurements of voltage and current and count the energy used (Smart Socket). The second part of the project is creation of a web application to manage the device and present statistics. Communication with the device and data storage will be possible through a configured cloud service.

Technologies

  • C++
  • Azure IoT Hub
  • Azure Stream Analytics
  • ESP-32

Libraries

  • SPIFFS
  • LiquidCrystal
  • ESPAsyncWebServer
  • EmonLib
  • Azure IoT device SDK for C

Device features

  • Wi-Fi connection wizzard
  • 230V/10A power supply control
  • Manual mode, time mode, auto mode
  • Programmable display (Voltage and current, date, power, power consumption)
  • Power compsumption counter with auto-resetter
  • Sending telemetry to cloud

Circuit idea diagram

idea

Circuit diagram

circuit

PCB design

pcb pcb_preview

Device case design

case_top case_bottom

System architecture

architecture The solution consists of six major components:

  • IoT Device - smart device able to work in GMS.
  • Azure IoT Hub - a managed cloud service that acts as a central message hub for communication between an IoT application and its attached devices.
  • Azure Stream Analytics - cloud service that provides real-time analytic computations on the data streaming from IoT devices.
  • Azure Database for PostgreSQL - Database used to store devices telemetry and web app data.
  • Azure App Service - Web app used for device manipulation and telemetry presentation. (Backend)
  • Azure Storage Accounts - Web app used for device manipulation and telemetry presentation. (Frontend)

Getting started

  1. Create IoT device using circuit diagram / PCB design.
  2. Create account on Microsoft Azure.
  3. Create Azure IoT Hub.
  4. In Azure IoT Hub add new device via Devices > Add Device.
  5. Clone repository.
  6. Open AzIoTConfig.h file.
  • In Azure IoT Hub open Overview to show hostname.
  • Enter cloud hostname IOTHUB_FQDN.
  • In Azure IoT Hub open Devices > Your Device Name to show cloud device credentials.
  • Enter cloud device credentials, Device ID DEVICE_ID and Primary Key DEVICE_KEY.
  1. Build and upload programme to ESP-32.
  2. Create Postgres database.
  3. Run backend to create entities.
  4. Add manually data about devices into devices table.
  5. Create and configure Azure Stream Analytics.
  • Define Azure IoT Hub as an input in Inputs > Add input.
  • Define Postgres database as an output in Outputs > Add output.
  • Define query:
SELECT
    [deviceId],
    [voltage],
    [current],
    [power],
    [kWh],
    [timestamp]
INTO
    [database_name]
FROM
    [iot_hub_name]
  1. Connect power supply to device.
  2. Connect to the Wi-Fi network. Credentials will be displayed on device display.
  3. Go to 192.168.4.1 and pass credentials to your home Wi-Fi. The device will reboot and connect to the Wi-Fi.
  4. Your device is now online and can be linked with your account.
  5. For device manipulation check GMS - App.

Device

device_front device_top device_inside Device overview.

device_wifi After device startup it will show Wi-Fi credentials. When connected, it is possible to configure device netowrk settings and connect it to the home Wi-Fi.

device_connect After network configuration, device will reboot and connect to the home Wi-Fi.

device_display_1 device_display_2 It is possible to configure data presented on device display. 16x2 LCD allows to display two of data: Time and date, voltage and current, power, power comsumption. In addition it is powwible to change display brightness.

Video presentation

YouTube

About

Repository contains circuit diagram, PCB design, device case model and firmware for Smart Socket, a device which is hardware part of Grid Management System.

Topics

Resources

Stars

Watchers

Forks