The application is an integral part of the subject "Designing systems with an Embedded computer - Embedded Systems" at the Master's studies of the Faculty of Electrical Engineering, University of East Sarajevo. The project also includes a mobile application eRegulation Mobile App and web application eRegulation Mobile Web.
This project implements an IoT device using the ESP8266 microcontroller to regulate temperature, humidity, and light conditions in a controlled environment. The device connects to a MQTT broker to receive commands and sends sensor data periodically. It uses the DHT11 sensor for temperature and humidity measurements and an LDR (Light Dependent Resistor) for light detection. The device can be controlled remotely through MQTT messages.
- ESP8266 microcontroller
- DHT11 sensor
- LDR (Light Dependent Resistor)
- 3 Relays for controlling heating, cooling, and light
- Power supply
- Resistors and wiring as per the circuit diagram
- ESP8266WiFi library
- PubSubClient library
- WiFiClientSecure library
- DHT library
- Replace
ssid
andpassword
with your Wi-Fi credentials. - Update
mqtt_server
,mqtt_username
, andmqtt_password
with MQTT broker details. - Adjust the pin definitions (
dhtPin
,ldrPin
,relayPinH
,relayPinC
,relayPinL
) based on your hardware connections. - Customize the
root_ca
certificate if a secure connection is required.
eregulation/arduino
: Commands and messages from the IoT device.eregulation/android
: Commands and messages to/from the Android application.eregulation/web
: Commands and messages to/from a web interface.
- Reconnect Function (
reconnect
): Handles MQTT reconnection logic. - MQTT Callback (
callback
): Processes incoming MQTT messages and performs corresponding actions. - Sensor Reading Function (
ReadDHTValues
): Reads temperature and humidity from the DHT11 sensor. - Light Check Function (
CheckLight
): Reads light intensity using the LDR. - Relay Control Function (
RelayControl
): Controls the relays based on heating, cooling, and light conditions. - Setup Function (
setup
): Initializes the hardware, connects to Wi-Fi, sets up MQTT, and initializes sensors. - Loop Function (
loop
): Main program loop where MQTT connection is maintained, sensor readings are taken, and control logic is executed.
t-on
: Enable temperature regulation.t-off
: Disable temperature regulation.h-on
: Enable humidity regulation.h-off
: Disable humidity regulation.t-nn-mm
: Set temperature range (nn: minimum, mm: maximum).h-nn-mm
: Set humidity range (nn: minimum, mm: maximum).l-on
: Turn on the light.l-off
: Turn off the light.l-auto
: Set light mode to auto.welcome
: Send device information to Android application.ping
: Send periodic status updates.
- Make sure to secure your MQTT connection using SSL certificates if required.
- Adjust the relay control logic and sensor thresholds based on your specific use case.
- Modify the relay control logic in the
RelayControl
function to suit your specific hardware configuration. - Adjust the temperature and humidity threshold values (
min_temp
,max_temp
,min_hum
,max_hum
) based on your environmental requirements. - Update the MQTT topics and commands according to your application's needs.
- Ensure the MQTT broker's security settings align with the device's credentials (
mqtt_username
andmqtt_password
). - If security is a concern, enable SSL/TLS by uncommenting the line
wifiClient.setCACert(root_ca);
and providing the appropriate root certificate.
This project is licensed under the MIT License. You can find more details in the LICENSE file.