diff --git a/Smart Home/Smart Plant Watering/3D Models/Smashing Jaagub.stl b/Smart Home/Smart Plant Watering/3D Models/Smashing Jaagub.stl new file mode 100644 index 0000000..a5680d4 Binary files /dev/null and b/Smart Home/Smart Plant Watering/3D Models/Smashing Jaagub.stl differ diff --git a/Smart Home/Smart Plant Watering/Circuit.png b/Smart Home/Smart Plant Watering/Circuit.png new file mode 100644 index 0000000..c2b4e28 Binary files /dev/null and b/Smart Home/Smart Plant Watering/Circuit.png differ diff --git a/Smart Home/Smart Plant Watering/Smart_Plant_Watering/Smart_Plant_Watering.ino b/Smart Home/Smart Plant Watering/Smart_Plant_Watering/Smart_Plant_Watering.ino new file mode 100644 index 0000000..8d8696a --- /dev/null +++ b/Smart Home/Smart Plant Watering/Smart_Plant_Watering/Smart_Plant_Watering.ino @@ -0,0 +1,110 @@ +#include +#include +#include +#include +#include + +#include + +//Static IP address configuration +IPAddress staticIP(192, 168, 1, 170); +IPAddress gateway(192, 168, 1, 1); +IPAddress subnet(255, 255, 255, 0); +IPAddress dns(192, 168, 1, 1); +IPAddress dns2(8, 8, 8, 8); + +const char *deviceName = "MakeItSmart_Plant_Watering"; + const char *ssid = "**********Your_SSID************"; + const char *password = "********Your Password**********"; + +ESP8266WebServer httpServer(80); +ESP8266HTTPUpdateServer httpUpdater; + +#define mosfet 12 +#define relay 14 + +const int analogInPin = A0; + +Ticker timer; +bool state = false; +int humidity = 0; + +Ticker relay_timer; + +void setup() { + Serial.begin(115200); + + pinMode(relay, OUTPUT); + pinMode(mosfet, OUTPUT); + + //analogWriteRange(1024); + + timer.attach_ms(1000, readSensorValue); + + connectToWifi(); +} + +void loop() { + analogWrite(mosfet, state ? 130 : 0); + digitalWrite(relay, state ? HIGH : LOW); + + httpServer.handleClient(); +} + +//--------------------Operational functions----------------------------------------- +void connectToWifi() { + WiFi.hostname(deviceName); + WiFi.config(staticIP, gateway, subnet, dns, dns2); + + WiFi.mode(WIFI_STA); + WiFi.begin(ssid, password); + + int counter = 0; + while (WiFi.status() != WL_CONNECTED && counter < 20) { + delay(500); + } + + if (WiFi.status() != WL_CONNECTED) ESP.restart(); + + httpUpdater.setup(&httpServer); + httpServer.on("/get_device_type", get_device_type); + httpServer.on("/get_humidity", get_humidity); + httpServer.on("/get_state", get_state); + httpServer.on("/waterize", waterize); + + httpServer.begin(); +} + +void readSensorValue() { + humidity = (int)((1024 - analogRead(analogInPin)) / 10.24); +} + +void stopWaterizing() { + if (relay_timer.active()) relay_timer.detach(); + state = false; +} + +//--------------------Http functions----------------------------------------- +void get_device_type() { + httpServer.send(200, "text/plain", "Plant Watering"); +} + +void get_humidity() { + httpServer.send(200, "text/plain", String(humidity)); +} + +void get_state() { + httpServer.send(200, "text/plain", String(state)); +} + +void waterize() { + state = httpServer.arg("value").toInt() == 1; + if (state) { + int duration = httpServer.arg("duration").toInt(); + if (!relay_timer.active()) relay_timer.attach_ms(duration > 0 ? duration : 3000, stopWaterizing); + } else { + if (relay_timer.active()) relay_timer.detach(); + } + + httpServer.send(200, "text/plain", "Ok"); +} diff --git a/Smart Home/Smart Plant Watering/Youtube Video.txt b/Smart Home/Smart Plant Watering/Youtube Video.txt new file mode 100644 index 0000000..b553105 --- /dev/null +++ b/Smart Home/Smart Plant Watering/Youtube Video.txt @@ -0,0 +1 @@ +https://youtu.be/yxsz6cjm-5I \ No newline at end of file diff --git a/Smart Home/Smart Roller Blind/Smart_Roller_Bilind_V2/Smart_Roller_Bilind_V2.ino b/Smart Home/Smart Roller Blind/Smart_Roller_Bilind_V2/Smart_Roller_Bilind_V2.ino index f1ec313..442dbf5 100644 --- a/Smart Home/Smart Roller Blind/Smart_Roller_Bilind_V2/Smart_Roller_Bilind_V2.ino +++ b/Smart Home/Smart Roller Blind/Smart_Roller_Bilind_V2/Smart_Roller_Bilind_V2.ino @@ -17,8 +17,8 @@ IPAddress dns(192, 168, 1, 1); IPAddress dns2(8, 8, 8, 8); const char *deviceName = "MakeItSmart_Roller_Blind"; -const char *ssid = "Your SSID"; -const char *password = "Your Password"; + const char *ssid = "**********Your_SSID************"; + const char *password = "********Your Password**********"; ESP8266WebServer httpServer(80); ESP8266HTTPUpdateServer httpUpdater; diff --git a/Smart Home/Smart Switch/Smart_Switch/Smart_Switch.ino b/Smart Home/Smart Switch/Smart_Switch/Smart_Switch.ino new file mode 100644 index 0000000..286e907 --- /dev/null +++ b/Smart Home/Smart Switch/Smart_Switch/Smart_Switch.ino @@ -0,0 +1,99 @@ +#include +#include +#include +#include +#include +#include + +#define LED D5 + +ESP8266WebServer httpServer(80); +ESP8266HTTPUpdateServer httpUpdater; + +bool state = false; +int counter = 0; + +unsigned long lastSensorRead = 0; +unsigned long sensorReadDelay = 1000; + + + +void setup() { + Serial.begin(115200); + + analogWriteRange(255); + + pinMode(LED, OUTPUT); + + bool success = SPIFFS.begin(); + if (!success) Serial.println("Error mounting the file system"); + + connectToWifi(); +} + +void loop() { + if ((millis() - lastSensorRead) > sensorReadDelay) { + + } + + digitalWrite(LED, state ? HIGH : LOW); + + httpServer.handleClient(); +} + + +void connectToWifi() { + Serial.print("Connecting"); + + IPAddress staticIP(192, 168, 1, 150); + IPAddress gateway(192, 168, 1, 1); + IPAddress subnet(255, 255, 255, 0); + IPAddress dns(192, 168, 1, 1); + IPAddress dns2(8, 8, 8, 8); + + const char* deviceName = "MakeItSmart_Smart_Thermometer"; + const char *ssid = "**********Your_SSID************"; + const char *password = "********Your Password**********"; + + WiFi.hostname(deviceName); + WiFi.config(staticIP, gateway, subnet, dns, dns2); + + WiFi.mode(WIFI_AP_STA); + WiFi.begin(ssid, password); + + int counter = 0; + while (WiFi.status() != WL_CONNECTED && counter++ < 20) { + delay(500); + Serial.print("."); + } + if (WiFi.status() != WL_CONNECTED) ESP.restart(); + + Serial.print("IP:"); + Serial.println(WiFi.localIP()); + + httpUpdater.setup(&httpServer); + httpServer.on("/get_state", get_state); + httpServer.on("/toggle", toggle); + httpServer.on("/get_device_type", get_device_type); + httpServer.begin(); + + Serial.print("IP:"); + Serial.println(WiFi.localIP()); + + delay(3000); +} + +//---------------------------------Http Functions--------------------------------------------------------------- + +void get_state() { + httpServer.send(200, "text/plain", /*"hum : " +*/ String(state)); +} + +void toggle() { + state = !state; + httpServer.send(200, "text/plain", /*"temp : " +*/ String(state)); +} + +void get_device_type() { + httpServer.send(200, "text/plain", "Switch"); +} diff --git a/Smart Home/Smart Temperature/Smart_Temperature/Smart_Temperature.ino b/Smart Home/Smart Temperature/Smart_Temperature/Smart_Temperature.ino new file mode 100644 index 0000000..08d8bb3 --- /dev/null +++ b/Smart Home/Smart Temperature/Smart_Temperature/Smart_Temperature.ino @@ -0,0 +1,117 @@ +#include +#include +#include +#include +#include +#include + +#include "DHT.h" + +#define DHTTYPE DHT11 +#define DHTpin 14 + +ESP8266WebServer httpServer(80); +ESP8266HTTPUpdateServer httpUpdater; + +DHT dht(DHTpin, DHTTYPE); + +int counter = 0; + +float humidity = 0; +float temperature = 0; + +unsigned long lastSensorRead = 0; +unsigned long sensorReadDelay = 1000; + +void setup() { + Serial.begin(115200); + + analogWriteRange(255); + + dht.begin(); + + bool success = SPIFFS.begin(); + if (!success) Serial.println("Error mounting the file system"); + + connectToWifi(); +} + +void loop() { + if ((millis() - lastSensorRead) > sensorReadDelay) { + lastSensorRead = millis(); + + float tmp = dht.readTemperature(); + if (tmp != temperature) updateTemperature(tmp); + + float hmd = dht.readHumidity(); + if (hmd != humidity) updateHumidity(hmd); + } + + httpServer.handleClient(); +} + + +void connectToWifi() { + Serial.print("Connecting"); + + IPAddress staticIP(192, 168, 1, 160); + IPAddress gateway(192, 168, 1, 1); + IPAddress subnet(255, 255, 255, 0); + IPAddress dns(192, 168, 1, 1); + IPAddress dns2(8, 8, 8, 8); + + const char* deviceName = "MakeItSmart_Smart_Thermometer"; + const char *ssid = "**********Your_SSID************"; + const char *password = "********Your Password**********"; + + WiFi.hostname(deviceName); + WiFi.config(staticIP, gateway, subnet, dns, dns2); + + WiFi.mode(WIFI_AP_STA); + WiFi.begin(ssid, password); + + int counter = 0; + while (WiFi.status() != WL_CONNECTED && counter++ < 20) { + delay(500); + Serial.print("."); + } + if (WiFi.status() != WL_CONNECTED) ESP.restart(); + + Serial.print("IP:"); + Serial.println(WiFi.localIP()); + + httpUpdater.setup(&httpServer); + httpServer.on("/getHumidity", getHumidity); + httpServer.on("/getTemperature", getTemperature); + httpServer.on("/get_device_type", get_device_type); + httpServer.begin(); + + Serial.print("IP:"); + Serial.println(WiFi.localIP()); + + delay(3000); +} + +void updateTemperature(float value) { + temperature = value ; + //temperature = random(-20, 80); //value ; +} + +void updateHumidity(float value) { + humidity = value; + //humidity = random(0, 100); //value; +} + +//---------------------------------Http Functions--------------------------------------------------------------- + +void getHumidity(){ + httpServer.send(200, "text/plain", /*"hum : " +*/ String(humidity)); +} + +void getTemperature(){ + httpServer.send(200, "text/plain", /*"temp : " +*/ String(temperature)); +} + +void get_device_type(){ + httpServer.send(200, "text/plain", "Thermometer"); +}