This is an old revision of the document!
Author: Claudiu-Catalin Pumnea - SRIC
The “Smart room monitoring and control system” is an innovative project that focuses on collecting environment parameters and leveraging them to control the lights and outlets of a kitchen. The system utilizes a range of sensors including a water level detection sensor, a temperature and humidity sensor, and a gas sensor. Additionally, a control module equipped with two relays is employed for managing the lights and outlets.
To provide users with real-time data and control functionality, a web application has been developed. The web app features intuitive graphs displaying the humidity and temperature readings, allowing users to visualize the environmental conditions in the kitchen. Furthermore, the app provides the capability to control the status of the relays, enabling users to remotely manage the lights and outlets for enhanced convenience and energy efficiency.
To develop this project, the following components were utilized:
Technologies used in the project:
These technologies form the foundation of the project, combining front-end (HTML, CSS, JavaScript), back-end (Node.js, Nest.js), and database (PostgreSQL) components to create a comprehensive web application with enhanced functionality and a reliable data storage system.
#include <DHT.h> #include <string.h> #include <HTTPClient.h> #include <WiFi.h> #include <ArduinoJson.h>
#define LIGHT_RELAY_PIN 18 #define CURRENT_OUTLET_RELAY_PIN 4 //Water level sensor #define WATER_LEVEL_SENSOR_PIN 34 //Gas sensor #define GAS_SENSOR_MQ2_PIN 35 //Temperature sensor #define DHTPIN 19 #define DHTTYPE DHT11 DHT dht(DHTPIN, DHTTYPE); //Initialize dht //Room and apartment constants const char* roomType = "Kitchen"; const int apartmentNumber = 49; //Initialize Docs DynamicJsonDocument getInitializeDoc(2048); DynamicJsonDocument getRelayStatusDoc(2048); ////Wifi credentials const char* ssid = "yourWifiNameHere"; const char* password = "yourWifiPasswordHere"; //Initialize wifiClient and httpClient WiFiClient client; HTTPClient http; //Flags if relays exists bool currentOutletRelayExists = true; bool lightRelayExists = true; //Counter for sending the post message int counter = 0; //Declare gas_value and wate_level_value float gas_value ; float water_Level_value ;
void setup() { Serial.begin(9600); setupWiFi(); initializePins(); initialize_board(); }
void setupWiFi() { WiFi.begin(ssid, password); Serial.print("\n Connecting to Wifi"); pinMode(2, OUTPUT); while ( WiFi.status() != WL_CONNECTED) { Serial.print("."); digitalWrite(2, HIGH); delay(250); digitalWrite(2, LOW); delay(250); } digitalWrite(2, HIGH); Serial.println("\n Connected to the WiFi network"); Serial.print("\n IP address: "); Serial.print(WiFi.localIP()); }
void initializePins() { pinMode(LIGHT_RELAY_PIN, OUTPUT); pinMode(CURRENT_OUTLET_RELAY_PIN, OUTPUT); pinMode(GAS_SENSOR_MQ2_PIN, INPUT); pinMode(LIGHT_CURRENT_SENSOR_PIN, INPUT); pinMode(OUTLET_CURRENT_SENSOR_PIN, INPUT); //Setting the initial state of the relays digitalWrite(LIGHT_RELAY_PIN, HIGH); digitalWrite(CURRENT_OUTLET_RELAY_PIN, HIGH); dht.begin(); }