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.
- C++
- Azure IoT Hub
- Azure Stream Analytics
- ESP-32
- SPIFFS
- LiquidCrystal
- ESPAsyncWebServer
- EmonLib
- Azure IoT device SDK for C
- 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
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)
- Create IoT device using circuit diagram / PCB design.
- Create account on Microsoft Azure.
- Create Azure IoT Hub.
- In Azure IoT Hub add new device via
Devices > Add Device
. - Clone repository.
- 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 KeyDEVICE_KEY
.
- Build and upload programme to ESP-32.
- Create Postgres database.
- Run backend to create entities.
- Add manually data about devices into devices table.
- 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]
- Connect power supply to device.
- Connect to the Wi-Fi network. Credentials will be displayed on device display.
- Go to
192.168.4.1
and pass credentials to your home Wi-Fi. The device will reboot and connect to the Wi-Fi. - Your device is now online and can be linked with your account.
- For device manipulation check GMS - App.
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.
After network configuration, device will reboot and connect to the home Wi-Fi.
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.