├── Air-Quality-Monitoring-System └── air-quality-monitoring-system.ino ├── Air-Quality-Monitoring-Using-Blynk-ThingSpeak-ESP8266 └── air-quality-monitoring-using-blynk-thingspeak-esp8266.ino ├── Air-Quality-Monitoring-Using-Google-Spreadsheet-and-ESP8266 ├── DebugMacros.h ├── GoogleScript.gs ├── HTTPSRedirect.cpp ├── HTTPSRedirect.h └── air-quality-monitoring-using-google-spreadsheet-and-esp8266.ino ├── Control-DC-Fan-Using-ESP8266-and-Blynk-IOT └── control-dc-fan-using-esp8266-blynk-iot.ino ├── Control-DC-Motor-Using-Blynk-and-ESP8266 └── control-dc-motor-using-blynk-and-esp8266.ino ├── Control-Electric-Bulb-From-Mobile └── control-electric-bulb-from-mobile.ino ├── Control-LED-Using-Blynk-IOT └── control-led-using-blynk-iot.ino ├── Control-LED-Using-Google-Assistant-and-Blynk └── control-led-using-google-assistant-and-blynk.ino ├── Control-LED-Using-Google-Assistant └── control-LED-using-google-assistant.ino ├── Control-LED-Using-WhatsApp └── control-led-using-whatsapp.ino ├── Control-LEDs-with-Localhost-MySQL-and-Xampp-Server ├── control-leds-with-localhost-mysql-and-xampp-server.ino ├── getLedStatus.php ├── index.php └── query.sql ├── Control-Servo-Motor-Using-ESP8266-and-Blynk-IOT └── control-servo-motor-using-esp8266-and-blynk-iot.ino ├── Control-Servo-Motor-Using-WhatsApp-and-ESP8266 └── control-servo-motor-using-whatsapp-and-esp8266.ino ├── Covid-Tracker-Using-ESP-8266 ├── circuit-diagram-covid-tracker.png └── covid-tracker-using-esp-8266.ino ├── ESP-8266-Temperature-Web-Server └── esp-8266-temperature-web-server.ino ├── ESP8266-Telegram-Home-Automation └── esp8266-telegram-home-automation.ino ├── ESP8266-Weather-Station-Web-Server └── esp8266-weather-station-web-server.ino ├── ESP8266-with-Telegram-Messenger-for-Monitoring-Temperature-and-Humidity-using-DHT11 └── ESP8266-with-telegram-messenger-for-monitoring-temperature-and-humidity-using-DHT11.ino ├── Gas-Leakage-Alert-Notification-Using-Blynk-IOT └── gas-leakage-alert-using-blynk-iot.ino ├── Gas-Level-Monitoring-and-Alert-Using-ESP8266-and-Blynk-IOT └── gas-level-monitoring-and-alert-using-esp8266-and-blynk-iot.ino ├── Google-Assistant-Home-Automation └── google-assistant-home-automation.ino ├── Home-Automation-Using-Arduino-IOT-Cloud-ESP-8266 ├── arduino_secrets.h ├── home-automation-using-arduino-iot-cloud-esp-8266.ino ├── sketch.json └── thingProperties.h ├── Home-Automation-Using-Blynk-iot └── home-automation-using-blynk-iot.ino ├── Home-Automation-Using-ESP8266-and-Blynk-IoT └── home-automation-using-esp8266-and-blynk-iot.ino ├── Home-Automation-Web-Server-with-ESP8266 └── home-automation-web-server-with-esp8266.ino ├── Home-Automation-with-WhatsApp-and-ESP8266 └── home-automation-with-whatsapp-and-esp8266.ino ├── How-to-Store-Temperature-Pressure-Altitude-in-Google-Spreadsheet ├── GoogleScript.gs └── how-to-store-temperature-pressure-altitude-in-google-spreadsheet.ino ├── IoT-Agriculture-Monitoring-System └── iot-agriculture-monitoring-system.ino ├── IoT-Based-Agricultural-System └── iot-based-agricultural-system.ino ├── Noise-Pollution-Monitoring-with-ESP8266-and-Blynk-IoT └── noise-pollution-monitoring-with-esp8266-and-blynk-iot.ino ├── Patient-Health-Monitoring-System-with-ESP8266-and-Blynk-IoT └── patient-health-monitoring-system-with-esp8266-and-blynk-iot.ino ├── Patient-Health-Monitoring-System-with-MAX30100-DHT11 └── patient-health-monitoring-system.ino ├── Pulse-Oximeter-with-ESP8266-and-Blynk-IoT └── pulse-oximeter-with-esp8266-and-blynk-iot.ino ├── Rain-Alarm-Notification └── rain-alarm-notification.ino ├── Rain-Monitoring-System └── rain-monitoring-system.ino ├── Read-Data-From-Google-Spreadsheet-and-Display-in-OLED ├── GoogleScript.js └── read-data-from-google-spreadsheet-and-display-in-OLED-Display.ino ├── Read-Data-from-Google-SpreadSheet-and-display-in-LCD-Display ├── GoogleScript.js └── read-data-from-google-spreadsheet-and-display-in-LCD-Display.ino ├── Real-Time-Temperature-Monitoring-with-NTC-Thermistor-ESP8266-and-Blynk-IoT └── real-time-temperature-monitoring-with-ntc-thermistor-esp8266-and-blynk-iot.ino ├── Smart-Attendance-Tracking-System-with-RFID-Module-and-ESP8266 ├── Script.js ├── card-holder-name.ino └── smart-attendance-tracking-system-with-rfid-module-and-esp8266.ino ├── Smart-Door-Notification-Using-ESP8266-and-Blynk-IOT └── smart-door-notification-using-esp8266-and-blynk-iot.ino ├── Smart-Environment-Monitoring-System └── smart-environment-monitoring-system.ino ├── Smart-Environment-Monitoring-with-ESP8266-Capacitive-Soil-Sensor-DHT11-Arduino-IoT-Cloud ├── Environment_Monitoring_System_jan14a(1).zip └── smart-environment-monitoring-with-esp8266-capacitive-soil-sensor-dht11-arduino-iot-cloud.ino ├── Smart-Exhaust-Fan-Control-using-MQ2-Sensor-and-ESP8266 └── smart-exhaust-fan-control-using-mq2-sensor-and-esp8266.ino ├── Smart-Irrigation-System-with-ESP8266-and-Blynk-IoT └── smart-irrigation-system-with-esp8266-and-blynk-iot.ino ├── Smart-Irrigation-Using-Blynk-IOT └── smart-irrigation-using-blynk-2.ino ├── Smart-LED-Tube-Light-Using-ESP8266-and-Blynk-IOT └── smart-led-tube-light-using-esp8266-and-blynk-iot.ino ├── Smart-Light-Monitoring-Using-ESP8266-and-Blynk-IoT └── smart-light-monitoring-using-esp8266-and-blynk-iot.ino ├── Smart-Notice-Board ├── circuit-diagram-smart-notice-board.png └── smart-notice-board.ino ├── Smart-Waste-Management-Using-ESP8266 └── smart-waste-management.ino ├── Smart-Waste-Management-with-ESP8266-and-Blynk-IoT └── smart-waste-management-with-esp8266-and-blynk-iot.ino ├── Soil-Moisture-Monitoring-System-Using-ThingSpeak-and-ESP8266 └── soil-moisture-monitoring-system-using-thingspeak-and-esp8266.ino ├── Soil-Moisture-Temperature-Humidity-Monitor-Using-ESP8266-and-Blynk-IOT └── soil-moisture-temperature--humidity-monitor-using-esp8266-and-blynk-iot.ino ├── Store-Temp-Values-in-Database-and-display-values-in-Website ├── config.php ├── database.sql ├── esp8266-dht11-mysql.ino ├── getdata.php ├── index.php └── sensordata.php ├── Store-Temperature-Pressure-Altitude-in-Google-SpreadSheet └── store-temperature-pressure-altitude-in-google-spreadsheet.ino ├── Temperature-Alert-Notification-Using-Blynk-IOT └── temperature-alert-notification-using-blynk-iot.ino ├── Temperature-Controlled-Fan-Using-ESP8266-and-Blynk-IOT └── temperature-controlled-fan-using-esp8266-and-blynk-iot.ino ├── Temperature-Data-Logger-in-Google-Spreadsheet ├── GoogleScript.js └── temperature-data-logger-in-google-spreadsheet.ino ├── Temperature-Monitor-Using-DS18B20-and-Blynk-IOT └── temperature-monitor-using-DS18B20-and-blynk-iot.io ├── Temperature-Monitor-Using-ThingSpeak └── temperature-monitor-using-thingspeak.ino ├── Temperature-Monitor-Using-WhatsApp └── temperature-monitor-using-whatsapp.ino ├── Temperature-Pressure-Altitude-Monitor-Using-ESP8266-Blynk-IOT └── temperature-pressure-altitude-blynk-iot-esp8266-blynkiot.ino ├── Temperature-Pressure-Altitude-Monitor-Using-Whatsapp └── temperature-pressure-altitude-monitor-using-whatsapp.ino ├── Temperature-and-Humidity-Monitor-Using-ESP8266-Blynk └── temperature-and-humidity-using-esp8266-blynk.ino ├── Theft-Alert-Notification-Using-Blynk-IOT └── theft-alert-notification-using-blynk-iot-and-esp8266.ino ├── Theft-Alert-Notification-Using-Microwave-Radar-Sensor-RCWL-0516-and-ESP8266 └── theft-alert-using-microwave-radar-sensor-rcwl-0516-and-esp8266.ino ├── Voltage-Monitor-with-ESP8266-Blynk-IoT └── voltage-monitor-with-esp8266-blynk-iot.ino ├── Water-Level-Monitoring-Using-ESP8266-Blynk-IOT └── water-level-monitoring-using-esp8266-and-blynk-iot.ino ├── Water-Quality-Monitoring-Using-TDS-Sensor-and-ESP8266-with-Blynk-IoT └── Water-Quality-Monitoring-Using-TDS-Sensor-and-ESP8266-with-Blynk-IoT.ino ├── Weather-Monitoring-System-with-ESP8266-and-Blynk └── weather-monitoring-system-with-esp8266-and-blynk.iot ├── Weather-Station-Web-Server ├── weather-station-web-server-circuit.png └── weather-station-web-server.ino └── WhatsApp-Home-Automation-Using-ESP8266 └── whatsapp-home-automation-using-esp8266.ino /Air-Quality-Monitoring-System/air-quality-monitoring-system.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPLgwKssgggsnFXp" 2 | #define BLYNK_DEVICE_NAME "Air Quality Monitoring" 3 | #define BLYNK_AUTH_TOKEN "k03gT6nJosdsfsffesrJV_S5SXEAdgdsdghhgPZvXEwSKDfj" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | //#include 12 | #include 13 | 14 | LiquidCrystal_I2C lcd(0x27, 16, 2); 15 | 16 | byte degree_symbol[8] = 17 | { 18 | 0b00111, 19 | 0b00101, 20 | 0b00111, 21 | 0b00000, 22 | 0b00000, 23 | 0b00000, 24 | 0b00000, 25 | 0b00000 26 | }; 27 | 28 | char auth[] = BLYNK_AUTH_TOKEN; 29 | 30 | char ssid[] = ""; // type your wifi name 31 | char pass[] = ""; // type your wifi password 32 | 33 | BlynkTimer timer; 34 | 35 | int gas = A0; 36 | int sensorThreshold = 100; 37 | 38 | #define DHTPIN 2 //Connect Out pin to D4 in NODE MCU 39 | #define DHTTYPE DHT11 40 | DHT dht(DHTPIN, DHTTYPE); 41 | 42 | 43 | void sendSensor() 44 | { 45 | 46 | 47 | float h = dht.readHumidity(); 48 | float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit 49 | 50 | 51 | if (isnan(h) || isnan(t)) { 52 | Serial.println("Failed to read from DHT sensor!"); 53 | return; 54 | } 55 | int analogSensor = analogRead(gas); 56 | Blynk.virtualWrite(V2, analogSensor); 57 | Serial.print("Gas Value: "); 58 | Serial.println(analogSensor); 59 | // You can send any value at any time. 60 | // Please don't send more that 10 values per second. 61 | Blynk.virtualWrite(V0, t); 62 | Blynk.virtualWrite(V1, h); 63 | 64 | Serial.print("Temperature : "); 65 | Serial.print(t); 66 | Serial.print(" Humidity : "); 67 | Serial.println(h); 68 | 69 | 70 | } 71 | void setup() 72 | { 73 | 74 | Serial.begin(115200); 75 | 76 | //pinMode(gas, INPUT); 77 | Blynk.begin(auth, ssid, pass); 78 | dht.begin(); 79 | timer.setInterval(30000L, sendSensor); 80 | 81 | //Wire.begin(); 82 | lcd.begin(); 83 | 84 | 85 | // lcd.backlight(); 86 | // lcd.clear(); 87 | lcd.setCursor(3,0); 88 | lcd.print("Air Quality"); 89 | lcd.setCursor(3,1); 90 | lcd.print("Monitoring"); 91 | delay(2000); 92 | lcd.clear(); 93 | } 94 | 95 | void loop() 96 | { 97 | Blynk.run(); 98 | timer.run(); 99 | float h = dht.readHumidity(); 100 | float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit 101 | int gasValue = analogRead(gas); 102 | lcd.setCursor(0,0); 103 | lcd.print("Temperature "); 104 | lcd.setCursor(0,1); 105 | lcd.print(t); 106 | lcd.setCursor(6,1); 107 | lcd.write(1); 108 | lcd.createChar(1, degree_symbol); 109 | lcd.setCursor(7,1); 110 | lcd.print("C"); 111 | delay(4000); 112 | lcd.clear(); 113 | lcd.setCursor(0, 0); 114 | lcd.print("Humidity "); 115 | lcd.print(h); 116 | lcd.print("%"); 117 | delay(4000); 118 | lcd.clear(); 119 | //lcd.setCursor(0,0); 120 | // lcd.print(gasValue); 121 | // lcd.clear(); 122 | if(gasValue<600) 123 | { 124 | lcd.setCursor(0,0); 125 | lcd.print("Gas Value: "); 126 | lcd.print(gasValue); 127 | lcd.setCursor(0, 1); 128 | lcd.print("Fresh Air"); 129 | Serial.println("Fresh Air"); 130 | delay(4000); 131 | lcd.clear(); 132 | } 133 | else if(gasValue>600) 134 | { 135 | lcd.setCursor(0,0); 136 | lcd.print(gasValue); 137 | lcd.setCursor(0, 1); 138 | lcd.print("Bad Air"); 139 | Serial.println("Bad Air"); 140 | delay(4000); 141 | lcd.clear(); 142 | } 143 | 144 | if(gasValue > 600){ 145 | //Blynk.email("shameer50@gmail.com", "Alert", "Bad Air!"); 146 | Blynk.logEvent("pollution_alert","Bad Air"); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /Air-Quality-Monitoring-Using-Blynk-ThingSpeak-ESP8266/air-quality-monitoring-using-blynk-thingspeak-esp8266.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Air Quality Monitoring Using Blynk, ThingSpeak and ESP8266 3 | 4 | #define BLYNK_TEMPLATE_ID "TMPL3_KL1ZjEs" 5 | #define BLYNK_TEMPLATE_NAME "Air Quality Monitoring" 6 | #define BLYNK_AUTH_TOKEN "jo71QKpxVdJeq2XSgduhJ2KodfuSq3ZhhdohvYDA" 7 | 8 | #define BLYNK_PRINT Serial 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "MQ135.h" 15 | #include 16 | 17 | String apiKey = "VU37fsMfJ5NGsdgfXEFNg5EQsg"; // Enter your Write API key from ThingSpeak 18 | const char *ssid = "WiFi Username"; // replace with your WiFi SSID 19 | const char *pass = "WiFi Password"; // replace with your WiFi password 20 | const char *server = "api.thingspeak.com"; 21 | const int sensorPin = 0; 22 | int air_quality; 23 | 24 | LiquidCrystal_I2C lcd(0x27, 16, 2); 25 | 26 | byte degree_symbol[8] = 27 | { 28 | 0b00111, 29 | 0b00101, 30 | 0b00111, 31 | 0b00000, 32 | 0b00000, 33 | 0b00000, 34 | 0b00000, 35 | 0b00000}; 36 | 37 | char auth[] = BLYNK_AUTH_TOKEN; 38 | 39 | BlynkTimer timer; 40 | 41 | int gas = A0; 42 | int sensorThreshold = 100; 43 | 44 | #define DHTPIN 2 // Connect Out pin to D4 in NODE MCU 45 | #define DHTTYPE DHT11 46 | DHT dht(DHTPIN, DHTTYPE); 47 | 48 | WiFiClient client; 49 | 50 | void sendToThingSpeak(float temperature, float humidity, int airQuality) 51 | { 52 | if (client.connect(server, 80)) // "184.106.153.149" or api.thingspeak.com 53 | { 54 | String postStr = apiKey; 55 | postStr += "&field1="; 56 | postStr += String(temperature); 57 | postStr += "&field2="; 58 | postStr += String(humidity); 59 | postStr += "&field3="; 60 | postStr += String(airQuality); 61 | postStr += "\r\n\r\n"; 62 | 63 | client.print("POST /update HTTP/1.1\n"); 64 | client.print("Host: api.thingspeak.com\n"); 65 | client.print("Connection: close\n"); 66 | client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n"); 67 | client.print("Content-Type: application/x-www-form-urlencoded\n"); 68 | client.print("Content-Length: "); 69 | client.print(postStr.length()); 70 | client.print("\n\n"); 71 | client.print(postStr); 72 | 73 | Serial.print("Temperature: "); 74 | Serial.print(temperature); 75 | Serial.print(" degrees Celsius, Humidity: "); 76 | Serial.print(humidity); 77 | Serial.print("%, Air Quality: "); 78 | Serial.print(airQuality); 79 | Serial.println(" PPM. Sent to ThingSpeak."); 80 | } 81 | client.stop(); 82 | } 83 | 84 | void sendSensor() 85 | { 86 | float h = dht.readHumidity(); 87 | float t = dht.readTemperature(); 88 | int analogSensor = analogRead(gas); 89 | 90 | Blynk.virtualWrite(V2, analogSensor); 91 | Blynk.virtualWrite(V0, t); 92 | Blynk.virtualWrite(V1, h); 93 | 94 | Serial.print("Gas Value: "); 95 | Serial.println(analogSensor); 96 | Serial.print("Temperature : "); 97 | Serial.print(t); 98 | Serial.print(" Humidity : "); 99 | Serial.println(h); 100 | 101 | // Send data to ThingSpeak 102 | sendToThingSpeak(t, h, analogSensor); 103 | } 104 | 105 | void setup() 106 | { 107 | Serial.begin(115200); 108 | 109 | Blynk.begin(auth, ssid, pass); 110 | dht.begin(); 111 | timer.setInterval(2000L, sendSensor); 112 | 113 | lcd.begin(); 114 | lcd.createChar(1, degree_symbol); 115 | 116 | lcd.setCursor(3, 0); 117 | lcd.print("Air Quality"); 118 | lcd.setCursor(3, 1); 119 | lcd.print("Monitoring"); 120 | delay(1000); 121 | lcd.clear(); 122 | 123 | Serial.println("Connecting to WiFi..."); 124 | WiFi.begin(ssid, pass); 125 | while (WiFi.status() != WL_CONNECTED) 126 | { 127 | delay(500); 128 | Serial.print("."); 129 | } 130 | Serial.println(""); 131 | Serial.println("WiFi connected"); 132 | } 133 | 134 | void loop() 135 | { 136 | Blynk.run(); 137 | timer.run(); 138 | 139 | float h = dht.readHumidity(); 140 | float t = dht.readTemperature(); 141 | int gasValue = analogRead(gas); 142 | 143 | lcd.setCursor(0, 0); 144 | lcd.print("Temperature "); 145 | lcd.setCursor(0, 1); 146 | lcd.print(t); 147 | lcd.setCursor(6, 1); 148 | lcd.write(1); 149 | lcd.setCursor(7, 1); 150 | lcd.print("C"); 151 | delay(1000); 152 | lcd.clear(); 153 | 154 | lcd.setCursor(0, 0); 155 | lcd.print("Humidity "); 156 | lcd.print(h); 157 | lcd.print("%"); 158 | delay(1000); 159 | lcd.clear(); 160 | 161 | if (gasValue < 120) 162 | { 163 | lcd.setCursor(0, 0); 164 | lcd.print("Gas Value: "); 165 | lcd.print(gasValue); 166 | lcd.setCursor(0, 1); 167 | lcd.print("Fresh Air"); 168 | Serial.println("Fresh Air"); 169 | delay(1000); 170 | lcd.clear(); 171 | } 172 | else if (gasValue > 120) 173 | { 174 | lcd.setCursor(0, 0); 175 | lcd.print("Gas Value: "); 176 | lcd.print(gasValue); 177 | lcd.setCursor(0, 1); 178 | lcd.print("Bad Air"); 179 | Serial.println("Bad Air"); 180 | delay(1000); 181 | lcd.clear(); 182 | } 183 | 184 | if (gasValue > 120) 185 | { 186 | //Blynk.email("shameer50@gmail.com", "Alert", "Bad Air!"); 187 | Blynk.logEvent("pollution_alert", "Bad Air"); 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /Air-Quality-Monitoring-Using-Google-Spreadsheet-and-ESP8266/DebugMacros.h: -------------------------------------------------------------------------------- 1 | // Variadic macros used to print information in de-bugging mode 2 | // from LarryD, Arduino forum 3 | 4 | #pragma once 5 | // un-comment this line to print the debugging statements 6 | //#define DEBUG 7 | 8 | #ifdef DEBUG 9 | #define DPRINT(...) Serial.print(__VA_ARGS__) 10 | #define DPRINTLN(...) Serial.println(__VA_ARGS__) 11 | #else 12 | // define blank line 13 | #define DPRINT(...) 14 | #define DPRINTLN(...) 15 | #endif 16 | -------------------------------------------------------------------------------- /Air-Quality-Monitoring-Using-Google-Spreadsheet-and-ESP8266/GoogleScript.gs: -------------------------------------------------------------------------------- 1 | 2 | var SS = SpreadsheetApp.openById('1uRJJVWRdGQ-ll5dGdxywYO8lxJVfplRWWEkeul1e1_M'); // Enter Your Sheet ID Got From Sheet URL Link 3 | var sheet = SS.getSheetByName('air_quality_data_sheet'); // Enter your sheet name here, In my case it is Temp_Data_Sheet 4 | var str = ""; 5 | 6 | function onOpen() { 7 | var ui = SpreadsheetApp.getUi(); 8 | ui.createMenu('Air_Quality_Monitoring') 9 | .addItem('Clear', 'Clear') 10 | .addToUi(); 11 | } 12 | 13 | function Clear() { 14 | sheet.deleteRows(4, sheet.getLastRow()); 15 | SS.toast('Chart cleared', 'Air_Quality_Monitoring', 5); 16 | } 17 | 18 | function doPost(e) { 19 | var parsedData; 20 | var result = {}; 21 | 22 | try { 23 | parsedData = JSON.parse(e.postData.contents); 24 | } catch (f) { 25 | return ContentService.createTextOutput("Error in parsing request body: " + f.message); 26 | } 27 | 28 | if (parsedData !== undefined) { 29 | var flag = parsedData.format; 30 | 31 | if (flag === undefined) { 32 | flag = 0; 33 | } 34 | 35 | switch (parsedData.command) { 36 | case "appendRow": 37 | var tmp = SS.getSheetByName(parsedData.sheet_name); 38 | var nextFreeRow = tmp.getLastRow() + 1; 39 | var dataArr = parsedData.values.split(","); 40 | 41 | // Add date, temperature, humidity, and air quality to the data array 42 | var now = new Date(); 43 | dataArr.unshift(Utilities.formatDate(now, "EST", "yyyy-MM-dd hh:mm a")); // Format date without 'T' and 'Z' 44 | 45 | tmp.appendRow(dataArr); 46 | 47 | str = "Success"; 48 | SpreadsheetApp.flush(); 49 | break; 50 | } 51 | 52 | return ContentService.createTextOutput(str); 53 | } else { 54 | return ContentService.createTextOutput("Error! Request body empty or in incorrect format."); 55 | } 56 | } 57 | 58 | function doGet(e) { 59 | var val = e.parameter.value; 60 | var cal = e.parameter.cal; 61 | var read = e.parameter.read; 62 | 63 | if (cal !== undefined) { 64 | return ContentService.createTextOutput(GetEventsOneWeek()); 65 | } 66 | 67 | if (read !== undefined) { 68 | var now = Utilities.formatDate(new Date(), "EST", "yyyy-MM-dd hh:mm a"); 69 | sheet.getRange('C1').setValue(count); 70 | return ContentService.createTextOutput(sheet.getRange('A1').getValue()); 71 | } 72 | 73 | if (e.parameter.value === undefined) 74 | return ContentService.createTextOutput("No value passed as an argument to the script URL."); 75 | 76 | var range = sheet.getRange('A1'); 77 | var retval = range.setValue(val).getValue(); 78 | var now = Utilities.formatDate(new Date(), "EST", "yyyy-MM-dd hh:mm a"); 79 | sheet.getRange('A1').setValue("Date"); 80 | sheet.getRange('B1').setValue(val); // Assuming 'val' is the temperature 81 | sheet.getRange('C1').setValue("Humidity"); 82 | sheet.getRange('D1').setValue("Air Quality"); 83 | 84 | if (retval == e.parameter.value) 85 | return ContentService.createTextOutput("Successfully wrote: " + e.parameter.value + "\ninto the spreadsheet."); 86 | else 87 | return ContentService.createTextOutput("Unable to write into the spreadsheet.\nCheck authentication and make sure the cursor is not on cell 'A1'. " + retval + ' ' + e.parameter.value); 88 | } 89 | 90 | function GetEventsOneWeek() { 91 | var Cal = CalendarApp.getCalendarsByName('Test REST API')[0]; 92 | var Now = new Date(); 93 | var OneWeekFromNow = new Date(); 94 | OneWeekFromNow.setDate(Now.getDate() + 7); 95 | var events = Cal.getEvents(Now, OneWeekFromNow); 96 | var str = '\nEvent Title,\tDescription,\tRecurring?,\tAll-day?,\tFirst Reminder (in minutes before event)\n'; 97 | for (var i = 0; i < events.length; i++) { 98 | str += events[i].getTitle() + ',\t' + events[i].getDescription() + ',\t' + events[i].isRecurringEvent() + ',\t' + events[i].isAllDayEvent() + ',\t' + events[i].getPopupReminders()[0]; 99 | str += '\n'; 100 | } 101 | return str; 102 | } 103 | -------------------------------------------------------------------------------- /Air-Quality-Monitoring-Using-Google-Spreadsheet-and-ESP8266/HTTPSRedirect.h: -------------------------------------------------------------------------------- 1 | /* HTTPS on ESP8266 with follow redirects, chunked encoding support 2 | * Version 2.1 3 | * Author: Sujay Phadke 4 | * Github: @electronicsguy 5 | * Copyright (C) 2017 Sujay Phadke 6 | * All rights reserved. 7 | * 8 | */ 9 | #pragma once 10 | #include 11 | 12 | // Un-comment for extra functionality 13 | //#define EXTRA_FNS 14 | #define OPTIMIZE_SPEED 15 | 16 | class HTTPSRedirect : public WiFiClientSecure { 17 | private: 18 | const int _httpsPort; 19 | bool _keepAlive; 20 | String _redirUrl; 21 | String _redirHost; 22 | unsigned int _maxRedirects; // to-do 23 | const char* _contentTypeHeader; 24 | 25 | struct headerFields{ 26 | String transferEncoding; 27 | unsigned int contentLength; 28 | #ifdef EXTRA_FNS 29 | String contentType; 30 | #endif 31 | }; 32 | 33 | headerFields _hF; 34 | 35 | String _Request; 36 | 37 | struct Response{ 38 | int statusCode; 39 | String reasonPhrase; 40 | bool redirected; 41 | String body; 42 | }; 43 | 44 | Response _myResponse; 45 | bool _printResponseBody; 46 | 47 | void Init(void); 48 | bool printRedir(void); 49 | void fetchHeader(void); 50 | bool getLocationURL(void); 51 | void fetchBodyUnChunked(unsigned); 52 | void fetchBodyChunked(void); 53 | unsigned int getResponseStatus(void); 54 | void InitResponse(void); 55 | void createGetRequest(const String&, const char*); 56 | void createPostRequest(const String&, const char*, const String&); 57 | 58 | #ifdef EXTRA_FNS 59 | void fetchBodyRaw(void); 60 | void printHeaderFields(void); 61 | #endif 62 | 63 | public: 64 | HTTPSRedirect(const int); 65 | ~HTTPSRedirect(); 66 | 67 | bool GET(const String&, const char*); 68 | bool GET(const String&, const char*, const bool&); 69 | bool POST(const String&, const char*, const String&); 70 | bool POST(const String&, const char*, const String&, const bool&); 71 | 72 | int getStatusCode(void); 73 | String getReasonPhrase(void); 74 | String getResponseBody(void); 75 | 76 | void setPrintResponseBody(bool); 77 | void setMaxRedirects(const unsigned int); 78 | 79 | void setContentTypeHeader(const char *); 80 | #ifdef OPTIMIZE_SPEED 81 | bool reConnectFinalEndpoint(void); 82 | #endif 83 | 84 | }; 85 | -------------------------------------------------------------------------------- /Air-Quality-Monitoring-Using-Google-Spreadsheet-and-ESP8266/air-quality-monitoring-using-google-spreadsheet-and-esp8266.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HTTPSRedirect.h" 3 | #include "DebugMacros.h" 4 | #include 5 | 6 | #define DHTPIN D2 // Connect to Pin D2 in ESP8266 7 | #define DHTTYPE DHT11 // select dht type as DHT 11 or DHT22 8 | DHT dht(DHTPIN, DHTTYPE); 9 | 10 | float h; 11 | float t; 12 | int air_quality = A0; 13 | String sheetHumid = ""; 14 | String sheetTemp = ""; 15 | String sheetairquality=""; 16 | 17 | 18 | const char* ssid = "WiFi Username"; //replace with our wifi ssid 19 | const char* password = "WiFi Password"; //replace with your wifi password 20 | 21 | const char* host = "script.google.com"; 22 | const char *GScriptId = "AKfycbyWsgB9tUL93wFktdfhgfVa22gjJ0uN8hgjj9Kw5ONZCe2-f5jwmDYl9Pb153vttBLnNKhv4ERLNzA"; // Replace with your own google script id 23 | const int httpsPort = 443; //the https port is same 24 | 25 | // echo | openssl s_client -connect script.google.com:443 |& openssl x509 -fingerprint -noout 26 | const char* fingerprint = ""; 27 | 28 | //const uint8_t fingerprint[20] = {}; 29 | 30 | String url = String("/macros/s/") + GScriptId + "/exec?value=Temperature"; // Write Teperature to Google Spreadsheet at cell A1 31 | // Fetch Google Calendar events for 1 week ahead 32 | String url2 = String("/macros/s/") + GScriptId + "/exec?cal"; // Write to Cell A continuosly 33 | 34 | //replace with sheet name not with spreadsheet file name taken from google 35 | String payload_base = "{\"command\": \"appendRow\", \ 36 | \"sheet_name\": \"air_quality_data_sheet\", \ 37 | \"values\": "; 38 | String payload = ""; 39 | 40 | HTTPSRedirect* client = nullptr; 41 | 42 | // used to store the values of free stack and heap before the HTTPSRedirect object is instantiated 43 | // so that they can be written to Google sheets upon instantiation 44 | 45 | void setup() { 46 | delay(1000); 47 | Serial.begin(115200); 48 | dht.begin(); //initialise DHT11 49 | 50 | Serial.println(); 51 | Serial.print("Connecting to wifi: "); 52 | Serial.println(ssid); 53 | 54 | WiFi.begin(ssid, password); 55 | while (WiFi.status() != WL_CONNECTED) { 56 | delay(500); 57 | Serial.print("."); 58 | } 59 | Serial.println(""); 60 | Serial.println("WiFi connected"); 61 | Serial.println("IP address: "); 62 | Serial.println(WiFi.localIP()); 63 | 64 | // Use HTTPSRedirect class to create a new TLS connection 65 | client = new HTTPSRedirect(httpsPort); 66 | client->setInsecure(); 67 | client->setPrintResponseBody(true); 68 | client->setContentTypeHeader("application/json"); 69 | Serial.print("Connecting to "); 70 | Serial.println(host); //try to connect with "script.google.com" 71 | 72 | // Try to connect for a maximum of 5 times then exit 73 | bool flag = false; 74 | for (int i = 0; i < 5; i++) { 75 | int retval = client->connect(host, httpsPort); 76 | if (retval == 1) { 77 | flag = true; 78 | break; 79 | } 80 | else 81 | Serial.println("Connection failed. Retrying..."); 82 | } 83 | 84 | if (!flag) { 85 | Serial.print("Could not connect to server: "); 86 | Serial.println(host); 87 | Serial.println("Exiting..."); 88 | return; 89 | } 90 | // Finish setup() function in 1s since it will fire watchdog timer and will reset the chip. 91 | //So avoid too many requests in setup() 92 | 93 | Serial.println("\nWrite into cell 'A1'"); 94 | Serial.println("------>"); 95 | // fetch spreadsheet data 96 | client->GET(url, host); 97 | 98 | Serial.println("\nGET: Fetch Google Calendar Data:"); 99 | Serial.println("------>"); 100 | // fetch spreadsheet data 101 | client->GET(url2, host); 102 | 103 | Serial.println("\nStart Sending Sensor Data to Google Spreadsheet"); 104 | 105 | 106 | // delete HTTPSRedirect object 107 | delete client; 108 | client = nullptr; 109 | } 110 | 111 | void loop() { 112 | 113 | h = dht.readHumidity(); // Reading temperature or humidity takes about 250 milliseconds! 114 | t = dht.readTemperature(); 115 | int airqualityvalue = analogRead(air_quality); 116 | // Read temperature as Celsius (the default) 117 | if (isnan(h) || isnan(t)) { // Check if any reads failed and exit early (to try again). 118 | Serial.println(F("Failed to read from DHT sensor!")); 119 | return; 120 | } 121 | 122 | Serial.print("Humidity: "); Serial.print(h); 123 | sheetHumid = String(h) + String(" %"); //convert integer humidity to string humidity 124 | Serial.print("% Temperature: "); Serial.print(t); Serial.println("°C "); 125 | sheetTemp = String(t) + String(" °C"); 126 | Serial.print("Air Quality: "); Serial.println(airqualityvalue); 127 | sheetairquality = String(airqualityvalue) + String(" PPM"); 128 | 129 | static int error_count = 0; 130 | static int connect_count = 0; 131 | const unsigned int MAX_CONNECT = 20; 132 | static bool flag = false; 133 | 134 | payload = payload_base + "\"" + sheetTemp + "," + sheetHumid + "," + sheetairquality + "\"}"; 135 | 136 | if (!flag) { 137 | client = new HTTPSRedirect(httpsPort); 138 | client->setInsecure(); 139 | flag = true; 140 | client->setPrintResponseBody(true); 141 | client->setContentTypeHeader("application/json"); 142 | } 143 | 144 | if (client != nullptr) { 145 | if (!client->connected()) { 146 | client->connect(host, httpsPort); 147 | client->POST(url2, host, payload, false); 148 | Serial.print("Sent : "); Serial.println("Temp, Humid and Air Quality"); 149 | } 150 | } 151 | else { 152 | DPRINTLN("Error creating client object!"); 153 | error_count = 5; 154 | } 155 | 156 | if (connect_count > MAX_CONNECT) { 157 | connect_count = 0; 158 | flag = false; 159 | delete client; 160 | return; 161 | } 162 | 163 | // Serial.println("GET Data from cell 'A1':"); 164 | // if (client->GET(url3, host)) { 165 | // ++connect_count; 166 | // } 167 | // else { 168 | // ++error_count; 169 | // DPRINT("Error-count while connecting: "); 170 | // DPRINTLN(error_count); 171 | // } 172 | 173 | Serial.println("POST or SEND Sensor data to Google Spreadsheet:"); 174 | if (client->POST(url2, host, payload)) { 175 | ; 176 | } 177 | else { 178 | ++error_count; 179 | DPRINT("Error-count while connecting: "); 180 | DPRINTLN(error_count); 181 | } 182 | 183 | if (error_count > 3) { 184 | Serial.println("Halting processor..."); 185 | delete client; 186 | client = nullptr; 187 | Serial.printf("Final free heap: %u\n", ESP.getFreeHeap()); 188 | Serial.printf("Final stack: %u\n", ESP.getFreeContStack()); 189 | Serial.flush(); 190 | ESP.deepSleep(0); 191 | } 192 | delay(3000); // keep delay of minimum 2 seconds as dht allow reading after 2 seconds interval and also for google sheet 193 | } 194 | -------------------------------------------------------------------------------- /Control-DC-Fan-Using-ESP8266-and-Blynk-IOT/control-dc-fan-using-esp8266-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPLh9mutBsh" 2 | #define BLYNK_TEMPLATE_NAME "Control Fan Using ESP8266" 3 | #define BLYNK_AUTH_TOKEN "HddHMUCj2KNi8pusbqOfdhjljllbLZFSBDSRXzu" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | 8 | #include 9 | 10 | 11 | char auth[] = BLYNK_AUTH_TOKEN; 12 | 13 | char ssid[] = "WiFi Username"; // type your wifi name 14 | char pass[] = "WiFi Password"; // type your wifi password 15 | 16 | int relaypin = D2; //GPIO4 17 | void setup() 18 | { 19 | Serial.begin(115200); 20 | Blynk.begin(auth, ssid, pass); 21 | pinMode(relaypin,OUTPUT); 22 | 23 | } 24 | 25 | void loop() 26 | { 27 | Blynk.run(); 28 | } 29 | -------------------------------------------------------------------------------- /Control-DC-Motor-Using-Blynk-and-ESP8266/control-dc-motor-using-blynk-and-esp8266.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Control DC Motor Using Blynk and ESP8266 3 | 4 | #define BLYNK_PRINT Serial 5 | 6 | 7 | #define BLYNK_TEMPLATE_ID "TMPL13ga8Jsolyn" 8 | #define BLYNK_DEVICE_NAME "Control DC Motor" 9 | #define BLYNK_AUTH_TOKEN "AakOYAkEk_aCvxgfhklOFc2lZpuolskvj7pQv9d7N" 10 | 11 | #include 12 | #include 13 | 14 | 15 | char auth[] = BLYNK_AUTH_TOKEN; 16 | 17 | char ssid[] = "WiFi Username"; // type your wifi name 18 | char pass[] = "WiFi Password"; // type your wifi password 19 | 20 | int M1PWM = D5; 21 | int M2PWM = D6; 22 | int M1F = D1; //GPIO5 23 | int M1R = D2; //GPIO4 24 | int M2F = D3; //GPIO0 25 | int M2R = D4; //GPIO2 26 | 27 | int pinValue1; 28 | int pinValue2; 29 | 30 | BLYNK_WRITE(V1) 31 | { 32 | int pinValue1 = param.asInt(); 33 | analogWrite(M1PWM,pinValue1); 34 | Blynk.virtualWrite(V1,pinValue1); 35 | Serial.print("V1 Slider Value is "); 36 | Serial.println(pinValue1); 37 | } 38 | 39 | BLYNK_WRITE(V2) 40 | { 41 | int pinValue2 = param.asInt(); 42 | analogWrite(M2PWM,pinValue2); 43 | Blynk.virtualWrite(V1,pinValue2); 44 | Serial.print("V2 Slider Value is "); 45 | Serial.println(pinValue2); 46 | } 47 | 48 | 49 | void setup(){ 50 | pinMode(M1PWM, OUTPUT); 51 | pinMode(M2PWM, OUTPUT); 52 | pinMode(M1F, OUTPUT); 53 | pinMode(M1R, OUTPUT); 54 | pinMode(M2F, OUTPUT); 55 | pinMode(M2R, OUTPUT); 56 | Serial.begin(9600); 57 | Blynk.begin(auth,ssid,pass); 58 | 59 | } 60 | 61 | void loop(){ 62 | Blynk.run(); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /Control-Electric-Bulb-From-Mobile/control-electric-bulb-from-mobile.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_PRINT Serial // Comment this out to disable prints and save space 2 | #include 3 | #include 4 | 5 | char auth[] = "Auth Code"; 6 | char ssid[] = "Wifi Username"; 7 | char pass[] = "Wifi Password"; 8 | 9 | void setup() 10 | { 11 | Serial.begin(9600); 12 | Blynk.begin(auth,ssid,pass); 13 | 14 | } 15 | 16 | void loop() 17 | { 18 | Blynk.run(); 19 | } 20 | -------------------------------------------------------------------------------- /Control-LED-Using-Blynk-IOT/control-led-using-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Control LED Using Blynk 2.0/Blynk IOT 3 | 4 | #define BLYNK_TEMPLATE_ID "TemplateID" 5 | #define BLYNK_DEVICE_NAME "Device Name" 6 | #define BLYNK_AUTH_TOKEN "Auth Token" 7 | 8 | 9 | #define BLYNK_PRINT Serial 10 | #include 11 | #include 12 | 13 | 14 | char auth[] = BLYNK_AUTH_TOKEN; 15 | char ssid[] = "Wifi Username"; // Enter your Wifi Username 16 | char pass[] = "Wifi Password"; // Enter your Wifi password 17 | 18 | int ledpin = D4; 19 | void setup() 20 | { 21 | Serial.begin(115200); 22 | Blynk.begin(auth, ssid, pass); 23 | pinMode(ledpin,OUTPUT); 24 | } 25 | 26 | void loop() 27 | { 28 | Blynk.run(); 29 | } 30 | -------------------------------------------------------------------------------- /Control-LED-Using-Google-Assistant-and-Blynk/control-led-using-google-assistant-and-blynk.ino: -------------------------------------------------------------------------------- 1 | /************************************************************* 2 | Download latest Blynk library here: 3 | https://github.com/blynkkk/blynk-library/releases/latest 4 | 5 | Blynk is a platform with iOS and Android apps to control 6 | Arduino, Raspberry Pi and the likes over the Internet. 7 | You can easily build graphic interfaces for all your 8 | projects by simply dragging and dropping widgets. 9 | 10 | Downloads, docs, tutorials: http://www.blynk.cc 11 | Sketch generator: http://examples.blynk.cc 12 | Blynk community: http://community.blynk.cc 13 | Follow us: http://www.fb.com/blynkapp 14 | http://twitter.com/blynk_app 15 | 16 | Blynk library is licensed under MIT license 17 | This example code is in public domain. 18 | 19 | ************************************************************* 20 | This example runs directly on NodeMCU. 21 | 22 | Note: This requires ESP8266 support package: 23 | https://github.com/esp8266/Arduino 24 | 25 | Please be sure to select the right NodeMCU module 26 | in the Tools -> Board menu! 27 | 28 | For advanced settings please follow ESP examples : 29 | - ESP8266_Standalone_Manual_IP.ino 30 | - ESP8266_Standalone_SmartConfig.ino 31 | - ESP8266_Standalone_SSL.ino 32 | 33 | Change WiFi ssid, pass, and Blynk auth token to run :) 34 | Feel free to apply it to any other example. It's simple! 35 | *************************************************************/ 36 | 37 | /* Comment this out to disable prints and save space */ 38 | #define BLYNK_PRINT Serial 39 | 40 | /* Fill-in your Template ID (only if using Blynk.Cloud) */ 41 | //#define BLYNK_TEMPLATE_ID "YourTemplateID" 42 | #define BLYNK_TEMPLATE_ID "TMPLuRdfdgghyTegg8KP" 43 | #define BLYNK_DEVICE_NAME "Google Assistant Control LED" 44 | #define BLYNK_AUTH_TOKEN "i20jFR61m0IeQrcsFfdfddguFzAuzgdgG1y7XPUrB" 45 | 46 | #include 47 | #include 48 | 49 | // You should get Auth Token in the Blynk App. 50 | // Go to the Project Settings (nut icon). 51 | char auth[] = BLYNK_AUTH_TOKEN; 52 | 53 | // Your WiFi credentials. 54 | // Set password to "" for open networks. 55 | char ssid[] = ""; 56 | char pass[] = ""; 57 | 58 | void setup() 59 | { 60 | // Debug console 61 | Serial.begin(9600); 62 | 63 | Blynk.begin(auth, ssid, pass); 64 | // You can also specify server: 65 | //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80); 66 | //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080); 67 | } 68 | 69 | void loop() 70 | { 71 | Blynk.run(); 72 | } 73 | -------------------------------------------------------------------------------- /Control-LED-Using-Google-Assistant/control-LED-using-google-assistant.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Adafruit_MQTT.h" 3 | #include "Adafruit_MQTT_Client.h" 4 | 5 | #define led1 D1 6 | #define led2 D2 7 | 8 | 9 | #define WLAN_SSID "WIFI Username" // Your SSID 10 | #define WLAN_PASS "WIFI Password" // Your password 11 | 12 | /************************* Adafruit.io Setup *********************************/ 13 | 14 | #define AIO_SERVER "io.adafruit.com" //Adafruit Server 15 | #define AIO_SERVERPORT 1883 16 | #define AIO_USERNAME "AIOUsername" // Username 17 | #define AIO_KEY "AUTH Key" // Auth Key 18 | 19 | //WIFI CLIENT 20 | WiFiClient client; 21 | 22 | Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY); 23 | 24 | Adafruit_MQTT_Subscribe Light1 = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME"/feeds/led01"); // Feeds name should be same everywhere 25 | Adafruit_MQTT_Subscribe Light2 = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/feeds/led02"); 26 | 27 | 28 | void MQTT_connect(); 29 | 30 | void setup() { 31 | Serial.begin(115200); 32 | 33 | pinMode(led1, OUTPUT); 34 | // pinMode(led2, OUTPUT); 35 | 36 | 37 | // Connect to WiFi access point. 38 | Serial.println(); Serial.println(); 39 | Serial.print("Connecting to "); 40 | Serial.println(WLAN_SSID); 41 | 42 | WiFi.begin(WLAN_SSID, WLAN_PASS); 43 | while (WiFi.status() != WL_CONNECTED) { 44 | delay(500); 45 | Serial.print("."); 46 | } 47 | Serial.println(); 48 | 49 | Serial.println("WiFi connected"); 50 | Serial.println("IP address: "); 51 | Serial.println(WiFi.localIP()); 52 | 53 | mqtt.subscribe(&Light1); 54 | // mqtt.subscribe(&Light2); 55 | 56 | } 57 | 58 | void loop() { 59 | 60 | MQTT_connect(); 61 | 62 | 63 | Adafruit_MQTT_Subscribe *subscription; 64 | while ((subscription = mqtt.readSubscription(20000))) { 65 | if (subscription == &Light1) { 66 | Serial.print(F("Got: ")); 67 | Serial.println((char *)Light1.lastread); 68 | int Light1_State = atoi((char *)Light1.lastread); 69 | digitalWrite(led1, Light1_State); 70 | 71 | } 72 | /* if (subscription == &Light2) { 73 | Serial.print(F("Got: ")); 74 | Serial.println((char *)Light2.lastread); 75 | int Light2_State = atoi((char *)Light2.lastread); 76 | digitalWrite(led2, Light2_State); 77 | }*/ 78 | } 79 | 80 | 81 | } 82 | 83 | void MQTT_connect() { 84 | int8_t ret; 85 | 86 | if (mqtt.connected()) { 87 | return; 88 | } 89 | 90 | Serial.print("Connecting to MQTT... "); 91 | 92 | uint8_t retries = 3; 93 | 94 | while ((ret = mqtt.connect()) != 0) { 95 | Serial.println(mqtt.connectErrorString(ret)); 96 | Serial.println("Retrying MQTT connection in 5 seconds..."); 97 | mqtt.disconnect(); 98 | delay(5000); 99 | retries--; 100 | if (retries == 0) { 101 | while (1); 102 | } 103 | } 104 | Serial.println("MQTT Connected!"); 105 | 106 | } 107 | -------------------------------------------------------------------------------- /Control-LED-Using-WhatsApp/control-led-using-whatsapp.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | ThingESP8266 thing("Username", "ProjectName", "ProjectUserName"); 5 | 6 | int LED = D2; 7 | 8 | unsigned long previousMillis = 0; 9 | const long INTERVAL = 6000; 10 | 11 | void setup() 12 | { 13 | Serial.begin(115200); 14 | pinMode(LED, OUTPUT); 15 | thing.SetWiFi("WiFiUsername", "WiFiPassword"); 16 | thing.initDevice(); 17 | } 18 | 19 | 20 | String HandleResponse(String query) 21 | { 22 | if (query == "led on") { 23 | digitalWrite(LED, 1); 24 | return "Done: LED Turned ON"; 25 | } 26 | 27 | else if (query == "led off") { 28 | digitalWrite(LED, 0); 29 | return "Done: LED Turned OFF"; 30 | } 31 | 32 | else if (query == "led status") 33 | return digitalRead(LED) ? "LED is OFF" : "LED is ON"; 34 | else return "Your query was invalid.."; 35 | 36 | } 37 | 38 | 39 | void loop() 40 | { 41 | thing.Handle(); 42 | 43 | } 44 | -------------------------------------------------------------------------------- /Control-LEDs-with-Localhost-MySQL-and-Xampp-Server/control-leds-with-localhost-mysql-and-xampp-server.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | // #include 6 | // #include 7 | 8 | const char* ssid = "WiFi Username"; 9 | const char* password = "WiFi Password"; 10 | 11 | const char* serverName = "http://localIP/control_led/getLedStatus.php"; 12 | 13 | const int led1Pin = D1; 14 | const int led2Pin = D2; 15 | const int led3Pin = D3; 16 | const int led4Pin = D4; 17 | 18 | WiFiClient wifiClient; 19 | 20 | void setup() { 21 | Serial.begin(115200); 22 | pinMode(led1Pin, OUTPUT); 23 | pinMode(led2Pin, OUTPUT); 24 | pinMode(led3Pin, OUTPUT); 25 | pinMode(led4Pin, OUTPUT); 26 | 27 | WiFi.begin(ssid, password); 28 | 29 | while (WiFi.status() != WL_CONNECTED) { 30 | delay(1000); 31 | Serial.println("Connecting to WiFi..."); 32 | } 33 | 34 | Serial.println("Connected to WiFi"); 35 | } 36 | 37 | void loop() { 38 | if (WiFi.status() == WL_CONNECTED) { 39 | HTTPClient http; 40 | 41 | http.begin(wifiClient, serverName); // Updated to use WiFiClient 42 | int httpResponseCode = http.GET(); 43 | 44 | if (httpResponseCode > 0) { 45 | String payload = http.getString(); 46 | Serial.println(payload); 47 | 48 | DynamicJsonDocument doc(1024); 49 | deserializeJson(doc, payload); 50 | 51 | int led1 = doc["led1"]; 52 | int led2 = doc["led2"]; 53 | int led3 = doc["led3"]; 54 | int led4 = doc["led4"]; 55 | 56 | digitalWrite(led1Pin, led1); 57 | digitalWrite(led2Pin, led2); 58 | digitalWrite(led3Pin, led3); 59 | digitalWrite(led4Pin, led4); 60 | } else { 61 | Serial.println("Error on HTTP request"); 62 | } 63 | 64 | http.end(); 65 | } 66 | 67 | delay(1000); // Check every 10 seconds 68 | } 69 | -------------------------------------------------------------------------------- /Control-LEDs-with-Localhost-MySQL-and-Xampp-Server/getLedStatus.php: -------------------------------------------------------------------------------- 1 | connect_error) { 12 | die("Connection failed: " . $conn->connect_error); 13 | } 14 | 15 | //retrieve LED status 16 | $sql = "SELECT * FROM led_status WHERE id = 1"; 17 | $result = $conn->query($sql); 18 | 19 | if ($result) { 20 | if ($result->num_rows > 0) { 21 | $row = $result->fetch_assoc(); 22 | echo json_encode($row); 23 | } else { 24 | echo json_encode(["error" => "No data found"]); 25 | } 26 | } else { 27 | echo json_encode(["error" => "Query failed"]); 28 | } 29 | 30 | // Close the connection 31 | $conn->close(); 32 | ?> 33 | -------------------------------------------------------------------------------- /Control-LEDs-with-Localhost-MySQL-and-Xampp-Server/index.php: -------------------------------------------------------------------------------- 1 | connect_error) { 12 | die("Connection failed: " . $conn->connect_error); 13 | } 14 | 15 | // Handle AJAX request 16 | if (isset($_POST['led']) && isset($_POST['status'])) { 17 | $led = $_POST['led']; 18 | $status = $_POST['status']; 19 | 20 | $sql = "UPDATE led_status SET $led=$status WHERE id=1"; 21 | $conn->query($sql); 22 | exit; 23 | } 24 | 25 | // Retrieve LED status 26 | $sql = "SELECT * FROM led_status WHERE id=1"; 27 | $result = $conn->query($sql); 28 | $row = $result->fetch_assoc(); 29 | ?> 30 | 31 | 32 | 33 | 34 | ESP32 LED Control 35 | 116 | 130 | 131 | 132 |
133 |
Tech Trends Shameer
134 |

ESP32 LED Control

135 |
136 | LED 1 137 | 141 |
142 |
143 | LED 2 144 | 148 |
149 |
150 | LED 3 151 | 155 |
156 |
157 | LED 4 158 | 162 |
163 |
164 | 165 | 166 | -------------------------------------------------------------------------------- /Control-LEDs-with-Localhost-MySQL-and-Xampp-Server/query.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE `led_status` ( 2 | `id` INT NOT NULL AUTO_INCREMENT, 3 | `led1` TINYINT NOT NULL DEFAULT 0, 4 | `led2` TINYINT NOT NULL DEFAULT 0, 5 | `led3` TINYINT NOT NULL DEFAULT 0, 6 | `led4` TINYINT NOT NULL DEFAULT 0, 7 | PRIMARY KEY (`id`) 8 | ); 9 | -------------------------------------------------------------------------------- /Control-Servo-Motor-Using-ESP8266-and-Blynk-IOT/control-servo-motor-using-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //How to Control Servo Motor Using Blynk IOT and ESP8266 | Servo Motor Control With Blynk 3 | 4 | #define BLYNK_TEMPLATE_ID "TMPL3q4FTdRjZ" 5 | #define BLYNK_TEMPLATE_NAME "Servo Motor Control" 6 | #define BLYNK_AUTH_TOKEN "cUxIK960I9wl5FkIJqoaAdfhklZDhPl;;OYdRIOn" 7 | 8 | 9 | #define BLYNK_PRINT Serial 10 | #include 11 | #include 12 | 13 | #include 14 | Servo servo1, servo2; 15 | 16 | char auth[] = BLYNK_AUTH_TOKEN; 17 | char ssid[] = "WiFi Username"; 18 | char pass[] = "WiFi Password"; 19 | 20 | BLYNK_WRITE(V0) 21 | { 22 | int s0 = param.asInt(); 23 | servo1.write(s0); 24 | Blynk.virtualWrite(V2, s0); 25 | } 26 | 27 | BLYNK_WRITE(V1) 28 | { 29 | int s1 = param.asInt(); 30 | servo2.write(s1); 31 | Blynk.virtualWrite(V3, s1); 32 | } 33 | 34 | 35 | void setup() 36 | { 37 | Serial.begin(9600); 38 | servo1.attach(D2); //Connect to Pin D2 in NodeMCU 39 | servo2.attach(D3); //Connect to Pin D3 in NodeMCU 40 | Blynk.begin(auth, ssid, pass);//Splash screen delay 41 | delay(2000); 42 | } 43 | 44 | void loop() 45 | { 46 | Blynk.run(); 47 | } 48 | -------------------------------------------------------------------------------- /Control-Servo-Motor-Using-WhatsApp-and-ESP8266/control-servo-motor-using-whatsapp-and-esp8266.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | ThingESP8266 thing("techtrends", "ControlLED", "techtrends"); 7 | Servo servo1; 8 | 9 | int servo_pin =D2; 10 | unsigned long previousMillis = 0; 11 | const long INTERVAL = 6000; 12 | 13 | void setup() 14 | { 15 | Serial.begin(9600); 16 | 17 | servo1.attach(servo_pin); 18 | thing.SetWiFi("WiFi Username", "WiFi Password"); 19 | 20 | thing.initDevice(); 21 | 22 | } 23 | 24 | 25 | String HandleResponse(String query) 26 | { 27 | if (query == "servo 180") { 28 | digitalWrite(servo_pin, 1); 29 | servo1.write(180); 30 | return "Done: Servo Motor Turned 180 degree"; 31 | } 32 | 33 | else if (query == "servo 90") { 34 | digitalWrite(servo_pin, 1); 35 | servo1.write(90); 36 | return "Done: Servo Motor Turned 90 degree"; 37 | } 38 | else if (query == "servo 0") { 39 | digitalWrite(servo_pin, 1); 40 | servo1.write(0); 41 | return "Done: Servo Motor Turned 0 degree"; 42 | } 43 | 44 | else if (query == "servo status") 45 | return digitalRead(servo_pin) ? "Servo is OFF" : "Servo is ON"; 46 | else return "Your query was invalid.."; 47 | 48 | } 49 | 50 | 51 | void loop() 52 | { 53 | 54 | thing.Handle(); 55 | 56 | } 57 | -------------------------------------------------------------------------------- /Covid-Tracker-Using-ESP-8266/circuit-diagram-covid-tracker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tech-Trends-Shameer/Esp-8266-Projects/af0a60e690551a543f4bd7d024d9c77b7e09b2e0/Covid-Tracker-Using-ESP-8266/circuit-diagram-covid-tracker.png -------------------------------------------------------------------------------- /Covid-Tracker-Using-ESP-8266/covid-tracker-using-esp-8266.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Covid Traacker 3 | #include 4 | #include 5 | #include //Use ESP8266 functions 6 | #include 7 | 8 | LiquidCrystal_I2C lcd(0x27, 16, 2); 9 | 10 | const char* ssid = "WIFI Username"; //WIFI SSID Name 11 | const char* password = "WIFI Password"; //WIFI Password 12 | const char* host = "api.thingspeak.com"; //We read the data from this host 13 | const int httpPortRead = 80; 14 | 15 | const char* url1 = "/apps/thinghttp/send_request?api_key=GEPNLPK2LRI6TQ0W"; //Change this URL Cases 16 | const char* url2 = "/apps/thinghttp/send_request?api_key=94ZTR3ZL7V8VPERR"; //Deaths 17 | const char* url3 = "/apps/thinghttp/send_request?api_key=CVAKEYKSNXNELZ8K"; //Recovered 18 | int To_remove; //There are some irrelevant data on the string and here's how I keep the index 19 | //of those characters 20 | String Cases,Deaths,Recovered,Data_Raw,Data_Raw_1,Data_Raw_2,Data_Raw_3; //Here I keep the numbers that I got 21 | 22 | WiFiClient client; //Create a WiFi client and http client 23 | HTTPClient http; 24 | 25 | void setup() 26 | { 27 | Wire.begin(); 28 | lcd.begin(); 29 | 30 | 31 | lcd.backlight(); 32 | lcd.clear(); 33 | lcd.setCursor(3,0); 34 | lcd.print("Tech Trends "); 35 | lcd.setCursor(5, 1); 36 | lcd.print("Shameer"); 37 | 38 | Serial.begin(115200); 39 | WiFi.disconnect(); //Disconnect and Reconnect to the Wifi 40 | delay(1000); 41 | WiFi.begin(ssid, password); 42 | Serial.println("Connected to the WiFi network"); //Display feedback on the serial monitor 43 | Serial.println(WiFi.localIP()); 44 | } 45 | 46 | void loop() 47 | { 48 | 49 | //Reading 1: Reading of cases 50 | if( http.begin(host,httpPortRead,url1)) //Connect to the host and the URL 51 | { 52 | int httpCode = http.GET(); //Check feedback if there's a response 53 | if (httpCode > 0) 54 | { 55 | if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) 56 | { 57 | 58 | Data_Raw = http.getString(); //Here we store the raw data string 59 | 60 | 61 | Data_Raw_1 = Data_Raw; 62 | To_remove = Data_Raw_1.indexOf(">"); //I look for the position of this symbol ">" 63 | Data_Raw_1.remove(0,To_remove+1); //I remove it and everything that's before 64 | To_remove = Data_Raw_1.indexOf("<"); //I look for the position of this symbol ">" 65 | Data_Raw_1.remove(To_remove,Data_Raw_1.length()); //I remove it and everything that's after 66 | //Example: This is the raw data received 63,927 67 | //First we look for ">" and we remove everything before it including it 68 | //We stay with this 63,927 69 | //We look for "<" symbol and we remove it + everything after 70 | //We keep only this 63,927 as string 71 | Cases=Data_Raw_1; 72 | Serial.print("Cases: "); //I choosed to display it on the serial monitor to help you debug 73 | Serial.println(Cases); 74 | 75 | Data_Raw_2=Data_Raw; 76 | To_remove = Data_Raw_2.indexOf(""); 77 | Data_Raw_2.remove(0,To_remove+6); 78 | Data_Raw_3=Data_Raw_2; 79 | To_remove = Data_Raw_2.indexOf(""); 80 | Data_Raw_2.remove(To_remove,Data_Raw_2.length()); 81 | 82 | Deaths=Data_Raw_2; 83 | Serial.print("Deaths: "); 84 | Serial.println(Deaths); 85 | 86 | To_remove = Data_Raw_3.indexOf(""); 87 | Data_Raw_3.remove(0,To_remove+6); 88 | 89 | To_remove = Data_Raw_3.indexOf("<"); 90 | Data_Raw_3.remove(To_remove,Data_Raw_3.length()); 91 | 92 | Recovered=Data_Raw_3; 93 | 94 | Serial.print("Recovered: "); 95 | Serial.println(Recovered); 96 | 97 | } 98 | } 99 | else //If we can't get data 100 | { 101 | Serial.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str()); 102 | } 103 | 104 | http.end(); 105 | } 106 | else //If we can't connect to the HTTP 107 | { 108 | Serial.printf("[HTTP} Unable to connect\n"); 109 | } 110 | 111 | while (WiFi.status() != WL_CONNECTED) //In case the Wifi connexion is lost 112 | { 113 | 114 | WiFi.disconnect(); 115 | delay(1000); 116 | 117 | WiFi.begin(ssid, password); 118 | Serial.println("Reconnecting to WiFi.."); 119 | delay(10000); 120 | } 121 | lcd.clear(); 122 | lcd.setCursor(0, 0); 123 | lcd.print("Cases:"); 124 | lcd.setCursor(6, 0); 125 | lcd.print(Cases); 126 | 127 | 128 | lcd.setCursor(0, 1); 129 | lcd.print("D:"); 130 | lcd.setCursor(2, 1); 131 | lcd.print(Deaths); 132 | 133 | 134 | delay(4000); 135 | lcd.clear(); 136 | lcd.setCursor(0, 0); 137 | lcd.print("R:"); 138 | lcd.setCursor(3, 0); 139 | lcd.print(Recovered); 140 | delay(4000); 141 | 142 | } 143 | -------------------------------------------------------------------------------- /ESP-8266-Temperature-Web-Server/esp-8266-temperature-web-server.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends 2 | //ESP8266 Temperature Web Server 3 | 4 | 5 | // Import required libraries 6 | //#include "WiFi.h" 7 | 8 | #include "ESPAsyncWebServer.h" 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | // Replace with your network credentials 15 | const char* ssid = ""; 16 | const char* password = ""; 17 | 18 | #define DHTPIN 4 // Digital pin connected to the DHT sensor 19 | 20 | // Uncomment the type of sensor in use: 21 | #define DHTTYPE DHT11 // DHT 11 22 | //#define DHTTYPE DHT22 // DHT 22 (AM2302) 23 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 24 | 25 | DHT dht(DHTPIN, DHTTYPE); 26 | 27 | // Create AsyncWebServer object on port 80 28 | AsyncWebServer server(80); 29 | 30 | String readDHTTemperature() { 31 | // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 32 | // Read temperature as Celsius (the default) 33 | float t = dht.readTemperature(); 34 | // Read temperature as Fahrenheit (isFahrenheit = true) 35 | //float t = dht.readTemperature(true); 36 | // Check if any reads failed and exit early (to try again). 37 | if (isnan(t)) { 38 | Serial.println("Failed to read from DHT sensor!"); 39 | return "--"; 40 | } 41 | else { 42 | Serial.println(t); 43 | return String(t); 44 | } 45 | } 46 | 47 | String readDHTHumidity() { 48 | // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 49 | float h = dht.readHumidity(); 50 | if (isnan(h)) { 51 | Serial.println("Failed to read from DHT sensor!"); 52 | return "--"; 53 | } 54 | else { 55 | Serial.println(h); 56 | return String(h); 57 | } 58 | } 59 | 60 | const char index_html[] PROGMEM = R"rawliteral( 61 | 62 | 63 | 64 | 65 | 81 | 82 | 83 |

Tech Trends

84 |

ESP8266 DHT Server

85 |

86 | 87 | Temperature 88 | %TEMPERATURE% 89 | °C 90 |

91 |

92 | 93 | Humidity 94 | %HUMIDITY% 95 | % 96 |

97 | 98 | 121 | )rawliteral"; 122 | 123 | // Replaces placeholder with DHT values 124 | String processor(const String& var){ 125 | //Serial.println(var); 126 | if(var == "TEMPERATURE"){ 127 | return readDHTTemperature(); 128 | } 129 | else if(var == "HUMIDITY"){ 130 | return readDHTHumidity(); 131 | } 132 | return String(); 133 | } 134 | 135 | void setup(){ 136 | // Serial port for debugging purposes 137 | Serial.begin(115200); 138 | 139 | dht.begin(); 140 | 141 | // Connect to Wi-Fi 142 | WiFi.begin(ssid, password); 143 | while (WiFi.status() != WL_CONNECTED) { 144 | delay(1000); 145 | Serial.println("Connecting to WiFi.."); 146 | } 147 | 148 | // Print ESP32 Local IP Address 149 | Serial.println(WiFi.localIP()); 150 | 151 | // Route for root / web page 152 | server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ 153 | request->send_P(200, "text/html", index_html, processor); 154 | }); 155 | server.on("/temperature", HTTP_GET, [](AsyncWebServerRequest *request){ 156 | request->send_P(200, "text/plain", readDHTTemperature().c_str()); 157 | }); 158 | server.on("/humidity", HTTP_GET, [](AsyncWebServerRequest *request){ 159 | request->send_P(200, "text/plain", readDHTHumidity().c_str()); 160 | }); 161 | 162 | // Start server 163 | server.begin(); 164 | } 165 | 166 | void loop(){ 167 | 168 | } 169 | -------------------------------------------------------------------------------- /ESP8266-Telegram-Home-Automation/esp8266-telegram-home-automation.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Home Automation using Telegram Bot 3 | 4 | #include "CTBot.h" 5 | #include "DHT.h" 6 | 7 | int RELAYPIN =D4; // Digital pin connected to the DHT sensor 8 | 9 | CTBot myBot; 10 | TBMessage msg; 11 | String ssid = "WIFI Username"; //Enter Wifi Username 12 | String pass = "Wifi Password"; // Enter Wifi Password 13 | String token = "Token" ; // Enter Your Telegram Bot Token 14 | 15 | void setup() { 16 | // initialize the Serial 17 | Serial.begin(115200); 18 | // dht.begin(); 19 | pinMode(RELAYPIN, OUTPUT); 20 | Serial.println("Starting TelegramBot..."); 21 | myBot.wifiConnect(ssid, pass); 22 | myBot.setTelegramToken(token); 23 | if (myBot.testConnection()){ 24 | 25 | Serial.println("\ntestConnection OK"); 26 | } 27 | else 28 | { 29 | Serial.println("\ntestConnection NOK"); 30 | } 31 | 32 | 33 | } 34 | 35 | void loop() { 36 | 37 | if (myBot.getNewMessage(msg)) { 38 | 39 | if (msg.text.equalsIgnoreCase("light on")) { 40 | digitalWrite(RELAYPIN, HIGH); 41 | 42 | Serial.println("ON"); 43 | } 44 | if (msg.text.equalsIgnoreCase("light off")) { 45 | digitalWrite(RELAYPIN, LOW); 46 | 47 | Serial.println("OFF"); 48 | } 49 | 50 | } 51 | 52 | delay(10); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /ESP8266-Weather-Station-Web-Server/esp8266-weather-station-web-server.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //BMP 280 Web Server 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define SEALEVELPRESSURE_HPA (1013.25) 10 | 11 | #define BMP_SCK (13) 12 | #define BMP_MISO (12) 13 | #define BMP_MOSI (11) 14 | #define BMP_CS (10) 15 | 16 | Adafruit_BMP280 bmp; // I2C 17 | 18 | float temperature, humidity, pressure, altitude; 19 | 20 | /*Put your SSID & Password*/ 21 | 22 | 23 | const char* ssid = ""; // Enter SSID here 24 | const char* password = ""; //Enter Password here 25 | 26 | ESP8266WebServer server(80); 27 | 28 | void setup() { 29 | Serial.begin(115200); 30 | delay(100); 31 | 32 | bmp.begin(0x76); 33 | 34 | Serial.println("Connecting to "); 35 | Serial.println(ssid); 36 | 37 | //connect to your local wi-fi network 38 | WiFi.begin(ssid, password); 39 | 40 | //check wi-fi is connected to wi-fi network 41 | while (WiFi.status() != WL_CONNECTED) { 42 | delay(1000); 43 | Serial.print("."); 44 | } 45 | Serial.println(""); 46 | Serial.println("WiFi connected..!"); 47 | Serial.print("Got IP: "); Serial.println(WiFi.localIP()); 48 | 49 | server.on("/", handle_OnConnect); 50 | server.onNotFound(handle_NotFound); 51 | 52 | server.begin(); 53 | Serial.println("HTTP server started"); 54 | 55 | } 56 | void loop() { 57 | server.handleClient(); 58 | } 59 | 60 | void handle_OnConnect() { 61 | temperature = bmp.readTemperature(); 62 | // humidity = bmp.readHumidity(); 63 | pressure = bmp.readPressure() / 100.0F; 64 | altitude = bmp.readAltitude(SEALEVELPRESSURE_HPA); 65 | server.send(200, "text/html", SendHTML(temperature,pressure,altitude)); 66 | } 67 | 68 | void handle_NotFound(){ 69 | server.send(404, "text/plain", "Not found"); 70 | } 71 | 72 | String SendHTML(float temperature, float pressure,float altitude){ 73 | String ptr = ""; 74 | ptr +=""; 75 | ptr +=""; 76 | ptr +="ESP8266 Weather Station"; 77 | ptr +=""; 78 | ptr +=""; 79 | ptr +=""; 95 | ptr +=""; 96 | ptr +=""; 97 | ptr +="

BMP280 ESP8266 Weather Station

"; 98 | ptr +="
"; 99 | ptr +="
"; 100 | ptr +="
"; 101 | ptr +=""; 106 | ptr +="
"; 107 | ptr +="
Temperature
"; 108 | ptr +="
"; 109 | ptr +=(int)temperature; 110 | ptr +="°C
"; 111 | ptr +="
"; 112 | ptr +="
"; 113 | ptr +="
"; 114 | ptr +=""; 118 | ptr +="
"; 119 | 120 | ptr +="
Pressure
"; 121 | ptr +="
"; 122 | ptr +=(int)pressure; 123 | ptr +="hPa
"; 124 | ptr +="
"; 125 | ptr +="
"; 126 | ptr +="
"; 127 | ptr +=""; 134 | ptr +="
"; 135 | ptr +="
Altitude
"; 136 | ptr +="
"; 137 | ptr +=(int)altitude; 138 | ptr +="m
"; 139 | ptr +="
"; 140 | ptr +="
"; 141 | ptr +=""; 142 | ptr +=""; 143 | return ptr; 144 | } 145 | -------------------------------------------------------------------------------- /ESP8266-with-Telegram-Messenger-for-Monitoring-Temperature-and-Humidity-using-DHT11/ESP8266-with-telegram-messenger-for-monitoring-temperature-and-humidity-using-DHT11.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //ESP8266 with telegram messenger for monitoring temperature and humidity using DHT11 3 | 4 | #include "CTBot.h" 5 | #include "DHT.h" 6 | 7 | #define DHTPIN D4 // Digital pin connected to the DHT sensor 8 | #define DHTTYPE DHT11 // DHT 11 9 | DHT dht(DHTPIN, DHTTYPE); 10 | CTBot myBot; 11 | TBMessage msg; 12 | String ssid = "WIFI Username" ; // Enter WIFI Username 13 | String pass = "WIFI Passoword"; // Enter WIFI Password 14 | String token = "Token" ; // Enter the token from Telegram Bor 15 | 16 | void setup() { 17 | // initialize the Serial 18 | Serial.begin(115200); 19 | dht.begin(); 20 | Serial.println("Starting TelegramBot..."); 21 | myBot.wifiConnect(ssid, pass); 22 | myBot.setTelegramToken(token); 23 | if (myBot.testConnection()){ 24 | 25 | Serial.println("\ntestConnection OK"); 26 | } 27 | else 28 | { 29 | Serial.println("\ntestConnection NOK"); 30 | } 31 | 32 | 33 | } 34 | 35 | void loop() { 36 | // a variable to store telegram message data 37 | 38 | float h = dht.readHumidity(); 39 | // Read temperature as Celsius (the default) 40 | float t = dht.readTemperature(); 41 | // Read temperature as Fahrenheit (isFahrenheit = true) 42 | float f = dht.readTemperature(true); 43 | 44 | String humid = "Humidity: " + String(h) + " % \n"; 45 | String temp = "Temperature: " + String(t) + "°C, " + String(f) + "°F \n"; 46 | if (myBot.getNewMessage(msg)) { 47 | 48 | if (msg.text.equalsIgnoreCase("Humidity")) { 49 | myBot.sendMessage(msg.sender.id, humid); 50 | } 51 | if (msg.text.equalsIgnoreCase("Temperature")) { 52 | myBot.sendMessage(msg.sender.id, temp); 53 | } 54 | 55 | } 56 | 57 | delay(10); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Gas-Leakage-Alert-Notification-Using-Blynk-IOT/gas-leakage-alert-using-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL4raE8f18" 2 | #define BLYNK_DEVICE_NAME "Gas Leakage" 3 | #define BLYNK_AUTH_TOKEN "s-O1oO5G4Xgu7nndsffEPZ6HdD81V74ZQpFy" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | 10 | char auth[] = BLYNK_AUTH_TOKEN; 11 | 12 | char ssid[] = "Wifi Username"; // type your wifi name 13 | char pass[] = "Wifi Password"; // type your wifi password 14 | int smokeA0 = A0; 15 | int data = 0; 16 | int sensorThres = 100; 17 | 18 | 19 | BlynkTimer timer; 20 | 21 | void sendSensor(){ 22 | 23 | int data = analogRead(smokeA0); 24 | Blynk.virtualWrite(V0, data); 25 | Serial.print("Pin A0: "); 26 | Serial.println(data); 27 | 28 | 29 | if(data > 20){ 30 | //Blynk.email("test@gmail.com", "Alert", "Gas Leakage Detected!"); 31 | Blynk.logEvent("gas_alert","Gas Leakage Detected"); 32 | } 33 | } 34 | 35 | void setup(){ 36 | pinMode(smokeA0, INPUT); 37 | Serial.begin(115200); 38 | Blynk.begin(auth, ssid, pass); 39 | //dht.begin(); 40 | timer.setInterval(2500L, sendSensor); 41 | } 42 | 43 | void loop(){ 44 | Blynk.run(); 45 | timer.run(); 46 | } 47 | -------------------------------------------------------------------------------- /Gas-Level-Monitoring-and-Alert-Using-ESP8266-and-Blynk-IOT/gas-level-monitoring-and-alert-using-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3VCrufs4P" 2 | #define BLYNK_TEMPLATE_NAME "Gas Level Monitoring" 3 | #define BLYNK_AUTH_TOKEN "S0BiPAAvMZRDEssZfkfv2K7gaG2kWhkddmOX1r-" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | 10 | #include 11 | 12 | LiquidCrystal_I2C lcd(0x27, 16, 2); 13 | 14 | 15 | 16 | char auth[] = BLYNK_AUTH_TOKEN; 17 | 18 | char ssid[] = "WiFi Username"; // type your wifi name 19 | char pass[] = "WiFi Password"; // type your wifi password 20 | 21 | BlynkTimer timer; 22 | 23 | int GasSensor = A0; 24 | 25 | #define GreenLED D4 26 | #define RedLED D5 27 | #define Buzzer D6 28 | 29 | int sensorThreshold = 100; 30 | 31 | 32 | 33 | void sendSensor() 34 | { 35 | int gasValue = analogRead(GasSensor); 36 | Blynk.virtualWrite(V0, gasValue); 37 | Serial.print("Gas Value: "); 38 | Serial.println(gasValue); 39 | // You can send any value at any time. 40 | // Please don't send more that 10 values per second. 41 | 42 | if(gasValue<100) 43 | { 44 | digitalWrite(GreenLED, HIGH); 45 | digitalWrite(RedLED, LOW); 46 | digitalWrite(Buzzer, LOW); 47 | lcd.setCursor(0,0); 48 | lcd.print("Gas Value: "); 49 | lcd.print(gasValue); 50 | lcd.setCursor(0, 1); 51 | lcd.print("Gas Normal"); 52 | Serial.println("Gas Normal"); 53 | delay(4000); 54 | lcd.clear(); 55 | } 56 | else if(gasValue>100) 57 | { 58 | digitalWrite(GreenLED, LOW); 59 | digitalWrite(RedLED, HIGH); 60 | digitalWrite(Buzzer, HIGH); 61 | Blynk.logEvent("gas_alert","Gas is High"); 62 | lcd.setCursor(0,0); 63 | lcd.print(gasValue); 64 | lcd.setCursor(0, 1); 65 | lcd.print("Gas Value High"); 66 | Serial.println("Gas is High"); 67 | delay(4000); 68 | lcd.clear(); 69 | } 70 | 71 | 72 | 73 | } 74 | void setup() 75 | { 76 | 77 | Serial.begin(115200); 78 | 79 | pinMode(GasSensor, INPUT); 80 | pinMode(GreenLED, OUTPUT); 81 | pinMode(RedLED, OUTPUT); 82 | pinMode(Buzzer, OUTPUT); 83 | Blynk.begin(auth, ssid, pass); 84 | 85 | timer.setInterval(1000L, sendSensor); 86 | 87 | 88 | lcd.begin(); 89 | 90 | 91 | lcd.setCursor(3,0); 92 | lcd.print("Gas Level"); 93 | lcd.setCursor(3,1); 94 | lcd.print("Monitoring"); 95 | delay(2000); 96 | lcd.clear(); 97 | } 98 | 99 | void loop() 100 | { 101 | Blynk.run(); 102 | timer.run(); 103 | 104 | 105 | } 106 | -------------------------------------------------------------------------------- /Google-Assistant-Home-Automation/google-assistant-home-automation.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Google Assistant Home Automation Using ESP8266 3 | 4 | #include 5 | #include "Adafruit_MQTT.h" 6 | #include "Adafruit_MQTT_Client.h" 7 | 8 | #define led1 D1 9 | //#define led2 D2 10 | 11 | 12 | #define WLAN_SSID "WiFi Username" // Your SSID 13 | #define WLAN_PASS "WiFi Password" // Your password 14 | 15 | /************************* Adafruit.io Setup *********************************/ 16 | 17 | #define AIO_SERVER "io.adafruit.com" //Adafruit Server 18 | #define AIO_SERVERPORT 1883 19 | #define AIO_USERNAME "AIO_Username" // Username 20 | #define AIO_KEY "Auth Key" // Auth Key 21 | 22 | //WIFI CLIENT 23 | WiFiClient client; 24 | 25 | Adafruit_MQTT_Client mqtt(&client, AIO_SERVER, AIO_SERVERPORT, AIO_USERNAME, AIO_KEY); 26 | 27 | Adafruit_MQTT_Subscribe Light1 = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME"/feeds/light01"); // Feeds name should be same everywhere 28 | 29 | 30 | 31 | void MQTT_connect(); 32 | 33 | void setup() { 34 | Serial.begin(115200); 35 | 36 | pinMode(led1, OUTPUT); 37 | 38 | 39 | // Connect to WiFi access point. 40 | Serial.println(); Serial.println(); 41 | Serial.print("Connecting to "); 42 | Serial.println(WLAN_SSID); 43 | 44 | WiFi.begin(WLAN_SSID, WLAN_PASS); 45 | while (WiFi.status() != WL_CONNECTED) { 46 | delay(500); 47 | Serial.print("."); 48 | } 49 | Serial.println(); 50 | 51 | Serial.println("WiFi connected"); 52 | Serial.println("IP address: "); 53 | Serial.println(WiFi.localIP()); 54 | 55 | mqtt.subscribe(&Light1); 56 | 57 | } 58 | 59 | void loop() { 60 | 61 | MQTT_connect(); 62 | 63 | 64 | Adafruit_MQTT_Subscribe *subscription; 65 | while ((subscription = mqtt.readSubscription(20000))) { 66 | if (subscription == &Light1) { 67 | Serial.print(F("Got: ")); 68 | Serial.println((char *)Light1.lastread); 69 | int Light1_State = atoi((char *)Light1.lastread); 70 | digitalWrite(led1, Light1_State); 71 | 72 | } 73 | 74 | } 75 | 76 | 77 | } 78 | 79 | void MQTT_connect() { 80 | int8_t ret; 81 | 82 | if (mqtt.connected()) { 83 | return; 84 | } 85 | 86 | Serial.print("Connecting to MQTT... "); 87 | 88 | uint8_t retries = 3; 89 | 90 | while ((ret = mqtt.connect()) != 0) { 91 | Serial.println(mqtt.connectErrorString(ret)); 92 | Serial.println("Retrying MQTT connection in 5 seconds..."); 93 | mqtt.disconnect(); 94 | delay(5000); 95 | retries--; 96 | if (retries == 0) { 97 | while (1); 98 | } 99 | } 100 | Serial.println("MQTT Connected!"); 101 | 102 | } 103 | -------------------------------------------------------------------------------- /Home-Automation-Using-Arduino-IOT-Cloud-ESP-8266/arduino_secrets.h: -------------------------------------------------------------------------------- 1 | #define SECRET_SSID "" 2 | #define SECRET_PASS "" 3 | #define SECRET_DEVICE_KEY "" 4 | -------------------------------------------------------------------------------- /Home-Automation-Using-Arduino-IOT-Cloud-ESP-8266/home-automation-using-arduino-iot-cloud-esp-8266.ino: -------------------------------------------------------------------------------- 1 | #include "arduino_secrets.h" 2 | /* 3 | Sketch generated by the Arduino IoT Cloud Thing "Untitled" 4 | https://create.arduino.cc/cloud/things/1010f446-2822-44f7-8522-62bf7e3af785 5 | 6 | Arduino IoT Cloud Variables description 7 | 8 | The following variables are automatically generated and updated when changes are made to the Thing 9 | 10 | bool light; 11 | 12 | Variables which are marked as READ/WRITE in the Cloud Thing will also have functions 13 | which are called when their values are changed from the Dashboard. 14 | These functions are generated with the Thing and added at the end of this sketch. 15 | */ 16 | 17 | #include "thingProperties.h" 18 | const int switch1=2; 19 | 20 | void setup() { 21 | // Initialize serial and wait for port to open: 22 | Serial.begin(9600); 23 | // This delay gives the chance to wait for a Serial Monitor without blocking if none is found 24 | delay(1500); 25 | pinMode(switch1,OUTPUT); 26 | // Defined in thingProperties.h 27 | initProperties(); 28 | 29 | // Connect to Arduino IoT Cloud 30 | ArduinoCloud.begin(ArduinoIoTPreferredConnection); 31 | 32 | /* 33 | The following function allows you to obtain more information 34 | related to the state of network and IoT Cloud connection and errors 35 | the higher number the more granular information you’ll get. 36 | The default is 0 (only errors). 37 | Maximum is 4 38 | */ 39 | setDebugMessageLevel(2); 40 | ArduinoCloud.printDebugInfo(); 41 | } 42 | 43 | void loop() { 44 | ArduinoCloud.update(); 45 | // Your code here 46 | 47 | 48 | } 49 | 50 | 51 | /* 52 | Since Light is READ_WRITE variable, onLightChange() is 53 | executed every time a new value is received from IoT Cloud. 54 | */ 55 | void onLightChange() { 56 | // Add your code here to act upon Light change 57 | 58 | if(light) 59 | { 60 | digitalWrite(switch1,HIGH); 61 | Serial.println("ON"); 62 | } 63 | else 64 | { 65 | digitalWrite(switch1,LOW); 66 | Serial.println("OFF"); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Home-Automation-Using-Arduino-IOT-Cloud-ESP-8266/sketch.json: -------------------------------------------------------------------------------- 1 | { 2 | "cpu": { 3 | "fqbn": "esp8266:esp8266:nodemcuv2:baud=115200,dbg=Disabled,eesz=4M,exception=disabled,ip=lm2f,lvl=None____,vt=flash,wipe=none,xtal=80", 4 | "name": "NodeMCU 1.0 (ESP-12E Module)", 5 | "type": "serial" 6 | }, 7 | "secrets": [ 8 | { 9 | "name": "SECRET_SSID", 10 | "value": "" 11 | }, 12 | { 13 | "name": "SECRET_PASS", 14 | "value": "" 15 | }, 16 | { 17 | "name": "SECRET_DEVICE_KEY", 18 | "value": "" 19 | } 20 | ], 21 | "included_libs": [] 22 | } 23 | -------------------------------------------------------------------------------- /Home-Automation-Using-Arduino-IOT-Cloud-ESP-8266/thingProperties.h: -------------------------------------------------------------------------------- 1 | // Code generated by Arduino IoT Cloud, DO NOT EDIT. 2 | 3 | #include 4 | #include 5 | 6 | const char DEVICE_LOGIN_NAME[] = "4csfgbac97a-c2aa-4032-8c8f-188c67cdfdfhhh2e88c"; 7 | 8 | const char SSID[] = SECRET_SSID; // Network SSID (name) 9 | const char PASS[] = SECRET_PASS; // Network password (use for WPA, or use as key for WEP) 10 | const char DEVICE_KEY[] = SECRET_DEVICE_KEY; // Secret device password 11 | 12 | void onLightChange(); 13 | 14 | bool light; 15 | 16 | void initProperties(){ 17 | 18 | ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME); 19 | ArduinoCloud.setSecretDeviceKey(DEVICE_KEY); 20 | ArduinoCloud.addProperty(light, READWRITE, ON_CHANGE, onLightChange); 21 | 22 | } 23 | 24 | WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS); 25 | -------------------------------------------------------------------------------- /Home-Automation-Using-Blynk-iot/home-automation-using-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPLZdgdgOwummO6" 2 | #define BLYNK_DEVICE_NAME "Control Electric Bulb" 3 | #define BLYNK_AUTH_TOKEN "5_S4mjFLbdfdggg7jZhdLDjgZxpKTWh_23liU4" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | 8 | #include 9 | 10 | 11 | char auth[] = BLYNK_AUTH_TOKEN; 12 | 13 | char ssid[] = ""; // type your wifi name 14 | char pass[] = ""; // type your wifi password 15 | 16 | int relaypin = D4; 17 | void setup() 18 | { 19 | Serial.begin(115200); 20 | Blynk.begin(auth, ssid, pass); 21 | pinMode(relaypin,OUTPUT); 22 | 23 | } 24 | 25 | void loop() 26 | { 27 | Blynk.run(); 28 | } 29 | -------------------------------------------------------------------------------- /Home-Automation-Using-ESP8266-and-Blynk-IoT/home-automation-using-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3UPPImTJH" 2 | #define BLYNK_TEMPLATE_NAME "Home Automation Using ESP8266" 3 | #define BLYNK_AUTH_TOKEN "VngJ1GCIF0KAR-XBQr35RIRoMSddb22e" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | 8 | #include 9 | 10 | 11 | char auth[] = BLYNK_AUTH_TOKEN; 12 | 13 | char ssid[] = "JioFi2_D08135"; // type your wifi name 14 | char pass[] = "WiFi Password"; // type your wifi password 15 | 16 | int relaypin1 = D1; //Connect to Pin D1 in NodeMCU 17 | int relaypin2 = D2; //Connect to Pin D2 in NodeMCU 18 | int relaypin3 = D3; //Connect to Pin D3 in NodeMCU 19 | int relaypin4 = D4; //Connect to Pin D4 in NodeMCU 20 | void setup() 21 | { 22 | Serial.begin(115200); 23 | Blynk.begin(auth, ssid, pass); 24 | pinMode(relaypin1,OUTPUT); 25 | pinMode(relaypin2,OUTPUT); 26 | pinMode(relaypin3,OUTPUT); 27 | pinMode(relaypin4,OUTPUT); 28 | 29 | } 30 | 31 | void loop() 32 | { 33 | Blynk.run(); 34 | } 35 | -------------------------------------------------------------------------------- /Home-Automation-with-WhatsApp-and-ESP8266/home-automation-with-whatsapp-and-esp8266.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | ThingESP8266 thing("techtrends", "HomeAutomation", "techtrends"); 5 | 6 | int LIGHT1 = D1; 7 | int LIGHT2 = D2; 8 | int LIGHT3 = D3; 9 | int LIGHT4 = D4; 10 | 11 | unsigned long previousMillis = 0; 12 | const long INTERVAL = 6000; 13 | 14 | void setup() 15 | { 16 | Serial.begin(115200); 17 | pinMode(LIGHT1, OUTPUT); 18 | pinMode(LIGHT2, OUTPUT); 19 | pinMode(LIGHT3, OUTPUT); 20 | pinMode(LIGHT4, OUTPUT); 21 | thing.SetWiFi("WiFi Username", "WiFi Password"); 22 | thing.initDevice(); 23 | } 24 | 25 | 26 | String HandleResponse(String query) 27 | { 28 | if (query == "light1 on") { 29 | digitalWrite(LIGHT1, 1); 30 | return "Done: Light1 Turned ON"; 31 | } 32 | 33 | else if (query == "light1 off") { 34 | digitalWrite(LIGHT1, 0); 35 | return "Done: Light1 Turned OFF"; 36 | } 37 | 38 | if (query == "light2 on") { 39 | digitalWrite(LIGHT2, 1); 40 | return "Done: Light2 Turned ON"; 41 | } 42 | 43 | else if (query == "light2 off") { 44 | digitalWrite(LIGHT2, 0); 45 | return "Done: Light2 Turned OFF"; 46 | } 47 | 48 | if (query == "light3 on") { 49 | digitalWrite(LIGHT3, 1); 50 | return "Done: Light3 Turned ON"; 51 | } 52 | 53 | else if (query == "light3 off") { 54 | digitalWrite(LIGHT3, 0); 55 | return "Done: Light3 Turned OFF"; 56 | } 57 | 58 | if (query == "light4 on") { 59 | digitalWrite(LIGHT4, 1); 60 | return "Done: Light4 Turned ON"; 61 | } 62 | 63 | else if (query == "light4 off") { 64 | digitalWrite(LIGHT4, 0); 65 | return "Done: Light4 Turned OFF"; 66 | } 67 | 68 | //else if (query == "light status") 69 | // return digitalRead(LIGHT) ? "LIGHT is OFF" : "LIGHT is ON"; 70 | else return "Your query was invalid.."; 71 | 72 | } 73 | 74 | 75 | void loop() 76 | { 77 | thing.Handle(); 78 | 79 | } 80 | -------------------------------------------------------------------------------- /How-to-Store-Temperature-Pressure-Altitude-in-Google-Spreadsheet/GoogleScript.gs: -------------------------------------------------------------------------------- 1 | // Created by Sujay S. Phadke, 2017 2 | // All Rights Reserved. 3 | // Github: https://github.com/electronicsguy 4 | // 5 | // Read/Write to Google Sheets using REST API. 6 | // Can be used with ESP8266 & other embedded IoT devices. 7 | // 8 | // Use this file with the ESP8266 library HTTPSRedirect 9 | // 10 | // doGet() and doPost() need the spreadsheet ID. Cannot use "active spreadsheet" here since 11 | // the device can operate without the spreadsheet even being open. 12 | // http://stackoverflow.com/questions/4024271/rest-api-best-practices-where-to-put-parameters 13 | // http://trevorfox.com/2015/03/rest-api-with-google-apps-script 14 | 15 | // Similar API docs: 16 | // https://gspread.readthedocs.org/en/latest/ 17 | // https://smartsheet-platform.github.io/api-docs/#versioning-and-changes 18 | // http://search.cpan.org/~jmcnamara/Excel-Writer-XLSX/lib/Excel/Writer/XLSX.pm 19 | 20 | // http://forum.espruino.com/conversations/269510/ 21 | // http://stackoverflow.com/questions/34691425/difference-between-getvalue-and-getdisplayvalue-on-google-app-script 22 | // http://ramblings.mcpher.com/Home/excelquirks/gooscript/optimize 23 | 24 | // Things to remember with getValue() object format: 25 | // 1. Partial dates or times-only will be replaced with a full date + time, probably in the 26 | // year 1989. Like this: Sat Dec 30 1899 08:09:00 GMT-0500 (EST) 27 | // 2. Dollar ($) currency symbol will be absent if cell contains currency. 28 | // This may be locale-dependent. 29 | // 3. Scientific notation will be replaced by decimal numbers like this: 0.0000055 30 | 31 | // Script examples 32 | // https://developers.google.com/adwords/scripts/docs/examples/spreadsheetapp 33 | 34 | var SS = SpreadsheetApp.openById('1dMf0z7_oTz46BsPUsNT8jEBhHTC9asGkdhjjeeczllddfJgot1MA'); //Enter Your Sheet ID Got From Sheet URL Link 35 | var sheet = SS.getSheetByName('BMP280_Data_Sheet'); // Enter your sheet name here, In my case it is Temp_Data_Sheet 36 | var str = ""; 37 | 38 | function onOpen(){ 39 | var ui = SpreadsheetApp.getUi(); 40 | ui.createMenu('ESP8266_BMP280_Data_Logger') 41 | .addItem('Clear', 'Clear') 42 | .addToUi(); 43 | } 44 | 45 | function Clear(){ 46 | sheet.deleteRows(4, sheet.getLastRow()); 47 | SS.toast('Chart cleared', 'ESP8266_BMP280_Data_Logger', 5); 48 | } 49 | 50 | function doPost(e) { 51 | 52 | var parsedData; 53 | var result = {}; 54 | 55 | try { 56 | parsedData = JSON.parse(e.postData.contents); 57 | } 58 | catch(f){ 59 | return ContentService.createTextOutput("Error in parsing request body: " + f.message); 60 | } 61 | 62 | if (parsedData !== undefined){ 63 | // Common items first 64 | // data format: 0 = display value(literal), 1 = object value 65 | var flag = parsedData.format; 66 | 67 | if (flag === undefined){ 68 | flag = 0; 69 | } 70 | 71 | switch (parsedData.command) { 72 | case "appendRow": 73 | var tmp = SS.getSheetByName(parsedData.sheet_name); 74 | var nextFreeRow = tmp.getLastRow() + 1; 75 | var dataArr = parsedData.values.split(","); 76 | 77 | tmp.appendRow(dataArr); 78 | 79 | str = "Success"; 80 | SpreadsheetApp.flush(); 81 | break; 82 | 83 | 84 | } 85 | 86 | return ContentService.createTextOutput(str); 87 | } // endif (parsedData !== undefined) 88 | 89 | else{ 90 | return ContentService.createTextOutput("Error! Request body empty or in incorrect format."); 91 | } 92 | 93 | 94 | } 95 | 96 | 97 | function doGet(e){ 98 | 99 | var val = e.parameter.value; 100 | var cal = e.parameter.cal; 101 | var read = e.parameter.read; 102 | 103 | if (cal !== undefined){ 104 | return ContentService.createTextOutput(GetEventsOneWeek()); 105 | } 106 | 107 | if (read !== undefined){ 108 | var now = Utilities.formatDate(new Date(), "EST", "yyyy-MM-dd'T'hh:mm a'Z'").slice(11,19); 109 | //sheet.getRange('D1').setValue(now); 110 | //var count = (sheet.getRange('C1').getValue()) + 1; 111 | sheet.getRange('C1').setValue(count); 112 | return ContentService.createTextOutput(sheet.getRange('A1').getValue()); 113 | } 114 | 115 | if (e.parameter.value === undefined) 116 | return ContentService.createTextOutput("No value passed as argument to script Url."); 117 | 118 | var range = sheet.getRange('A1'); 119 | var retval = range.setValue(val).getValue(); 120 | var now = Utilities.formatDate(new Date(), "EST", "yyyy-MM-dd'T'hh:mm a'Z'").slice(11,19); 121 | // sheet.getRange('B1').setValue(now); 122 | sheet.getRange('B1').setValue("Pressure"); 123 | sheet.getRange('C1').setValue("Altitude"); 124 | //sheet.getRange('C1').setValue('0'); 125 | 126 | if (retval == e.parameter.value) 127 | return ContentService.createTextOutput("Successfully wrote: " + e.parameter.value + "\ninto spreadsheet."); 128 | else 129 | return ContentService.createTextOutput("Unable to write into spreadsheet.\nCheck authentication and make sure the cursor is not on cell 'A1'." + retval + ' ' + e.parameter.value); 130 | } 131 | 132 | function GetEventsOneWeek(){ 133 | var Cal = CalendarApp.getCalendarsByName('Test REST API')[0]; 134 | // Need to create 2 separate Date() objects. Cannot do 'OneWeekFromNow = Nowjs' to 135 | // simply get it's value and use that later without modifying 'Now' 136 | // since in JS, an object is automatically passed by reference 137 | var Now = new Date(); 138 | var OneWeekFromNow = new Date(); 139 | OneWeekFromNow.setDate(Now.getDate() + 7); 140 | //Logger.log(Now); 141 | //Logger.log(OneWeekFromNow); 142 | var events = Cal.getEvents(Now, OneWeekFromNow); 143 | //Logger.log(events.length); 144 | var str = '\nEvent Title,\tDescription,\tRecurring?,\tAll-day?,\tFirst Reminder (in minutes before event)\n'; 145 | for (var i = 0; i < events.length; i++){ 146 | str += events[i].getTitle() + ',\t' + events[i].getDescription() + ',\t' + events[i].isRecurringEvent() + ',\t' + events[i].isAllDayEvent() + ',\t' + events[i].getPopupReminders()[0]; 147 | str += '\n'; 148 | } 149 | //Logger.log(str); 150 | return str; 151 | } 152 | -------------------------------------------------------------------------------- /IoT-Agriculture-Monitoring-System/iot-agriculture-monitoring-system.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3OSKgku4doR" 2 | #define BLYNK_TEMPLATE_NAME "IOT Based Agriculture System" 3 | #define BLYNK_AUTH_TOKEN "fQrObEhbsdf10MGJbaIbsDUoqkdlghutyyMJHg7HmTJ" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | #include 9 | #include // Include the I2C LCD library 10 | 11 | #define SOIL_MOISTURE_PIN A0 12 | #define THRESHOLD_MOISTURE 10 13 | #define PUMP_PIN D1 14 | #define PUMP_SWITCH V6 15 | #define DHT_PIN D2 16 | #define DHT_TYPE DHT11 17 | #define RAIN_SENSOR_PIN A0 18 | 19 | char auth[] = BLYNK_AUTH_TOKEN; 20 | char ssid[] = "WiFi Username"; 21 | char pass[] = "WiFi Password"; 22 | 23 | DHT dht(DHT_PIN, DHT_TYPE); 24 | LiquidCrystal_I2C lcd(0x27, 16, 2); // Change the address to your LCD's address 25 | 26 | BlynkTimer timer; 27 | 28 | bool isPumpOn = false; 29 | 30 | int temt6000Pin = A0; 31 | float light; 32 | int light_value; 33 | 34 | void sendSensorData() 35 | { 36 | int soilMoisture = analogRead(SOIL_MOISTURE_PIN); 37 | int soilMoisturePercentage = map(soilMoisture, 400, 1023, 100, 0); 38 | Serial.print("Soil Moisture Percentage "); 39 | Serial.println(soilMoisturePercentage); 40 | float temperature = dht.readTemperature(); 41 | float humidity = dht.readHumidity(); 42 | Serial.print("Temperature"); 43 | Serial.println(temperature); 44 | Serial.print("Humidity"); 45 | Serial.println(humidity); 46 | if (!isnan(temperature) && !isnan(humidity)) 47 | { 48 | Blynk.virtualWrite(V0, temperature); 49 | Blynk.virtualWrite(V1, humidity); 50 | } 51 | else 52 | { 53 | Serial.println("Failed to read data from DHT sensor!"); 54 | } 55 | Blynk.virtualWrite(V2, soilMoisturePercentage); 56 | 57 | int rainsensorValue = analogRead(RAIN_SENSOR_PIN); 58 | int rainValue = map(rainsensorValue, 400, 1023, 100, 0); 59 | 60 | Serial.print("Rain Sensor Value: "); 61 | Serial.println(rainValue); 62 | Blynk.virtualWrite(V4, rainValue); // Send rain sensor value to Blynk 63 | 64 | light_value = analogRead(temt6000Pin); 65 | light = light_value * 0.0976; // percentage calculation 66 | Serial.print("Light"); 67 | Serial.println(light); 68 | //Blynk.virtualWrite(V3, light_value); // Send raw light value to Blynk 69 | Blynk.virtualWrite(V3, light); // Send light percentage to Blynk 70 | 71 | lcd.clear(); 72 | lcd.setCursor(0, 0); 73 | lcd.print("Soil Moisture: "); 74 | lcd.print(soilMoisturePercentage); 75 | lcd.print("%"); 76 | lcd.setCursor(0, 1); 77 | lcd.print("Temp: "); 78 | lcd.print(temperature); 79 | lcd.print("C"); 80 | lcd.setCursor(10, 1); 81 | lcd.print("Humidity: "); 82 | lcd.print(humidity); 83 | lcd.print("%"); 84 | lcd.setCursor(0, 2); 85 | lcd.print("Rain Sensor: "); 86 | lcd.print(rainValue); 87 | lcd.print(" "); 88 | 89 | lcd.setCursor(0, 3); 90 | lcd.print("Light Intensity: "); 91 | lcd.print(light_value); // Display raw light value 92 | lcd.print(" | "); 93 | lcd.print(light); // Display light percentage 94 | 95 | 96 | if (isPumpOn || soilMoisturePercentage < THRESHOLD_MOISTURE || rainValue > 500) 97 | { 98 | digitalWrite(PUMP_PIN, HIGH); 99 | if (!isPumpOn) 100 | { 101 | Blynk.logEvent("moisture_alert", "Soil moisture is below the threshold!"); 102 | Serial.println("Soil moisture is below the threshold!"); 103 | } 104 | } 105 | else 106 | { 107 | if (!isPumpOn) 108 | { 109 | digitalWrite(PUMP_PIN, LOW); 110 | } 111 | } 112 | } 113 | 114 | BLYNK_WRITE(PUMP_SWITCH) 115 | { 116 | isPumpOn = param.asInt(); 117 | if (isPumpOn) 118 | { 119 | Serial.println("Pump manually turned ON"); 120 | } 121 | else 122 | { 123 | Serial.println("Pump manually turned OFF"); 124 | } 125 | } 126 | 127 | void setup() 128 | { 129 | Serial.begin(9600); 130 | pinMode(PUMP_PIN, OUTPUT); 131 | pinMode(RAIN_SENSOR_PIN, INPUT); 132 | dht.begin(); 133 | 134 | lcd.begin(); // Initialize LCD 135 | //lcd.backlight(); 136 | 137 | Blynk.begin(auth, ssid, pass); 138 | 139 | timer.setInterval(3000L, sendSensorData); 140 | 141 | Blynk.virtualWrite(PUMP_SWITCH, isPumpOn); 142 | Blynk.syncVirtual(PUMP_SWITCH); 143 | } 144 | 145 | void loop() 146 | { 147 | Blynk.run(); 148 | timer.run(); 149 | } 150 | -------------------------------------------------------------------------------- /IoT-Based-Agricultural-System/iot-based-agricultural-system.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3OSKg4doR" 2 | #define BLYNK_TEMPLATE_NAME "IOT Based Agriculture System" 3 | #define BLYNK_AUTH_TOKEN "fQrObEhb10fdjMGJbdfaIbsvfDjdwyUojqkyMJHfghj7HmTJ" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | #include 9 | #include // Include the I2C LCD library 10 | 11 | #define SOIL_MOISTURE_PIN A0 12 | #define THRESHOLD_MOISTURE 10 13 | #define PUMP_PIN D1 14 | #define PUMP_SWITCH V6 15 | #define DHT_PIN D2 16 | #define DHT_TYPE DHT11 17 | #define RAIN_SENSOR_PIN A0 18 | 19 | char auth[] = BLYNK_AUTH_TOKEN; 20 | char ssid[] = "WiFi Username"; 21 | char pass[] = "WiFi Password"; 22 | 23 | DHT dht(DHT_PIN, DHT_TYPE); 24 | LiquidCrystal_I2C lcd(0x27, 16, 2); // Change the address to your LCD's address 25 | 26 | BlynkTimer timer; 27 | 28 | bool isPumpOn = false; 29 | 30 | int temt6000Pin = A0; 31 | float light; 32 | int light_value; 33 | 34 | void sendSensorData() 35 | { 36 | int soilMoisture = analogRead(SOIL_MOISTURE_PIN); 37 | int soilMoisturePercentage = map(soilMoisture, 400, 1023, 100, 0); 38 | Serial.print("Soil Moisture Percentage "); 39 | Serial.println(soilMoisturePercentage); 40 | float temperature = dht.readTemperature(); 41 | float humidity = dht.readHumidity(); 42 | Serial.print("Temperature"); 43 | Serial.println(temperature); 44 | Serial.print("Humidity"); 45 | Serial.println(humidity); 46 | if (!isnan(temperature) && !isnan(humidity)) 47 | { 48 | Blynk.virtualWrite(V0, temperature); 49 | Blynk.virtualWrite(V1, humidity); 50 | } 51 | else 52 | { 53 | Serial.println("Failed to read data from DHT sensor!"); 54 | } 55 | Blynk.virtualWrite(V2, soilMoisturePercentage); 56 | 57 | int rainsensorValue = analogRead(RAIN_SENSOR_PIN); 58 | int rainValue = map(rainsensorValue, 400, 1023, 100, 0); 59 | 60 | Serial.print("Rain Sensor Value: "); 61 | Serial.println(rainValue); 62 | Blynk.virtualWrite(V4, rainValue); // Send rain sensor value to Blynk 63 | 64 | light_value = analogRead(temt6000Pin); 65 | light = light_value * 0.0976; // percentage calculation 66 | Serial.print("Light"); 67 | Serial.println(light); 68 | //Blynk.virtualWrite(V3, light_value); // Send raw light value to Blynk 69 | Blynk.virtualWrite(V3, light); // Send light percentage to Blynk 70 | 71 | lcd.clear(); 72 | lcd.setCursor(0, 0); 73 | lcd.print("Soil Moisture: "); 74 | lcd.print(soilMoisturePercentage); 75 | lcd.print("%"); 76 | lcd.setCursor(0, 1); 77 | lcd.print("Temp: "); 78 | lcd.print(temperature); 79 | lcd.print("C"); 80 | lcd.setCursor(10, 1); 81 | lcd.print("Humidity: "); 82 | lcd.print(humidity); 83 | lcd.print("%"); 84 | lcd.setCursor(0, 2); 85 | lcd.print("Rain Sensor: "); 86 | lcd.print(rainValue); 87 | lcd.print(" "); 88 | 89 | lcd.setCursor(0, 3); 90 | lcd.print("Light Intensity: "); 91 | lcd.print(light_value); // Display raw light value 92 | lcd.print(" | "); 93 | lcd.print(light); // Display light percentage 94 | 95 | 96 | if (isPumpOn || soilMoisturePercentage < THRESHOLD_MOISTURE || rainValue > 500) 97 | { 98 | digitalWrite(PUMP_PIN, HIGH); 99 | if (!isPumpOn) 100 | { 101 | Blynk.logEvent("moisture_alert", "Soil moisture is below the threshold!"); 102 | Serial.println("Soil moisture is below the threshold!"); 103 | } 104 | } 105 | else 106 | { 107 | if (!isPumpOn) 108 | { 109 | digitalWrite(PUMP_PIN, LOW); 110 | } 111 | } 112 | } 113 | 114 | BLYNK_WRITE(PUMP_SWITCH) 115 | { 116 | isPumpOn = param.asInt(); 117 | if (isPumpOn) 118 | { 119 | Serial.println("Pump manually turned ON"); 120 | } 121 | else 122 | { 123 | Serial.println("Pump manually turned OFF"); 124 | } 125 | } 126 | 127 | void setup() 128 | { 129 | Serial.begin(9600); 130 | pinMode(PUMP_PIN, OUTPUT); 131 | pinMode(RAIN_SENSOR_PIN, INPUT); 132 | dht.begin(); 133 | 134 | lcd.begin(); // Initialize LCD 135 | //lcd.backlight(); 136 | 137 | Blynk.begin(auth, ssid, pass); 138 | 139 | timer.setInterval(3000L, sendSensorData); 140 | 141 | Blynk.virtualWrite(PUMP_SWITCH, isPumpOn); 142 | Blynk.syncVirtual(PUMP_SWITCH); 143 | } 144 | 145 | void loop() 146 | { 147 | Blynk.run(); 148 | timer.run(); 149 | } 150 | -------------------------------------------------------------------------------- /Noise-Pollution-Monitoring-with-ESP8266-and-Blynk-IoT/noise-pollution-monitoring-with-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL31kVdgJmv" 2 | #define BLYNK_TEMPLATE_NAME "Noise Pollution Monitoring" 3 | #define BLYNK_AUTH_TOKEN "dp0J9sdfNlZkPVgaS4dgilKCgzpRSMgYfAgddX-lg" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | #include 9 | #define SENSOR_PIN A0 10 | LiquidCrystal_I2C lcd(0x27, 16, 2); 11 | const int sampleWindow = 50; 12 | unsigned int sample; 13 | int db; 14 | char auth[] = BLYNK_AUTH_TOKEN; 15 | char ssid[] = "WiFi Username"; 16 | char pass[] = "WiFi Password"; 17 | //BLYNK_READ(V0) 18 | //{ 19 | 20 | //} 21 | void setup() { 22 | Serial.begin(115200); 23 | pinMode (SENSOR_PIN, INPUT); 24 | lcd.begin(); 25 | lcd.backlight(); 26 | 27 | // Display "Tech Trends Shameer" 28 | lcd.setCursor(3, 0); 29 | lcd.print("Tech Trends "); 30 | lcd.setCursor(3, 1); 31 | lcd.print(" Shameer "); 32 | delay(2000); // Wait for 3 seconds 33 | 34 | // Clear the LCD and display "Noise Pollution Monitoring" 35 | lcd.clear(); 36 | lcd.setCursor(1, 0); 37 | lcd.print("Noise Pollution "); 38 | lcd.setCursor(3, 1); 39 | lcd.print("Monitoring "); 40 | 41 | 42 | delay(2000); 43 | lcd.clear(); 44 | 45 | lcd.clear(); 46 | Blynk.begin(auth, ssid, pass); 47 | Blynk.virtualWrite(V0, db); 48 | } 49 | void loop() { 50 | Blynk.run(); 51 | unsigned long startMillis = millis(); // Start of sample window 52 | float peakToPeak = 0; // peak-to-peak level 53 | unsigned int signalMax = 0; //minimum value 54 | unsigned int signalMin = 1024; //maximum value 55 | // collect data for 50 mS 56 | while (millis() - startMillis < sampleWindow) 57 | { 58 | sample = analogRead(SENSOR_PIN); //get reading from microphone 59 | if (sample < 1024) // toss out spurious readings 60 | { 61 | if (sample > signalMax) 62 | { 63 | signalMax = sample; // save just the max levels 64 | } 65 | else if (sample < signalMin) 66 | { 67 | signalMin = sample; // save just the min levels 68 | } 69 | } 70 | } 71 | peakToPeak = signalMax - signalMin; // max - min = peak-peak amplitude 72 | Serial.println(peakToPeak); 73 | db = map(peakToPeak, 20, 900, 0, 90); //calibrate for deciBels 74 | // db = map(peakToPeak, 20, 900, 49.5, 90); //calibrate for deciBels 75 | // Blynk.virtualWrite(V0, db); 76 | lcd.setCursor(0, 0); 77 | lcd.print("Loudness: "); 78 | lcd.print(db); 79 | lcd.print("dB"); 80 | if (db <= 50) 81 | { 82 | lcd.setCursor(0, 1); 83 | lcd.print("Level: Quite"); 84 | Serial.println("Level: Quite"); 85 | Serial.println(db); 86 | } 87 | else if (db > 50 && db < 75) 88 | { 89 | lcd.setCursor(0, 1); 90 | lcd.print("Level: Moderate"); 91 | Serial.println("Level: Moderate"); 92 | Serial.println(db); 93 | } 94 | else if (db >= 75) 95 | { 96 | lcd.setCursor(0, 1); 97 | lcd.print("Level: High"); 98 | Serial.println("Level: High"); 99 | Serial.println(db); 100 | } 101 | delay(600); 102 | Blynk.virtualWrite(V0, db); 103 | lcd.clear(); 104 | } 105 | -------------------------------------------------------------------------------- /Patient-Health-Monitoring-System-with-ESP8266-and-Blynk-IoT/patient-health-monitoring-system-with-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_PRINT Serial 2 | 3 | #define BLYNK_TEMPLATE_ID "TMPL3hHougpcA" 4 | #define BLYNK_TEMPLATE_NAME "Patient Health Monitoring" 5 | #define BLYNK_AUTH_TOKEN "XON3QXXdSNp7BPv-58bstihYRGe42l137ZpV4w" 6 | 7 | #include 8 | #include "MAX30100_PulseOximeter.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define REPORTING_PERIOD_MS 1000 16 | LiquidCrystal_I2C lcd(0x27, 16, 2); 17 | 18 | #define DHTPIN 2 // Pin which is connected to the DHT sensor. 19 | #define DHTTYPE DHT11 // DHT 11 20 | 21 | DHT dht(DHTPIN, DHTTYPE); 22 | 23 | char auth[] = BLYNK_AUTH_TOKEN; // You should get Auth Token in the Blynk App. 24 | char ssid[] = "WiFi Username"; // Your WiFi credentials. 25 | char pass[] = "WiFi Password"; 26 | 27 | // Connections : SCL PIN - D22 , SDA PIN - D21 , INT PIN - D0 28 | PulseOximeter pox; 29 | 30 | int BPM, SpO2, humidity, temperature;; 31 | uint32_t tsLastReport = 0; 32 | 33 | 34 | void onBeatDetected() 35 | { 36 | Serial.println("Beat Detected!"); 37 | } 38 | 39 | void setup() 40 | { 41 | Serial.begin(115200); 42 | 43 | pinMode(19, OUTPUT); 44 | Blynk.begin(auth, ssid, pass); 45 | 46 | Serial.print("Initializing Pulse Oximeter.."); 47 | lcd.begin(); 48 | lcd.backlight(); 49 | 50 | // Display "Tech Trends Shameer" 51 | lcd.setCursor(3, 0); 52 | lcd.print("Tech Trends "); 53 | lcd.setCursor(3, 1); 54 | lcd.print(" Shameer "); 55 | delay(2000); // Wait for 3 seconds 56 | 57 | // Clear the LCD and display "Pulse Oximeter" 58 | lcd.clear(); 59 | lcd.setCursor(1, 0); 60 | lcd.print("Patient Health "); 61 | lcd.setCursor(3, 1); 62 | lcd.print("Monitoring "); 63 | lcd.setCursor(12, 0); // Adjust the position for the heart symbol 64 | 65 | delay(2000); 66 | lcd.clear(); 67 | 68 | if (!pox.begin()) 69 | { 70 | Serial.println("FAILED"); 71 | for(;;); 72 | } 73 | else 74 | { 75 | Serial.println("SUCCESS"); 76 | pox.setOnBeatDetectedCallback(onBeatDetected); 77 | } 78 | 79 | // The default current for the IR LED is 50mA and it could be changed by uncommenting the following line. 80 | pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA); 81 | 82 | } 83 | 84 | void loop() 85 | { 86 | pox.update(); 87 | Blynk.run(); 88 | 89 | BPM = pox.getHeartRate(); 90 | SpO2 = pox.getSpO2(); 91 | humidity = dht.readHumidity(); 92 | temperature = dht.readTemperature(); 93 | 94 | 95 | 96 | 97 | if (millis() - tsLastReport > REPORTING_PERIOD_MS) 98 | { 99 | //lcd.clear(); 100 | lcd.setCursor(0 , 0); 101 | lcd.print("BPM:"); 102 | lcd.print(pox.getHeartRate()); 103 | //lcd.setCursor(10, 0); // Adjust the position for the heart symbol 104 | lcd.setCursor(0 , 1); 105 | lcd.print("Sp02:"); 106 | lcd.print(pox.getSpO2()); 107 | lcd.print("%"); 108 | //tsLastReport = millis(); 109 | 110 | Serial.print("Heart rate:"); 111 | Serial.print(BPM); 112 | Serial.print(" bpm / SpO2:"); 113 | Serial.print(SpO2); 114 | Serial.println(" %"); 115 | 116 | 117 | //tsLastReport = millis(); 118 | 119 | 120 | Serial.print("Humidity: "); 121 | Serial.print(humidity); 122 | Serial.print(" %\t"); 123 | Serial.print("Temp: "); 124 | Serial.print(temperature); 125 | Serial.println(" *C"); 126 | //lcd.clear(); 127 | lcd.setCursor(9 , 0); 128 | lcd.print("T: "); 129 | lcd.print(temperature); 130 | lcd.print((char)223); 131 | lcd.print("C"); 132 | //lcd.setCursor(10, 0); // Adjust the position for the heart symbol 133 | lcd.setCursor(9 , 1); 134 | lcd.print("H: "); 135 | lcd.print(humidity); 136 | lcd.print("% "); 137 | Blynk.virtualWrite(V1, BPM); 138 | Blynk.virtualWrite(V2, SpO2); 139 | Blynk.virtualWrite(V3, temperature); 140 | Blynk.virtualWrite(V4, humidity); 141 | tsLastReport = millis(); 142 | 143 | 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /Patient-Health-Monitoring-System-with-MAX30100-DHT11/patient-health-monitoring-system.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_PRINT Serial 2 | 3 | #define BLYNK_TEMPLATE_ID "TMPL3hHougpcA" 4 | #define BLYNK_TEMPLATE_NAME "Patient Health Monitoring" 5 | #define BLYNK_AUTH_TOKEN "XONsdf3XXdNdsfp7BPv-58bgdftihYRgfh42l1fgj7Zp4w" 6 | 7 | #include 8 | #include "MAX30100_PulseOximeter.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #define REPORTING_PERIOD_MS 1000 16 | LiquidCrystal_I2C lcd(0x27, 16, 2); 17 | 18 | #define DHTPIN 2 // Pin which is connected to the DHT sensor. 19 | #define DHTTYPE DHT11 // DHT 11 20 | 21 | DHT dht(DHTPIN, DHTTYPE); 22 | 23 | char auth[] = BLYNK_AUTH_TOKEN; // You should get Auth Token in the Blynk App. 24 | char ssid[] = "WiFi Username"; // Your WiFi credentials. 25 | char pass[] = "WiFi Password"; 26 | 27 | // Connections : SCL PIN - D22 , SDA PIN - D21 , INT PIN - D0 28 | PulseOximeter pox; 29 | 30 | int BPM, SpO2, humidity, temperature;; 31 | uint32_t tsLastReport = 0; 32 | 33 | 34 | void onBeatDetected() 35 | { 36 | Serial.println("Beat Detected!"); 37 | } 38 | 39 | void setup() 40 | { 41 | Serial.begin(115200); 42 | 43 | pinMode(19, OUTPUT); 44 | Blynk.begin(auth, ssid, pass); 45 | 46 | Serial.print("Initializing Pulse Oximeter.."); 47 | lcd.begin(); 48 | lcd.backlight(); 49 | 50 | // Display "Tech Trends Shameer" 51 | lcd.setCursor(3, 0); 52 | lcd.print("Tech Trends "); 53 | lcd.setCursor(3, 1); 54 | lcd.print(" Shameer "); 55 | delay(2000); // Wait for 3 seconds 56 | 57 | // Clear the LCD and display "Pulse Oximeter" 58 | lcd.clear(); 59 | lcd.setCursor(1, 0); 60 | lcd.print("Patient Health "); 61 | lcd.setCursor(3, 1); 62 | lcd.print("Monitoring "); 63 | lcd.setCursor(12, 0); // Adjust the position for the heart symbol 64 | 65 | delay(2000); 66 | lcd.clear(); 67 | 68 | if (!pox.begin()) 69 | { 70 | Serial.println("FAILED"); 71 | for(;;); 72 | } 73 | else 74 | { 75 | Serial.println("SUCCESS"); 76 | pox.setOnBeatDetectedCallback(onBeatDetected); 77 | } 78 | 79 | // The default current for the IR LED is 50mA and it could be changed by uncommenting the following line. 80 | pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA); 81 | 82 | } 83 | 84 | void loop() 85 | { 86 | pox.update(); 87 | Blynk.run(); 88 | 89 | BPM = pox.getHeartRate(); 90 | SpO2 = pox.getSpO2(); 91 | humidity = dht.readHumidity(); 92 | temperature = dht.readTemperature(); 93 | 94 | 95 | 96 | 97 | if (millis() - tsLastReport > REPORTING_PERIOD_MS) 98 | { 99 | //lcd.clear(); 100 | lcd.setCursor(0 , 0); 101 | lcd.print("BPM:"); 102 | lcd.print(pox.getHeartRate()); 103 | //lcd.setCursor(10, 0); // Adjust the position for the heart symbol 104 | lcd.setCursor(0 , 1); 105 | lcd.print("Sp02:"); 106 | lcd.print(pox.getSpO2()); 107 | lcd.print("%"); 108 | //tsLastReport = millis(); 109 | 110 | Serial.print("Heart rate:"); 111 | Serial.print(BPM); 112 | Serial.print(" bpm / SpO2:"); 113 | Serial.print(SpO2); 114 | Serial.println(" %"); 115 | 116 | 117 | //tsLastReport = millis(); 118 | 119 | 120 | Serial.print("Humidity: "); 121 | Serial.print(humidity); 122 | Serial.print(" %\t"); 123 | Serial.print("Temp: "); 124 | Serial.print(temperature); 125 | Serial.println(" *C"); 126 | //lcd.clear(); 127 | lcd.setCursor(9 , 0); 128 | lcd.print("T: "); 129 | lcd.print(temperature); 130 | lcd.print((char)223); 131 | lcd.print("C"); 132 | //lcd.setCursor(10, 0); // Adjust the position for the heart symbol 133 | lcd.setCursor(9 , 1); 134 | lcd.print("H: "); 135 | lcd.print(humidity); 136 | lcd.print("% "); 137 | Blynk.virtualWrite(V1, BPM); 138 | Blynk.virtualWrite(V2, SpO2); 139 | Blynk.virtualWrite(V3, temperature); 140 | Blynk.virtualWrite(V4, humidity); 141 | tsLastReport = millis(); 142 | 143 | 144 | } 145 | 146 | } 147 | -------------------------------------------------------------------------------- /Pulse-Oximeter-with-ESP8266-and-Blynk-IoT/pulse-oximeter-with-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3Pa-OHckX" 2 | #define BLYNK_TEMPLATE_NAME "Patient Health Monitoring" 3 | #define BLYNK_AUTH_TOKEN "tpecmTthmRjusads5SYkadaJ20dsfkUesafMBeFfH" 4 | 5 | #include 6 | #include "MAX30100_PulseOximeter.h" 7 | #define BLYNK_PRINT Serial 8 | #include 9 | #include 10 | 11 | #define REPORTING_PERIOD_MS 1000 12 | 13 | char auth[] = BLYNK_AUTH_TOKEN; // You should get Auth Token in the Blynk App. 14 | char ssid[] = "WiFi Username"; // Your WiFi credentials. 15 | char pass[] = "WiFi Password"; 16 | 17 | // Connections : SCL PIN - D22 , SDA PIN - D21 , INT PIN - D0 18 | PulseOximeter pox; 19 | 20 | float BPM, SpO2; 21 | uint32_t tsLastReport = 0; 22 | 23 | 24 | void onBeatDetected() 25 | { 26 | Serial.println("Beat Detected!"); 27 | } 28 | 29 | void setup() 30 | { 31 | Serial.begin(115200); 32 | 33 | pinMode(19, OUTPUT); 34 | Blynk.begin(auth, ssid, pass); 35 | 36 | Serial.print("Initializing Pulse Oximeter.."); 37 | 38 | if (!pox.begin()) 39 | { 40 | Serial.println("FAILED"); 41 | for(;;); 42 | } 43 | else 44 | { 45 | Serial.println("SUCCESS"); 46 | pox.setOnBeatDetectedCallback(onBeatDetected); 47 | } 48 | 49 | // The default current for the IR LED is 50mA and it could be changed by uncommenting the following line. 50 | pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA); 51 | 52 | } 53 | 54 | void loop() 55 | { 56 | pox.update(); 57 | Blynk.run(); 58 | 59 | BPM = pox.getHeartRate(); 60 | SpO2 = pox.getSpO2(); 61 | if (millis() - tsLastReport > REPORTING_PERIOD_MS) 62 | { 63 | Serial.print("Heart rate:"); 64 | Serial.print(BPM); 65 | Serial.print(" bpm / SpO2:"); 66 | Serial.print(SpO2); 67 | Serial.println(" %"); 68 | 69 | Blynk.virtualWrite(V3, BPM); 70 | Blynk.virtualWrite(V4, SpO2); 71 | 72 | tsLastReport = millis(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Rain-Alarm-Notification/rain-alarm-notification.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_PRINT Serial 2 | #include 3 | #include 4 | BlynkTimer timer; 5 | char auth[] = "x7i-rCaK_XkesEG7Ezdd-EwKivRgKZryohsdgfgJ"; 6 | 7 | char ssid[] = "wifi username"; 8 | char pass[] = "wifi password"; 9 | int flag=0; 10 | void notifyOnFire() 11 | { 12 | int isButtonPressed = digitalRead(D1); 13 | if (isButtonPressed==0 && flag==0) { 14 | Serial.println("Its Raining"); 15 | Blynk.notify("Alert : Its Raining"); 16 | flag=1; 17 | } 18 | else if (isButtonPressed==1) 19 | { 20 | flag=0; 21 | } 22 | } 23 | void setup() 24 | { 25 | Serial.begin(9600); 26 | Blynk.begin(auth, ssid, pass); 27 | pinMode(D1,INPUT); 28 | timer.setInterval(1000L,notifyOnFire); 29 | } 30 | void loop() 31 | { 32 | Blynk.run(); 33 | timer.run(); 34 | } 35 | -------------------------------------------------------------------------------- /Rain-Monitoring-System/rain-monitoring-system.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #define BLYNK_PRINT Serial 3 | #include 4 | #include 5 | //#include 6 | 7 | LiquidCrystal_I2C lcd(0x3F, 16, 2); 8 | // IF IN LCD IS NOT PRINTED ANY THING THEN CHANGE THIS VALUE 0x3F TO 0x27 9 | //DHT dht(D3, DHT11); //(sensor pin,sensor type) 10 | BlynkTimer timer; 11 | 12 | char auth[] = "Auth Code"; //Enter the Auth code which was send by Blink 13 | char ssid[] = "Wifi Username"; //Enter your WIFI Name 14 | char pass[] = "Wifi Password"; //Enter your WIFI Password 15 | 16 | void weather() { 17 | //float h = dht.readHumidity(); 18 | // float t = dht.readTemperature(); 19 | int r = analogRead(A0); 20 | // bool l = digitalRead(D4); 21 | lcd.print("Tech Trends"); 22 | r = map(r, 0, 1023, 100, 0); 23 | /* if (isnan(h) || isnan(t)) { 24 | Serial.println("Failed to read from DHT sensor!"); 25 | return; 26 | }*/ 27 | 28 | /*Blynk.virtualWrite(V0, t); //V0 is for Temperature 29 | Blynk.virtualWrite(V1, h); //V1 is for Humidity*/ 30 | Blynk.virtualWrite(V2, r); //V2 is for Rainfall 31 | 32 | /*if (l == 0) { 33 | WidgetLED led1(V3); 34 | led1.on(); 35 | lcd.setCursor(9, 1); 36 | lcd.print("L :"); 37 | lcd.print("High"); 38 | lcd.print(" "); 39 | } else if (l == 1) { 40 | WidgetLED led1(V3); 41 | led1.off(); 42 | lcd.setCursor(9, 1); 43 | lcd.print("L :"); 44 | lcd.print("Low"); 45 | lcd.print(" "); 46 | }*/ 47 | 48 | /* lcd.setCursor(0, 0); 49 | lcd.print("T :"); 50 | lcd.print(t); 51 | 52 | lcd.setCursor(0, 1); 53 | lcd.print("H :"); 54 | lcd.print(h);*/ 55 | Serial.println(r); 56 | lcd.setCursor(9, 0); 57 | lcd.print("R :"); 58 | lcd.print(r); 59 | lcd.print(" "); 60 | 61 | } 62 | 63 | void setup() { 64 | Serial.begin(9600); // See the connection status in Serial Monitor 65 | lcd.init(); 66 | lcd.backlight(); 67 | Blynk.begin(auth, ssid, pass); 68 | lcd.print("Tech Trends"); 69 | //dht.begin(); 70 | // Setup a function to be called every second 71 | timer.setInterval(10L, weather); 72 | } 73 | 74 | void loop() { 75 | Blynk.run(); // Initiates Blynk 76 | timer.run(); // Initiates SimpleTimer 77 | } 78 | -------------------------------------------------------------------------------- /Read-Data-From-Google-Spreadsheet-and-Display-in-OLED/GoogleScript.js: -------------------------------------------------------------------------------- 1 | 2 | var ss = SpreadsheetApp.openById('192k4yM-OrKsxU4E9w7pjkdk0OsdghhffjyjkkkMbV2k0HZARcqkNzI8g'); 3 | var sheet = ss.getSheetByName('Sheet1'); 4 | 5 | function doGet(e){ 6 | var read = e.parameter.read; 7 | 8 | if (read !== undefined){ 9 | return ContentService.createTextOutput(sheet.getRange('A1').getValue()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Read-Data-From-Google-Spreadsheet-and-Display-in-OLED/read-data-from-google-spreadsheet-and-display-in-OLED-Display.ino: -------------------------------------------------------------------------------- 1 | 2 | //#include 3 | //#include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | /********************************************************************************/ 14 | //Things to change 15 | const char * ssid = ""; 16 | const char * password = ""; 17 | String GOOGLE_SCRIPT_ID = "AKfycbzvES70BNafBPsdsggL7g88PJhyOlD78zOsdgggx-oOhOSpg75qQlgRjh8Xw"; 18 | 19 | const int sendInterval = 5000; 20 | /********************************************************************************/ 21 | #define SCREEN_WIDTH 128 // OLED display width, in pixels 22 | #define SCREEN_HEIGHT 64 // OLED display height, in pixels 23 | 24 | // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins) 25 | #define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin) 26 | Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); 27 | 28 | #define NUMFLAKES 10 // Number of snowflakes in the animation example 29 | 30 | #define LOGO_HEIGHT 16 31 | #define LOGO_WIDTH 16 32 | #define BLUE 0x001F 33 | 34 | WiFiClientSecure client; 35 | 36 | void testdrawstyles(String str) { 37 | display.clearDisplay(); 38 | 39 | display.setTextSize(2); // Normal 1:1 pixel scale 40 | display.setTextColor(SSD1306_WHITE); // Draw white text 41 | display.setCursor(0,0); // Start at top-left corner 42 | // display.println(F("GSheet C2:")); 43 | // display.setCursor(0,1); // Start at top-left corner 44 | // display.println(F(str.c_str())); 45 | display.print(str); 46 | display.display(); 47 | delay(2000); 48 | } 49 | 50 | void setup() { 51 | Serial.begin(115200); 52 | delay(10); 53 | 54 | // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally 55 | if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64 56 | Serial.println(F("SSD1306 allocation failed")); 57 | for(;;); // Don't proceed, loop forever 58 | } 59 | display.clearDisplay(); 60 | 61 | display.setTextColor(SSD1306_WHITE); 62 | display.setTextSize(2); 63 | display.setCursor(0,17); 64 | display.print("Welcome To "); 65 | display.setTextSize(2); 66 | display.setCursor(0, 39); 67 | display.print("TechTrends "); 68 | display.display(); 69 | delay(2000); // Pause for 2 seconds 70 | display.clearDisplay(); 71 | 72 | 73 | WiFi.mode(WIFI_STA); 74 | WiFi.begin(ssid, password); 75 | 76 | Serial.println("Started"); 77 | Serial.print("Connecting"); 78 | while (WiFi.status() != WL_CONNECTED) { 79 | delay(5000); 80 | Serial.print("."); 81 | } 82 | 83 | Serial.println("Ready to go"); 84 | //testdrawstyles(); 85 | } 86 | 87 | void loop() { 88 | spreadsheet_comm(); 89 | delay(sendInterval); 90 | } 91 | 92 | void spreadsheet_comm(void) { 93 | std::unique_ptrclient(new BearSSL::WiFiClientSecure); 94 | client->setInsecure(); 95 | HTTPClient https; 96 | String url="https://script.google.com/macros/s/"+GOOGLE_SCRIPT_ID+"/exec?read"; 97 | // Serial.print(url); 98 | Serial.print("Making a request"); 99 | //https.begin(url.c_str()); //Specify the URL and certificate 100 | https.begin(*client, url.c_str()); 101 | https.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); 102 | int httpCode = https.GET(); 103 | String payload; 104 | if (httpCode > 0) { //Check for the returning code 105 | payload = https.getString(); 106 | 107 | Serial.println(httpCode); 108 | Serial.println(payload); 109 | testdrawstyles(payload); 110 | } 111 | else { 112 | Serial.println("Error on HTTP request"); 113 | } 114 | https.end(); 115 | } 116 | -------------------------------------------------------------------------------- /Read-Data-from-Google-SpreadSheet-and-display-in-LCD-Display/GoogleScript.js: -------------------------------------------------------------------------------- 1 | var ss = SpreadsheetApp.openById('1sv00-AtvAAW6x50stmrCjl_grCvHIxI_5qbv44LzRrffsgdgvU'); 2 | var sheet = ss.getSheetByName('Sheet1'); 3 | 4 | 5 | function doGet(e){ 6 | var read = e.parameter.read; 7 | 8 | if (read !== undefined){ 9 | return ContentService.createTextOutput(sheet.getRange('A1').getValue()); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Read-Data-from-Google-SpreadSheet-and-display-in-LCD-Display/read-data-from-google-spreadsheet-and-display-in-LCD-Display.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Read Data from Google SpreadSheet and display in LCD Display 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | LiquidCrystal_I2C lcd(0x27, 16, 2); // Set the LCD address 11 | 12 | 13 | //Enter WIFI Credentials 14 | const char * ssid = "Wifi Username"; // Enter your Wifi Username 15 | const char * password = "Wifi Password"; // Enter your Wifi Password 16 | String GOOGLE_SCRIPT_ID = "AKfycbwl3Bh81XoOxNoEsBRlWhPU4zH2kzfm7QhkV2hlouigWhn4E46b"; 17 | //--------------------------------------------------------------------- 18 | 19 | 20 | 21 | const int sendInterval = 50; 22 | String message = "Welcome"; 23 | int x; 24 | int len=0; 25 | int k=0; 26 | WiFiClientSecure client; 27 | 28 | void setup() 29 | { 30 | Serial.begin(9600); 31 | lcd.begin(); 32 | delay(10); 33 | //-------------------------------------------- 34 | WiFi.mode(WIFI_STA); 35 | WiFi.begin(ssid, password); 36 | 37 | Serial.print("Connecting to Wi-Fi"); 38 | while (WiFi.status() != WL_CONNECTED) 39 | { 40 | lcd.home(); 41 | lcd.print("Waiting for Wifi"); 42 | delay(500); 43 | Serial.print("."); 44 | } 45 | lcd.clear(); 46 | lcd.home(); 47 | lcd.print("Wifi Connected"); 48 | Serial.println("OK"); 49 | //-------------------------------------------- 50 | } 51 | 52 | void loop() 53 | { 54 | int inc =0; 55 | if(k==0) 56 | read_google_sheet(); 57 | len =message.length(); 58 | for (int a=15; a>=-len;a--) 59 | { 60 | lcd.clear(); 61 | lcd.home(); 62 | lcd.print("Smart Display"); 63 | if(a>=0) 64 | { 65 | lcd.setCursor(a,1); 66 | lcd.print(message.substring(0,15)); 67 | } 68 | else 69 | { 70 | inc++; 71 | lcd.setCursor(0,1); 72 | lcd.print(message.substring(inc,len)); 73 | } 74 | delay(400); 75 | } 76 | k++; 77 | if(k>2) 78 | k=0; 79 | } 80 | 81 | void read_google_sheet(void) 82 | { 83 | //----------------------------------------------------------------------------------- 84 | std::unique_ptrclient(new BearSSL::WiFiClientSecure); 85 | client->setInsecure(); 86 | HTTPClient https; 87 | String url="https://script.google.com/macros/s/"+GOOGLE_SCRIPT_ID+"/exec?read"; 88 | Serial.println("Reading Data From Google Sheet....."); 89 | https.begin(*client, url.c_str()); 90 | //----------------------------------------------------------------------------------- 91 | //Removes the error "302 Moved Temporarily Error" 92 | https.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); 93 | //----------------------------------------------------------------------------------- 94 | //Get the returning HTTP status code 95 | int httpCode = https.GET(); 96 | Serial.print("HTTP Status Code: "); 97 | Serial.println(httpCode); 98 | //----------------------------------------------------------------------------------- 99 | if(httpCode <= 0){Serial.println("Error on HTTP request"); https.end(); return;} 100 | //----------------------------------------------------------------------------------- 101 | //reading data comming from Google Sheet 102 | String payload = https.getString(); 103 | Serial.println("Payload: "+payload); 104 | //----------------------------------------------------------------------------------- 105 | if(httpCode == 200) 106 | message= payload; 107 | //------------------------------------------------------------------------------------- 108 | https.end(); 109 | } 110 | -------------------------------------------------------------------------------- /Real-Time-Temperature-Monitoring-with-NTC-Thermistor-ESP8266-and-Blynk-IoT/real-time-temperature-monitoring-with-ntc-thermistor-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3XGFnbsdgsEgK" 2 | #define BLYNK_TEMPLATE_NAME "Temperature Monitor Using Thermistor" 3 | #define BLYNK_AUTH_TOKEN "nSrruVdL_4UUg8cesdkpL1KgsliXgd8P_714Fh" 4 | 5 | //#define BLYNK_PRINT Serial 6 | 7 | #include 8 | #include 9 | 10 | char auth[] = BLYNK_AUTH_TOKEN; // Your Blynk auth token 11 | char ssid[] = "WiFi Username"; // Your WiFi SSID 12 | char pass[] = "WiFi Password"; // Your WiFi Password 13 | 14 | const int analogPin = A0; // Analog pin for NTC thermistor 15 | BlynkTimer timer; 16 | 17 | void sendTemperature() { 18 | int analogValue = analogRead(analogPin); 19 | float voltage = analogValue * (3.3 / 1023.0); // Convert analog reading to voltage 20 | float resistance = (3.3 - voltage) * 10000 / voltage; // Calculate resistance 21 | float temperature = 1 / (log(resistance / 10000) / 3950 + 1 / (25 + 273.15)) - 273.15; // Calculate temperature 22 | 23 | Blynk.virtualWrite(V1, temperature); // Send temperature to Blynk app (Virtual Pin V5) 24 | 25 | Serial.print("Analog Value: "); 26 | Serial.print(analogValue); 27 | Serial.print(" Voltage: "); 28 | Serial.print(voltage); 29 | Serial.print(" V, Resistance: "); 30 | Serial.print(resistance); 31 | Serial.print(" ohms, Temperature: "); 32 | Serial.print(temperature); 33 | Serial.println(" *C"); 34 | } 35 | 36 | void setup() { 37 | Serial.begin(9600); 38 | Blynk.begin(auth, ssid, pass); 39 | 40 | timer.setInterval(1000L, sendTemperature); // Send temperature every second 41 | } 42 | 43 | void loop() { 44 | Blynk.run(); 45 | timer.run(); 46 | } 47 | -------------------------------------------------------------------------------- /Smart-Attendance-Tracking-System-with-RFID-Module-and-ESP8266/Script.js: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Smart Attendance System 3 | 4 | var ss = SpreadsheetApp.openById('SheetID'); 5 | var sheet = ss.getSheetByName('Sheet1'); 6 | var timezone = 'Asia/Karachi'; // Corrected timezone format 7 | 8 | // ------------------------------------------------------------------------ 9 | function doGet(e){ 10 | Logger.log(JSON.stringify(e)); 11 | 12 | // Check if the 'name' parameter is undefined 13 | if (typeof e.parameter.name === 'undefined') { 14 | return ContentService.createTextOutput('Received data is undefined'); 15 | } 16 | 17 | var Curr_Date = new Date(); 18 | var Curr_Time = Utilities.formatDate(Curr_Date, timezone, 'HH:mm:ss'); 19 | var name = stripQuotes(e.parameter.name); 20 | 21 | var nextRow = sheet.getLastRow() + 1; 22 | sheet.getRange('A' + nextRow).setValue(Curr_Date); 23 | sheet.getRange('B' + nextRow).setValue(Curr_Time); 24 | sheet.getRange('C' + nextRow).setValue(name); 25 | 26 | // Returns response back to ESP32 27 | var response = 'Card holder name is stored in column C'; 28 | return ContentService.createTextOutput(response); 29 | } 30 | 31 | // ------------------------------------------------------------------------ 32 | function stripQuotes(value) { 33 | return value.toString().replace(/^["']|['"]$/g, ''); 34 | } 35 | 36 | // ------------------------------------------------------------------------ 37 | // Extra Function. Not used in this project. 38 | // Planning to use in future projects. 39 | // This function is used to handle POST request 40 | function doPost(e) { 41 | var val = e.parameter.value; 42 | 43 | if (e.parameter.value !== undefined){ 44 | var range = sheet.getRange('A2'); 45 | range.setValue(val); 46 | } 47 | } 48 | // ------------------------------------------------------------------------ 49 | -------------------------------------------------------------------------------- /Smart-Attendance-Tracking-System-with-RFID-Module-and-ESP8266/card-holder-name.ino: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | //----------------------------------------- 5 | constexpr uint8_t RST_PIN = D3; 6 | constexpr uint8_t SS_PIN = D4; 7 | //----------------------------------------- 8 | MFRC522 mfrc522(SS_PIN, RST_PIN); 9 | MFRC522::MIFARE_Key key; 10 | //----------------------------------------- 11 | /* Set the block to write data */ 12 | int blockNum = 2; 13 | /* This is the actual data which is 14 | going to be written into the card */ 15 | byte blockData [16] = {"Tech Trends"}; 16 | //----------------------------------------- 17 | /* Create array to read data from Block */ 18 | /* Length of buffer should be 2 Bytes 19 | more than the size of Block (16 Bytes) */ 20 | byte bufferLen = 18; 21 | byte readBlockData[18]; 22 | //----------------------------------------- 23 | MFRC522::StatusCode status; 24 | //----------------------------------------- 25 | 26 | 27 | 28 | void setup() 29 | { 30 | //----------------------------------------- 31 | //Initialize serial communications with PC 32 | Serial.begin(9600); 33 | //----------------------------------------- 34 | //Initialize SPI bus 35 | SPI.begin(); 36 | //----------------------------------------- 37 | //Initialize MFRC522 Module 38 | mfrc522.PCD_Init(); 39 | Serial.println("Scan a MIFARE 1K Tag to write data..."); 40 | //----------------------------------------- 41 | } 42 | 43 | 44 | 45 | /**************************************************************************************************** 46 | * Writ() function 47 | ****************************************************************************************************/ 48 | void loop() 49 | { 50 | //------------------------------------------------------------------------------ 51 | /* Prepare the ksy for authentication */ 52 | /* All keys are set to FFFFFFFFFFFFh at chip delivery from the factory */ 53 | for (byte i = 0; i < 6; i++){ 54 | key.keyByte[i] = 0xFF; 55 | } 56 | //------------------------------------------------------------------------------ 57 | /* Look for new cards */ 58 | /* Reset the loop if no new card is present on RC522 Reader */ 59 | if ( ! mfrc522.PICC_IsNewCardPresent()){return;} 60 | //------------------------------------------------------------------------------ 61 | /* Select one of the cards */ 62 | if ( ! mfrc522.PICC_ReadCardSerial()) {return;} 63 | //------------------------------------------------------------------------------ 64 | Serial.print("\n"); 65 | Serial.println("**Card Detected**"); 66 | /* Print UID of the Card */ 67 | Serial.print(F("Card UID:")); 68 | for (byte i = 0; i < mfrc522.uid.size; i++){ 69 | Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); 70 | Serial.print(mfrc522.uid.uidByte[i], HEX); 71 | } 72 | Serial.print("\n"); 73 | /* Print type of card (for example, MIFARE 1K) */ 74 | Serial.print(F("PICC type: ")); 75 | MFRC522::PICC_Type piccType = mfrc522.PICC_GetType(mfrc522.uid.sak); 76 | Serial.println(mfrc522.PICC_GetTypeName(piccType)); 77 | //------------------------------------------------------------------------------ 78 | /* Call 'WriteDataToBlock' function, which will write data to the block */ 79 | Serial.print("\n"); 80 | Serial.println("Writing to Data Block..."); 81 | WriteDataToBlock(blockNum, blockData); 82 | //------------------------------------------------------------------------------ 83 | /* Read data from the same block */ 84 | Serial.print("\n"); 85 | Serial.println("Reading from Data Block..."); 86 | ReadDataFromBlock(blockNum, readBlockData); 87 | /* If you want to print the full memory dump, uncomment the next line */ 88 | //mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); 89 | //------------------------------------------------------------------------------ 90 | /* Print the data read from block */ 91 | Serial.print("\n"); 92 | Serial.print("Data in Block:"); 93 | Serial.print(blockNum); 94 | Serial.print(" --> "); 95 | for (int j=0 ; j<16 ; j++){ 96 | Serial.write(readBlockData[j]); 97 | } 98 | Serial.print("\n"); 99 | //------------------------------------------------------------------------------ 100 | } 101 | 102 | 103 | 104 | /**************************************************************************************************** 105 | * Writ() function 106 | ****************************************************************************************************/ 107 | void WriteDataToBlock(int blockNum, byte blockData[]) 108 | { 109 | //------------------------------------------------------------------------------ 110 | /* Authenticating the desired data block for write access using Key A */ 111 | status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, blockNum, &key, &(mfrc522.uid)); 112 | if (status != MFRC522::STATUS_OK){ 113 | Serial.print("Authentication failed for Write: "); 114 | Serial.println(mfrc522.GetStatusCodeName(status)); 115 | return; 116 | } 117 | //------------------------------------------------------------------------------ 118 | else { 119 | Serial.println("Authentication success"); 120 | } 121 | //------------------------------------------------------------------------------ 122 | /* Write data to the block */ 123 | status = mfrc522.MIFARE_Write(blockNum, blockData, 16); 124 | if (status != MFRC522::STATUS_OK) { 125 | Serial.print("Writing to Block failed: "); 126 | Serial.println(mfrc522.GetStatusCodeName(status)); 127 | return; 128 | } 129 | else 130 | {Serial.println("Data was written into Block successfully");} 131 | //------------------------------------------------------------------------------ 132 | } 133 | 134 | 135 | 136 | 137 | 138 | /**************************************************************************************************** 139 | * ReadDataFromBlock() function 140 | ****************************************************************************************************/ 141 | void ReadDataFromBlock(int blockNum, byte readBlockData[]) 142 | { 143 | //------------------------------------------------------------------------------ 144 | /* Authenticating the desired data block for Read access using Key A */ 145 | status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, blockNum, &key, &(mfrc522.uid)); 146 | //------------------------------------------------------------------------------ 147 | if (status != MFRC522::STATUS_OK){ 148 | Serial.print("Authentication failed for Read: "); 149 | Serial.println(mfrc522.GetStatusCodeName(status)); 150 | return; 151 | } 152 | else { 153 | Serial.println("Authentication success"); 154 | } 155 | //------------------------------------------------------------------------------ 156 | /* Reading data from the Block */ 157 | status = mfrc522.MIFARE_Read(blockNum, readBlockData, &bufferLen); 158 | if (status != MFRC522::STATUS_OK){ 159 | Serial.print("Reading failed: "); 160 | Serial.println(mfrc522.GetStatusCodeName(status)); 161 | return; 162 | } 163 | else { 164 | Serial.println("Block was read successfully"); 165 | } 166 | //------------------------------------------------------------------------------ 167 | } 168 | -------------------------------------------------------------------------------- /Smart-Door-Notification-Using-ESP8266-and-Blynk-IOT/smart-door-notification-using-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL36t_K6RBw" 2 | #define BLYNK_TEMPLATE_NAME "Smart Door Notification" 3 | #define BLYNK_AUTH_TOKEN "N8JnjSZXuWdhjWm9dDuysTF21fd42b5hejddsK6Kx" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | #define DOOR_SENSOR 4 10 | #define buzzer 2 11 | BlynkTimer timer; 12 | char auth[] = BLYNK_AUTH_TOKEN; //Enter the authentication code sent by Blynk to your Email 13 | char ssid[] = "WiFi Username"; //Enter your WIFI SSID 14 | char pass[] = "WiFi Password"; //Enter your WIFI Password 15 | int flag=0; 16 | 17 | void notifyOnButtonPress() 18 | { 19 | int isButtonPressed = digitalRead(DOOR_SENSOR); 20 | if (isButtonPressed==1 && flag==0) { 21 | Serial.println("Someone Opened the door"); 22 | Blynk.logEvent("security_alert","Someone opened the Door"); 23 | digitalWrite(buzzer, HIGH); 24 | flag=1; 25 | } 26 | else if (isButtonPressed==0) 27 | { 28 | flag=0; 29 | Serial.println("Door Closed"); 30 | digitalWrite(buzzer, LOW); 31 | } 32 | } 33 | void setup() 34 | { 35 | Serial.begin(9600); 36 | Blynk.begin(auth, ssid, pass); 37 | pinMode(DOOR_SENSOR,INPUT_PULLUP); 38 | pinMode(buzzer, OUTPUT); 39 | timer.setInterval(5000L,notifyOnButtonPress); 40 | } 41 | void loop() 42 | { 43 | Blynk.run(); 44 | timer.run(); 45 | } 46 | -------------------------------------------------------------------------------- /Smart-Environment-Monitoring-System/smart-environment-monitoring-system.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3466yY8pl" 2 | #define BLYNK_TEMPLATE_NAME "Environment Monitoring System" 3 | #define BLYNK_AUTH_TOKEN "akZZG3qpc8k9_WkJ3xqx-zhIvGvLGKSh" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | 12 | char auth[] = BLYNK_AUTH_TOKEN; 13 | 14 | char ssid[] = "Galaxy F23 5G 3FF5"; // type your wifi name 15 | char pass[] = "edrp6836ehan"; // type your wifi password 16 | 17 | BlynkTimer timer; 18 | 19 | 20 | #define DHTPIN 4 //Connect Out pin to D2 in NODE MCU 21 | #define DHTTYPE DHT11 22 | DHT dht(DHTPIN, DHTTYPE); 23 | 24 | const int AirValue = 650; //you need to replace this value with Value_1 25 | const int WaterValue = 310; //you need to replace this value with Value_2 26 | const int SensorPin = A0; 27 | 28 | void sendSensor() 29 | { 30 | /*int soilmoisturevalue = analogRead(A0); 31 | soilmoisturevalue = map(soilmoisturevalue, 0, 1023, 0, 100);*/ 32 | int value = analogRead(A0); 33 | //value = map(value,400,1023,100,0); 34 | value = map(value, AirValue, WaterValue, 0, 100); 35 | float h = dht.readHumidity(); 36 | float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit 37 | 38 | if (isnan(h) || isnan(t)) { 39 | Serial.println("Failed to read from DHT sensor!"); 40 | return; 41 | } 42 | // You can send any value at any time. 43 | // Please don't send more that 10 values per second. 44 | Blynk.virtualWrite(V0, value); 45 | Blynk.virtualWrite(V1, t); 46 | Blynk.virtualWrite(V2, h); 47 | Serial.print("Soil Moisture : "); 48 | Serial.print(value); 49 | Serial.print("Temperature : "); 50 | Serial.print(t); 51 | Serial.print(" Humidity : "); 52 | Serial.println(h); 53 | } 54 | void setup() 55 | { 56 | 57 | Serial.begin(115200); 58 | 59 | 60 | Blynk.begin(auth, ssid, pass); 61 | dht.begin(); 62 | timer.setInterval(100L, sendSensor); 63 | 64 | } 65 | 66 | void loop() 67 | { 68 | Blynk.run(); 69 | timer.run(); 70 | } 71 | -------------------------------------------------------------------------------- /Smart-Environment-Monitoring-with-ESP8266-Capacitive-Soil-Sensor-DHT11-Arduino-IoT-Cloud/Environment_Monitoring_System_jan14a(1).zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tech-Trends-Shameer/Esp-8266-Projects/af0a60e690551a543f4bd7d024d9c77b7e09b2e0/Smart-Environment-Monitoring-with-ESP8266-Capacitive-Soil-Sensor-DHT11-Arduino-IoT-Cloud/Environment_Monitoring_System_jan14a(1).zip -------------------------------------------------------------------------------- /Smart-Environment-Monitoring-with-ESP8266-Capacitive-Soil-Sensor-DHT11-Arduino-IoT-Cloud/smart-environment-monitoring-with-esp8266-capacitive-soil-sensor-dht11-arduino-iot-cloud.ino: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Smart-Exhaust-Fan-Control-using-MQ2-Sensor-and-ESP8266/smart-exhaust-fan-control-using-mq2-sensor-and-esp8266.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPLsdf37UsdfmEUog3K" 2 | #define BLYNK_TEMPLATE_NAME "Smoke Controlled Exhaust Fan" 3 | #define BLYNK_AUTH_TOKEN "iE0jdwBsdfLmUBFdsfZICzOhCPfBGfg0WLsdfhw3snzS" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | char auth[] = BLYNK_AUTH_TOKEN; // Blynk Auth Token 10 | char ssid[] = "WiFi Username"; // WiFi SSID 11 | char pass[] = "WiFi Password"; // WiFi Password 12 | 13 | const int smokeA0 = A0; // Analog pin A0 connected to MQ-2 sensor 14 | const int relayPin = D1; // Digital pin D1 connected to relay module 15 | 16 | BlynkTimer timer; 17 | 18 | void setup() { 19 | Serial.begin(9600); 20 | Blynk.begin(auth, ssid, pass); 21 | 22 | pinMode(smokeA0, INPUT); 23 | pinMode(relayPin, OUTPUT); 24 | digitalWrite(relayPin, LOW); 25 | 26 | timer.setInterval(1000L, checkSmokeLevel); 27 | } 28 | 29 | void checkSmokeLevel() { 30 | int smokeLevel = analogRead(smokeA0); 31 | Serial.print("Smoke Level: "); 32 | Serial.println(smokeLevel); 33 | Blynk.virtualWrite(V1, smokeLevel); // Send smoke level to Blynk 34 | 35 | if (smokeLevel > 150) { 36 | digitalWrite(relayPin, HIGH); // Turn on relay (and fan) 37 | } else { 38 | digitalWrite(relayPin, LOW); // Turn off relay (and fan) 39 | } 40 | } 41 | 42 | BLYNK_WRITE(V2) { // Manual control from Blynk app 43 | int pinValue = param.asInt(); 44 | digitalWrite(relayPin, pinValue); 45 | } 46 | 47 | void loop() { 48 | Blynk.run(); 49 | timer.run(); 50 | } 51 | -------------------------------------------------------------------------------- /Smart-Irrigation-System-with-ESP8266-and-Blynk-IoT/smart-irrigation-system-with-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3UUK-5dEk" 2 | #define BLYNK_TEMPLATE_NAME "Smart Agriculture System" 3 | #define BLYNK_AUTH_TOKEN "KK9W1dspx9MsdVWpKztIsdfJKnaU1gwmW7xgpsdfjkY4k" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | #define SOIL_MOISTURE_PIN A0 // Analog pin for soil moisture sensor 10 | #define THRESHOLD_MOISTURE 10 // Adjust this value based on your soil moisture sensor readings 11 | #define PUMP_PIN D1 // Digital pin for controlling the pump 12 | #define PUMP_SWITCH V6 // Virtual pin for controlling the pump manually 13 | 14 | char auth[] = BLYNK_AUTH_TOKEN; // Replace with your Blynk auth token 15 | char ssid[] = "WiFi Username"; // Replace with your WiFi credentials 16 | char pass[] = "WiFi Password"; 17 | 18 | BlynkTimer timer; 19 | 20 | bool isPumpOn = false; // Variable to track pump status 21 | 22 | void sendSensorData() 23 | { 24 | int soilMoisture = analogRead(SOIL_MOISTURE_PIN); 25 | Serial.print("Soil Moisture "); 26 | Serial.println(soilMoisture); 27 | // Map the analog sensor values to a percentage (0-100) 28 | int soilMoisturePercentage = map(soilMoisture, 400, 1023, 100, 0); 29 | Serial.print("Soil Moisture Percentage "); 30 | Serial.println(soilMoisturePercentage); 31 | // Send soil moisture data to Blynk 32 | Blynk.virtualWrite(V5, soilMoisturePercentage); 33 | 34 | // Check if the pump should be on based on manual switch or soil moisture level 35 | if (isPumpOn || soilMoisturePercentage < THRESHOLD_MOISTURE) 36 | { 37 | // Turn on the pump 38 | digitalWrite(PUMP_PIN, HIGH); 39 | // Check if the pump is turned on automatically (not manually) 40 | if (!isPumpOn) { 41 | // Send alert notification to Blynk app if the pump is turned on automatically 42 | Blynk.logEvent("moisture_alert","Soil moisture is below the threshold!"); 43 | Serial.println("Soil moisture is below the threshold!"); 44 | } 45 | } 46 | else 47 | { 48 | // Turn off the pump only if it was not turned on manually 49 | if (!isPumpOn) { 50 | digitalWrite(PUMP_PIN, LOW); 51 | } 52 | } 53 | } 54 | 55 | BLYNK_WRITE(PUMP_SWITCH) 56 | { 57 | isPumpOn = param.asInt(); 58 | if (isPumpOn) { 59 | Serial.println("Pump manually turned ON"); 60 | } else { 61 | Serial.println("Pump manually turned OFF"); 62 | } 63 | } 64 | 65 | void setup() 66 | { 67 | Serial.begin(9600); 68 | pinMode(PUMP_PIN, OUTPUT); // Set pump pin as an output 69 | 70 | Blynk.begin(auth, ssid, pass); 71 | 72 | timer.setInterval(3000L, sendSensorData); // Set the interval for checking soil moisture (every 3 seconds) 73 | 74 | // Setup switch widget 75 | Blynk.virtualWrite(PUMP_SWITCH, isPumpOn); 76 | Blynk.syncVirtual(PUMP_SWITCH); 77 | } 78 | 79 | void loop() 80 | { 81 | Blynk.run(); 82 | timer.run(); 83 | } 84 | -------------------------------------------------------------------------------- /Smart-Irrigation-Using-Blynk-IOT/smart-irrigation-using-blynk-2.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Control Water Pump Using Blynk 2.0 3 | 4 | #define BLYNK_TEMPLATE_ID "TemplateID" 5 | #define BLYNK_DEVICE_NAME "Control Pump" 6 | #define BLYNK_AUTH_TOKEN "Auth Token" 7 | 8 | 9 | #define BLYNK_PRINT Serial 10 | #include 11 | 12 | #include 13 | 14 | 15 | char auth[] = BLYNK_AUTH_TOKEN; 16 | 17 | char ssid[] = "Wifi Username"; // Enter your wifi name 18 | char pass[] = "Wifi Password"; // Enter your wifi password 19 | 20 | int relaypin = D4; 21 | void setup() 22 | { 23 | Serial.begin(115200); 24 | Blynk.begin(auth, ssid, pass); 25 | pinMode(relaypin,OUTPUT); 26 | 27 | } 28 | 29 | void loop() 30 | { 31 | Blynk.run(); 32 | } 33 | -------------------------------------------------------------------------------- /Smart-LED-Tube-Light-Using-ESP8266-and-Blynk-IOT/smart-led-tube-light-using-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Smart LED Tube Light Using ESP8266 and Blynk IOT | Home Automation Using ESP8266 and Blynk IOT 3 | 4 | #define BLYNK_TEMPLATE_ID "TMPL3Sm7jhd4p" 5 | #define BLYNK_TEMPLATE_NAME "Smart Tube Light Using ESP8266" 6 | #define BLYNK_AUTH_TOKEN "EA4JsAwoncg-MZsqdg2MDfsf_sa0yhd-wnhsf9Q" 7 | 8 | #define BLYNK_PRINT Serial 9 | #include 10 | 11 | #include 12 | 13 | 14 | char auth[] = BLYNK_AUTH_TOKEN; 15 | 16 | char ssid[] = "WiFi Username"; // type your wifi name 17 | char pass[] = "WiFi Password"; // type your wifi password 18 | 19 | int relaypin = D2; 20 | void setup() 21 | { 22 | Serial.begin(9600); 23 | Blynk.begin(auth, ssid, pass); 24 | pinMode(relaypin,OUTPUT); 25 | 26 | } 27 | 28 | void loop() 29 | { 30 | Blynk.run(); 31 | } 32 | -------------------------------------------------------------------------------- /Smart-Light-Monitoring-Using-ESP8266-and-Blynk-IoT/smart-light-monitoring-using-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Light Intensity Measurement 3 | 4 | #define BLYNK_TEMPLATE_ID "TMPL3Atk3AY9w" 5 | #define BLYNK_TEMPLATE_NAME "Light Intensity Measurement" 6 | #define BLYNK_AUTH_TOKEN "Am76Kd2Fr-xfgCq7uydjl9mmuIs4--mxfkj6mZk" 7 | 8 | #define BLYNK_PRINT Serial 9 | #include 10 | #include 11 | 12 | char auth[] = BLYNK_AUTH_TOKEN; 13 | 14 | char ssid[] = "WiFi Username"; // type your wifi name 15 | char pass[] = "WiFi Password"; // type your wifi password 16 | 17 | BlynkTimer timer; 18 | 19 | 20 | int temt6000Pin = A0; //Connect Ambient Sensor to A0 in NodeMCU 21 | float light; 22 | int light_value; 23 | 24 | void lightIntensity() 25 | { 26 | int light_value = analogRead(temt6000Pin); 27 | light = light_value * 0.0976;// percentage calculation 28 | Blynk.virtualWrite(V0, light); 29 | Serial.print("Light Value"); 30 | Serial.println(light_value); 31 | Serial.print("Light %"); 32 | Serial.println(light); 33 | delay(2000); 34 | } 35 | 36 | void setup() 37 | { 38 | Serial.begin(115200); 39 | 40 | pinMode(temt6000Pin, INPUT); //data pin for ambientlight sensor 41 | Blynk.begin(auth, ssid, pass); 42 | timer.setInterval(100L, lightIntensity); 43 | } 44 | 45 | void loop() 46 | { 47 | Blynk.run(); 48 | timer.run(); 49 | } 50 | -------------------------------------------------------------------------------- /Smart-Notice-Board/circuit-diagram-smart-notice-board.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tech-Trends-Shameer/Esp-8266-Projects/af0a60e690551a543f4bd7d024d9c77b7e09b2e0/Smart-Notice-Board/circuit-diagram-smart-notice-board.png -------------------------------------------------------------------------------- /Smart-Notice-Board/smart-notice-board.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends 2 | //Web Controlled Smart Notice Board 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | LiquidCrystal_I2C lcd(0x27, 16, 2); 11 | 12 | 13 | AsyncWebServer server(80); 14 | 15 | const char* ssid = ""; //wifi ssid 16 | const char* password = ""; //wifi password 17 | 18 | const char* PARAM_INPUT_1 = "input1"; 19 | 20 | const char index_html[] PROGMEM = R"rawliteral( 21 | 22 | Smart Notice Board 23 | 24 |

Web Controlled Smart Notice Board

25 |
26 |
27 | Enter the Text to Display: 28 | 29 |

30 | 31 |
)rawliteral"; 32 | 33 | void notFound(AsyncWebServerRequest *request) { 34 | request->send(404, "text/plain", "Not found"); 35 | } 36 | 37 | void setup() 38 | { 39 | Serial.begin(115200); 40 | Wire.begin(); 41 | lcd.begin(); 42 | lcd.backlight(); 43 | lcd.clear(); 44 | lcd.setCursor(4,0); 45 | lcd.print("Tech Trends "); 46 | 47 | 48 | WiFi.mode(WIFI_STA); 49 | WiFi.begin(ssid, password); 50 | if (WiFi.waitForConnectResult() != WL_CONNECTED) { 51 | Serial.println("WiFi Failed!"); 52 | return; 53 | } 54 | Serial.println(); 55 | Serial.print("IP Address: "); 56 | Serial.println(WiFi.localIP()); 57 | 58 | server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ 59 | request->send_P(200, "text/html", index_html); 60 | }); 61 | 62 | server.on("/get", HTTP_GET, [] (AsyncWebServerRequest *request) { 63 | String message; 64 | String inputParam; 65 | if (request->hasParam(PARAM_INPUT_1)) { 66 | message = request->getParam(PARAM_INPUT_1)->value(); 67 | inputParam = PARAM_INPUT_1; 68 | lcd.clear(); 69 | lcd.setCursor(0,0); 70 | 71 | lcd.print(message); 72 | } 73 | else { 74 | message = "No message sent"; 75 | inputParam = "none"; 76 | } 77 | Serial.println(message); 78 | 79 | request->send(200, "text/html", index_html); 80 | }); 81 | server.onNotFound(notFound); 82 | server.begin(); 83 | } 84 | 85 | void loop() 86 | { 87 | for (int positionCounter = 0; positionCounter < 29; positionCounter++) { 88 | lcd.scrollDisplayLeft(); 89 | delay(500); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /Smart-Waste-Management-Using-ESP8266/smart-waste-management.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3EFXpZo_U" 2 | #define BLYNK_TEMPLATE_NAME "Smart Waste Management" 3 | #define BLYNK_AUTH_TOKEN "Ou4_p5iR3nsNsdp1Ak5MMB5gheXY4qXHPhAeNZ" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | #define TRIGGER_PIN D2 // Ultrasonic sensor trigger pin 10 | #define ECHO_PIN D1 // Ultrasonic sensor echo pin 11 | #define RAIN_SENSOR_PIN D4 // Rain sensor analog pin 12 | int flag=0; 13 | 14 | char auth[] = BLYNK_AUTH_TOKEN; // Blynk authentication token 15 | char ssid[] = "WiFi Username"; // Your WiFi network SSID 16 | char pass[] = "WiFi Password"; // Your WiFi network password 17 | 18 | BlynkTimer timer; 19 | 20 | void setup() { 21 | Serial.begin(9600); 22 | Blynk.begin(auth, ssid, pass); 23 | pinMode(TRIGGER_PIN, OUTPUT); 24 | pinMode(ECHO_PIN, INPUT); 25 | timer.setInterval(5000L, sendSensorData); // Send sensor data every 5 seconds 26 | } 27 | 28 | void loop() { 29 | Blynk.run(); 30 | timer.run(); 31 | } 32 | 33 | void sendSensorData() { 34 | /*long duration, distance; 35 | digitalWrite(TRIGGER_PIN, LOW); 36 | delayMicroseconds(2); 37 | digitalWrite(TRIGGER_PIN, HIGH); 38 | delayMicroseconds(10); 39 | digitalWrite(TRIGGER_PIN, LOW); 40 | duration = pulseIn(ECHO_PIN, HIGH); 41 | distance = (duration/2) / 29.1;*/ 42 | 43 | float distance = getDistance(); // Measure distance in centimeters 44 | int rainValue = digitalRead(RAIN_SENSOR_PIN); 45 | //bool isRaining = rainValue > 50; // Adjust threshold according to the sensitivity of the rain sensor 46 | Serial.println("Distance"); 47 | Serial.print(distance); 48 | Serial.println("Rain"); 49 | Serial.print(rainValue); 50 | // Send waste level and rain status to Blynk 51 | Blynk.virtualWrite(V5, distance); 52 | Blynk.virtualWrite(V6, rainValue); 53 | 54 | // Check if waste bin is full 55 | if (distance < 6) { 56 | Serial.println("Waste bin is full! Please empty it."); 57 | //Blynk.notify("Waste bin is full! Please empty it."); 58 | Blynk.logEvent("waste_alert","Waste bin is full! Please empty it."); 59 | } 60 | 61 | // Check if it's raining 62 | //if (isRaining) { 63 | if (rainValue==0){ 64 | Serial.println("Its Raining"); 65 | //Blynk.notify("It's raining! Please take appropriate action."); 66 | Blynk.logEvent("rain_alert","It's raining! Waste bin is full! Please take appropriate action."); 67 | //flag=1; 68 | } 69 | /*else if (rainValue==1) 70 | { 71 | flag=0; 72 | }*/ 73 | } 74 | 75 | float getDistance() { 76 | digitalWrite(TRIGGER_PIN, LOW); 77 | delayMicroseconds(2); 78 | digitalWrite(TRIGGER_PIN, HIGH); 79 | delayMicroseconds(10); 80 | digitalWrite(TRIGGER_PIN, LOW); 81 | float duration = pulseIn(ECHO_PIN, HIGH); 82 | float distance = duration * 0.034 / 2; // Calculate distance in centimeters 83 | return distance; 84 | } 85 | -------------------------------------------------------------------------------- /Smart-Waste-Management-with-ESP8266-and-Blynk-IoT/smart-waste-management-with-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3EFXpZo_U" 2 | #define BLYNK_TEMPLATE_NAME "Smart Waste Management" 3 | #define BLYNK_AUTH_TOKEN "Ou4_p5iR3ndsNp1Aksdf5MMB5dheX4qXHPhhfkAeNZ" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | #define TRIGGER_PIN D2 // Ultrasonic sensor trigger pin 10 | #define ECHO_PIN D1 // Ultrasonic sensor echo pin 11 | #define RAIN_SENSOR_PIN D4 // Rain sensor analog pin 12 | int flag=0; 13 | 14 | char auth[] = BLYNK_AUTH_TOKEN; // Blynk authentication token 15 | char ssid[] = "WiFi SSID"; // Your WiFi network SSID 16 | char pass[] = " WiFi Password"; // Your WiFi network password 17 | 18 | BlynkTimer timer; 19 | 20 | void setup() { 21 | Serial.begin(9600); 22 | Blynk.begin(auth, ssid, pass); 23 | pinMode(TRIGGER_PIN, OUTPUT); 24 | pinMode(ECHO_PIN, INPUT); 25 | timer.setInterval(5000L, sendSensorData); // Send sensor data every 5 seconds 26 | } 27 | 28 | void loop() { 29 | Blynk.run(); 30 | timer.run(); 31 | } 32 | 33 | void sendSensorData() { 34 | /*long duration, distance; 35 | digitalWrite(TRIGGER_PIN, LOW); 36 | delayMicroseconds(2); 37 | digitalWrite(TRIGGER_PIN, HIGH); 38 | delayMicroseconds(10); 39 | digitalWrite(TRIGGER_PIN, LOW); 40 | duration = pulseIn(ECHO_PIN, HIGH); 41 | distance = (duration/2) / 29.1;*/ 42 | 43 | float distance = getDistance(); // Measure distance in centimeters 44 | int rainValue = digitalRead(RAIN_SENSOR_PIN); 45 | //bool isRaining = rainValue > 50; // Adjust threshold according to the sensitivity of the rain sensor 46 | Serial.println("Distance"); 47 | Serial.print(distance); 48 | Serial.println("Rain"); 49 | Serial.print(rainValue); 50 | // Send waste level and rain status to Blynk 51 | Blynk.virtualWrite(V5, distance); 52 | Blynk.virtualWrite(V6, rainValue); 53 | 54 | // Check if waste bin is full 55 | if (distance < 6) { 56 | Serial.println("Waste bin is full! Please empty it."); 57 | //Blynk.notify("Waste bin is full! Please empty it."); 58 | Blynk.logEvent("waste_alert","Waste bin is full! Please empty it."); 59 | } 60 | 61 | // Check if it's raining 62 | //if (isRaining) { 63 | if (rainValue==0){ 64 | Serial.println("Its Raining"); 65 | //Blynk.notify("It's raining! Please take appropriate action."); 66 | Blynk.logEvent("rain_alert","It's raining! Waste bin is full! Please take appropriate action."); 67 | //flag=1; 68 | } 69 | /*else if (rainValue==1) 70 | { 71 | flag=0; 72 | }*/ 73 | } 74 | 75 | float getDistance() { 76 | digitalWrite(TRIGGER_PIN, LOW); 77 | delayMicroseconds(2); 78 | digitalWrite(TRIGGER_PIN, HIGH); 79 | delayMicroseconds(10); 80 | digitalWrite(TRIGGER_PIN, LOW); 81 | float duration = pulseIn(ECHO_PIN, HIGH); 82 | float distance = duration * 0.034 / 2; // Calculate distance in centimeters 83 | return distance; 84 | } 85 | -------------------------------------------------------------------------------- /Soil-Moisture-Monitoring-System-Using-ThingSpeak-and-ESP8266/soil-moisture-monitoring-system-using-thingspeak-and-esp8266.ino: -------------------------------------------------------------------------------- 1 | #include // Including library for dht 2 | #include "MQ135.h" 3 | #include 4 | 5 | String apiKey = "7BIPDPKPUCdhj62TXsBO"; // Enter your Write API key from ThingSpeak 6 | 7 | const char *ssid = "WiFi Username"; // replace with your wifi ssid and wpa2 key 8 | const char *pass = "WiFi Password"; 9 | const char* server = "api.thingspeak.com"; 10 | const int sensorPin= 0; 11 | 12 | 13 | #define DHTPIN 4 //Connect to GPIO 2 in NodeMCU Board 14 | 15 | 16 | DHT dht(DHTPIN, DHT11); 17 | 18 | WiFiClient client; 19 | 20 | void setup() 21 | { 22 | Serial.begin(115200); 23 | delay(10); 24 | dht.begin(); 25 | 26 | Serial.println("Connecting to "); 27 | Serial.println(ssid); 28 | 29 | 30 | WiFi.begin(ssid, pass); 31 | 32 | while (WiFi.status() != WL_CONNECTED) 33 | { 34 | delay(500); 35 | Serial.print("."); 36 | } 37 | Serial.println(""); 38 | Serial.println("WiFi connected"); 39 | 40 | } 41 | 42 | void loop() 43 | { 44 | int value = analogRead(A0); 45 | value = map(value,400,1023,100,0); 46 | float h = dht.readHumidity(); 47 | float t = dht.readTemperature(); 48 | 49 | 50 | if (client.connect(server,80)) // "184.106.153.149" or api.thingspeak.com 51 | { 52 | 53 | String postStr = apiKey; 54 | postStr +="&field1="; 55 | postStr += String(value); 56 | postStr +="&field2="; 57 | postStr += String(t); 58 | postStr +="&field3="; 59 | postStr += String(h); 60 | postStr += "\r\n\r\n"; 61 | 62 | client.print("POST /update HTTP/1.1\n"); 63 | client.print("Host: api.thingspeak.com\n"); 64 | client.print("Connection: close\n"); 65 | client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n"); 66 | client.print("Content-Type: application/x-www-form-urlencoded\n"); 67 | client.print("Content-Length: "); 68 | client.print(postStr.length()); 69 | client.print("\n\n"); 70 | client.print(postStr); 71 | 72 | Serial.print("Temperature: "); 73 | Serial.print(t); 74 | Serial.print(" degrees Celcius, Humidity: "); 75 | Serial.print(h); 76 | Serial.print("%, Soil Moisture "); 77 | Serial.print(value); 78 | Serial.println("%. Send to Thingspeak."); 79 | } 80 | client.stop(); 81 | 82 | Serial.println("Waiting..."); 83 | 84 | // thingspeak needs minimum 15 sec delay between updates 85 | delay(1000); 86 | } 87 | -------------------------------------------------------------------------------- /Soil-Moisture-Temperature-Humidity-Monitor-Using-ESP8266-and-Blynk-IOT/soil-moisture-temperature--humidity-monitor-using-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3ulW8UBa2" 2 | #define BLYNK_TEMPLATE_NAME "Soil Moisture and Temperature Monitor" 3 | #define BLYNK_AUTH_TOKEN "OmvKhq_3NrKhfjCBwsTDgwDdsgHgK2-QKfds0-Oqm" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | 12 | char auth[] = BLYNK_AUTH_TOKEN; 13 | 14 | char ssid[] = "WiFi Username"; // type your wifi name 15 | char pass[] = "WiFi Password"; // type your wifi password 16 | 17 | BlynkTimer timer; 18 | 19 | 20 | #define DHTPIN 4 //Connect Out pin to D2 in NODE MCU 21 | #define DHTTYPE DHT11 22 | DHT dht(DHTPIN, DHTTYPE); 23 | 24 | 25 | void sendSensor() 26 | { 27 | /*int soilmoisturevalue = analogRead(A0); 28 | soilmoisturevalue = map(soilmoisturevalue, 0, 1023, 0, 100);*/ 29 | int value = analogRead(A0); 30 | value = map(value,400,1023,100,0); 31 | float h = dht.readHumidity(); 32 | float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit 33 | 34 | if (isnan(h) || isnan(t)) { 35 | Serial.println("Failed to read from DHT sensor!"); 36 | return; 37 | } 38 | // You can send any value at any time. 39 | // Please don't send more that 10 values per second. 40 | Blynk.virtualWrite(V0, value); 41 | Blynk.virtualWrite(V1, t); 42 | Blynk.virtualWrite(V2, h); 43 | Serial.print("Soil Moisture : "); 44 | Serial.print(value); 45 | Serial.print("Temperature : "); 46 | Serial.print(t); 47 | Serial.print(" Humidity : "); 48 | Serial.println(h); 49 | } 50 | void setup() 51 | { 52 | 53 | Serial.begin(115200); 54 | 55 | 56 | Blynk.begin(auth, ssid, pass); 57 | dht.begin(); 58 | timer.setInterval(100L, sendSensor); 59 | 60 | } 61 | 62 | void loop() 63 | { 64 | Blynk.run(); 65 | timer.run(); 66 | } 67 | -------------------------------------------------------------------------------- /Store-Temp-Values-in-Database-and-display-values-in-Website/config.php: -------------------------------------------------------------------------------- 1 | connect_errno) { 22 | echo "Connection to database is failed: ".$db->connect_error; 23 | exit(); 24 | } 25 | -------------------------------------------------------------------------------- /Store-Temp-Values-in-Database-and-display-values-in-Website/database.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 4.6.4 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- Generation Time: Jan 19, 2022 at 03:47 PM 6 | -- PHP Version: 5.5.38 7 | 8 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 9 | SET time_zone = "+00:00"; 10 | 11 | 12 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 13 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 14 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 15 | /*!40101 SET NAMES utf8mb4 */; 16 | 17 | -- 18 | -- Database: `3881360_esp32db` 19 | -- 20 | 21 | -- -------------------------------------------------------- 22 | 23 | -- 24 | -- Table structure for table `tbl_temperature` 25 | -- 26 | 27 | CREATE TABLE `tbl_temperature` ( 28 | `id` int(11) NOT NULL, 29 | `temperature` float NOT NULL, 30 | `humidity` float NOT NULL, 31 | `created_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP 32 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 33 | 34 | 35 | -- 36 | -- Indexes for dumped tables 37 | -- 38 | 39 | -- 40 | -- Indexes for table `tbl_temperature` 41 | -- 42 | ALTER TABLE `tbl_temperature` 43 | ADD PRIMARY KEY (`id`); 44 | 45 | -- 46 | -- AUTO_INCREMENT for dumped tables 47 | -- 48 | 49 | -- 50 | -- AUTO_INCREMENT for table `tbl_temperature` 51 | -- 52 | ALTER TABLE `tbl_temperature` 53 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=56; 54 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 55 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 56 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 57 | -------------------------------------------------------------------------------- /Store-Temp-Values-in-Database-and-display-values-in-Website/esp8266-dht11-mysql.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Store the temperature and humidity value in database and display values in website 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | //------------------------------------------------------------------- 9 | #include 10 | #define DHT11_PIN D4 11 | #define DHTTYPE DHT11 12 | 13 | DHT dht(DHT11_PIN, DHTTYPE); 14 | //------------------------------------------------------------------- 15 | //enter WIFI credentials 16 | const char* ssid = "WiFi Username"; 17 | const char* password = "WiFi Password"; 18 | //------------------------------------------------------------------- 19 | //enter domain name and path 20 | //http://www.example.com/sensordata.php 21 | const char* SERVER_NAME = "http://techtrends.etechnopark.com/sensordata.php"; 22 | 23 | //PROJECT_API_KEY is the exact duplicate of, PROJECT_API_KEY in config.php file 24 | //Both values must be same 25 | String PROJECT_API_KEY = "5fsdsf2ev5FF"; 26 | //------------------------------------------------------------------- 27 | //Send an HTTP POST request every 30 seconds 28 | unsigned long lastMillis = 0; 29 | long interval = 5000; 30 | //------------------------------------------------------------------- 31 | 32 | /* 33 | * ******************************************************************* 34 | * setup() function 35 | * ******************************************************************* 36 | */ 37 | void setup() { 38 | 39 | //----------------------------------------------------------------- 40 | Serial.begin(115200); 41 | Serial.println("esp32 serial initialize"); 42 | //----------------------------------------------------------------- 43 | dht.begin(); 44 | Serial.println("initialize DHT11"); 45 | //----------------------------------------------------------------- 46 | WiFi.begin(ssid, password); 47 | Serial.println("Connecting"); 48 | while(WiFi.status() != WL_CONNECTED) { 49 | delay(500); 50 | Serial.print("."); 51 | } 52 | Serial.println(""); 53 | Serial.print("Connected to WiFi network with IP Address: "); 54 | Serial.println(WiFi.localIP()); 55 | 56 | Serial.println("Timer set to 5 seconds (timerDelay variable),"); 57 | Serial.println("it will take 5 seconds before publishing the first reading."); 58 | //----------------------------------------------------------------- 59 | } 60 | 61 | 62 | /* 63 | * ******************************************************************* 64 | * setup() function 65 | * ******************************************************************* 66 | */ 67 | void loop() { 68 | 69 | //----------------------------------------------------------------- 70 | //Check WiFi connection status 71 | if(WiFi.status()== WL_CONNECTED){ 72 | if(millis() - lastMillis > interval) { 73 | //Send an HTTP POST request every interval seconds 74 | upload_temperature(); 75 | lastMillis = millis(); 76 | } 77 | } 78 | //----------------------------------------------------------------- 79 | else { 80 | Serial.println("WiFi Disconnected"); 81 | } 82 | //----------------------------------------------------------------- 83 | 84 | delay(1000); 85 | } 86 | 87 | 88 | void upload_temperature() 89 | { 90 | //-------------------------------------------------------------------------------- 91 | //Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 92 | //Read temperature as Celsius (the default) 93 | float t = dht.readTemperature(); 94 | 95 | float h = dht.readHumidity(); 96 | 97 | if (isnan(h) || isnan(t)) { 98 | Serial.println(F("Failed to read from DHT sensor!")); 99 | return; 100 | } 101 | 102 | //Compute heat index in Celsius (isFahreheit = false) 103 | float hic = dht.computeHeatIndex(t, h, false); 104 | //-------------------------------------------------------------------------------- 105 | //°C 106 | String humidity = String(h, 2); 107 | String temperature = String(t, 2); 108 | String heat_index = String(hic, 2); 109 | 110 | Serial.println("Temperature: "+temperature); 111 | Serial.println("Humidity: "+humidity); 112 | //Serial.println(heat_index); 113 | Serial.println("--------------------------"); 114 | //-------------------------------------------------------------------------------- 115 | //HTTP POST request data 116 | String temperature_data; 117 | temperature_data = "api_key="+PROJECT_API_KEY; 118 | temperature_data += "&temperature="+temperature; 119 | temperature_data += "&humidity="+humidity; 120 | 121 | Serial.print("temperature_data: "); 122 | Serial.println(temperature_data); 123 | //-------------------------------------------------------------------------------- 124 | 125 | WiFiClient client; 126 | HTTPClient http; 127 | 128 | http.begin(client, SERVER_NAME); 129 | // Specify content-type header 130 | http.addHeader("Content-Type", "application/x-www-form-urlencoded"); 131 | // Send HTTP POST request 132 | int httpResponseCode = http.POST(temperature_data); 133 | //-------------------------------------------------------------------------------- 134 | // If you need an HTTP request with a content type: 135 | //application/json, use the following: 136 | //http.addHeader("Content-Type", "application/json"); 137 | //temperature_data = "{\"api_key\":\""+PROJECT_API_KEY+"\","; 138 | //temperature_data += "\"temperature\":\""+temperature+"\","; 139 | //temperature_data += "\"humidity\":\""+humidity+"\""; 140 | //temperature_data += "}"; 141 | //int httpResponseCode = http.POST(temperature_data); 142 | //-------------------------------------------------------------------------------- 143 | // If you need an HTTP request with a content type: text/plain 144 | //http.addHeader("Content-Type", "text/plain"); 145 | //int httpResponseCode = http.POST("Hello, World!"); 146 | //-------------------------------------------------------------------------------- 147 | Serial.print("HTTP Response code: "); 148 | Serial.println(httpResponseCode); 149 | 150 | // Free resources 151 | http.end(); 152 | } 153 | -------------------------------------------------------------------------------- /Store-Temp-Values-in-Database-and-display-values-in-Website/getdata.php: -------------------------------------------------------------------------------- 1 | query($sql); 6 | if (!$result) { 7 | { echo "Error: " . $sql . "
" . $db->error; } 8 | } 9 | 10 | $row = $result->fetch_assoc(); 11 | 12 | //$rows = $result -> fetch_all(MYSQLI_ASSOC); 13 | //print_r($row); 14 | 15 | //header('Content-Type: application/json'); 16 | 17 | //$table=array(0=>array('Label','Value'),1=>array('Temperature',$row)); 18 | 19 | 20 | echo json_encode($row); 21 | 22 | 23 | ?> 24 | -------------------------------------------------------------------------------- /Store-Temp-Values-in-Database-and-display-values-in-Website/sensordata.php: -------------------------------------------------------------------------------- 1 | PROJECT_API_KEY: ".PROJECT_API_KEY."
"; 11 | //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 12 | if($api_key == PROJECT_API_KEY) { 13 | $temperature = escape_data($_POST["temperature"]); 14 | $humidity = escape_data($_POST["humidity"]); 15 | 16 | $sql = "INSERT INTO tbl_temperature(temperature,humidity,created_date) 17 | VALUES('".$temperature."','".$humidity."','".date("Y-m-d H:i:s")."')"; 18 | 19 | if($db->query($sql) === FALSE) 20 | { echo "Error: " . $sql . "
" . $db->error; } 21 | 22 | echo "OK. INSERT ID: "; 23 | echo $db->insert_id; 24 | } 25 | //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 26 | else 27 | { 28 | echo "Wrong API Key"; 29 | } 30 | //MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 31 | } 32 | //---------------------------------------------------------------------------- 33 | else 34 | { 35 | echo "No HTTP POST request found"; 36 | } 37 | //---------------------------------------------------------------------------- 38 | 39 | 40 | function escape_data($data) { 41 | $data = trim($data); 42 | $data = stripslashes($data); 43 | $data = htmlspecialchars($data); 44 | return $data; 45 | } 46 | -------------------------------------------------------------------------------- /Temperature-Alert-Notification-Using-Blynk-IOT/temperature-alert-notification-using-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TemplateID" 2 | #define BLYNK_DEVICE_NAME "Temperature Alert" 3 | #define BLYNK_AUTH_TOKEN "Auth Token" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | 10 | #include 11 | 12 | char auth[] = BLYNK_AUTH_TOKEN; 13 | 14 | char ssid[] = "WiFi Username"; // type your wifi name 15 | char pass[] = "WiFi Password"; // type your wifi password 16 | 17 | #define DHTPIN 2 // Mention the digital pin where you connected 18 | #define DHTTYPE DHT11 // DHT 11 19 | DHT dht(DHTPIN, DHTTYPE); 20 | BlynkTimer timer; 21 | 22 | void sendSensor(){ 23 | float h = dht.readHumidity(); 24 | float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit 25 | if (isnan(h) || isnan(t)) { 26 | Serial.println("Failed to read from DHT sensor!"); 27 | return; 28 | } 29 | 30 | Serial.println(t); 31 | Blynk.virtualWrite(V6, h); 32 | Blynk.virtualWrite(V5, t); 33 | Serial.print("Temperature : "); 34 | Serial.print(t); 35 | Serial.print(" Humidity : "); 36 | Serial.println(h); 37 | 38 | 39 | if(t > 30){ 40 | // Blynk.email("shameer50@gmail.com", "Alert", "Temperature over 28C!"); 41 | Blynk.logEvent("temp_alert","Temp above 30 degree"); 42 | } 43 | } 44 | 45 | void setup(){ 46 | Serial.begin(115200); 47 | Blynk.begin(auth, ssid, pass); 48 | dht.begin(); 49 | timer.setInterval(2500L, sendSensor); 50 | } 51 | 52 | void loop(){ 53 | Blynk.run(); 54 | timer.run(); 55 | } 56 | -------------------------------------------------------------------------------- /Temperature-Controlled-Fan-Using-ESP8266-and-Blynk-IOT/temperature-controlled-fan-using-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPLdfjjjN1j6tcU" 2 | #define BLYNK_TEMPLATE_NAME "Temperature Controlled Fan" 3 | #define BLYNK_AUTH_TOKEN "RpDQKdkghjfjl0M6merI-z-V-Ix4zrzG5cvW5gb" 4 | 5 | #define BLYNK_PRINT Serial 6 | 7 | #include 8 | #include 9 | #include 10 | #define DHTPIN D5 // Digital pin connected to the DHT sensor 11 | 12 | // Uncomment whatever type you're using! 13 | #define DHTTYPE DHT11 // DHT 11 14 | //#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 15 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 16 | #define FAN_PIN D2 // FAN RELAY 17 | 18 | 19 | char auth[] = BLYNK_AUTH_TOKEN; 20 | char ssid[] = "Wifi Username"; 21 | char pass[] = "Wifi Password"; 22 | 23 | float humDHT = 0; 24 | float tempDHT = 0; 25 | 26 | 27 | // Initialize DHT sensor. 28 | DHT dht(DHTPIN, DHTTYPE); 29 | 30 | void setup() { 31 | Serial.begin(115200); 32 | pinMode(FAN_PIN, OUTPUT); 33 | digitalWrite(FAN_PIN, LOW); 34 | Serial.println(F("DHTxx test!")); 35 | dht.begin(); 36 | Blynk.begin( auth, ssid , pass ); 37 | } 38 | 39 | 40 | void loop() { 41 | 42 | Blynk.run(); 43 | 44 | // Wait a few seconds between measurements. 45 | delay(2000); 46 | 47 | // Reading temperature or humidity takes about 250 milliseconds! 48 | // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) 49 | humDHT = dht.readHumidity(); 50 | // Read temperature as Celsius (the default) 51 | tempDHT = dht.readTemperature(); 52 | 53 | // Check if any reads failed and exit early (to try again). 54 | if (isnan(humDHT) || isnan(tempDHT)) 55 | { 56 | Serial.println("Failed to read from DHT sensor!"); 57 | return; 58 | } 59 | 60 | Serial.print(F("Temperature: ")); 61 | Serial.print(tempDHT); 62 | Serial.print(F("°C ")); 63 | Serial.println(); 64 | Serial.print(F("Humidity: ")); 65 | Serial.print(humDHT); 66 | Serial.print(F("%")); 67 | Serial.println(); 68 | 69 | Serial.println("***********************"); 70 | Serial.println(); 71 | 72 | // Compare Threshold value from Blynk and DHT Temperature value. 73 | if (tempDHT>31) 74 | { 75 | digitalWrite(FAN_PIN, HIGH); 76 | 77 | } 78 | else { 79 | digitalWrite(FAN_PIN, LOW); 80 | 81 | 82 | } 83 | 84 | Blynk.virtualWrite(V1, tempDHT); 85 | Blynk.virtualWrite(V2, humDHT); 86 | } 87 | -------------------------------------------------------------------------------- /Temperature-Data-Logger-in-Google-Spreadsheet/GoogleScript.js: -------------------------------------------------------------------------------- 1 | // All Rights Reserved. 2 | // Github: https://github.com/electronicsguy 3 | // 4 | // Read/Write to Google Sheets using REST API. 5 | // Can be used with ESP8266 & other embedded IoT devices. 6 | // 7 | // Use this file with the ESP8266 library HTTPSRedirect 8 | // 9 | // doGet() and doPost() need the spreadsheet ID. Cannot use "active spreadsheet" here since 10 | // the device can operate without the spreadsheet even being open. 11 | // http://stackoverflow.com/questions/4024271/rest-api-best-practices-where-to-put-parameters 12 | // http://trevorfox.com/2015/03/rest-api-with-google-apps-script 13 | 14 | // Similar API docs: 15 | // https://gspread.readthedocs.org/en/latest/ 16 | // https://smartsheet-platform.github.io/api-docs/#versioning-and-changes 17 | // http://search.cpan.org/~jmcnamara/Excel-Writer-XLSX/lib/Excel/Writer/XLSX.pm 18 | 19 | // http://forum.espruino.com/conversations/269510/ 20 | // http://stackoverflow.com/questions/34691425/difference-between-getvalue-and-getdisplayvalue-on-google-app-script 21 | // http://ramblings.mcpher.com/Home/excelquirks/gooscript/optimize 22 | 23 | // Things to remember with getValue() object format: 24 | // 1. Partial dates or times-only will be replaced with a full date + time, probably in the 25 | // year 1989. Like this: Sat Dec 30 1899 08:09:00 GMT-0500 (EST) 26 | // 2. Dollar ($) currency symbol will be absent if cell contains currency. 27 | // This may be locale-dependent. 28 | // 3. Scientific notation will be replaced by decimal numbers like this: 0.0000055 29 | 30 | // Script examples 31 | // https://developers.google.com/adwords/scripts/docs/examples/spreadsheetapp 32 | 33 | var SS = SpreadsheetApp.openById('1VQc8FKEsdeADAcw8kn_Wzpv2qZIwT-F_psfsDDbFzF9fY'); //Enter Your Sheet ID Got From Sheet URL Link 34 | var sheet = SS.getSheetByName('Temp_Data_Sheet'); // Enter your sheet name here, In my case it is Temp_Data_Sheet 35 | var str = ""; 36 | 37 | function onOpen(){ 38 | var ui = SpreadsheetApp.getUi(); 39 | ui.createMenu('ESP8266_Temp_Data_Logger') 40 | .addItem('Clear', 'Clear') 41 | .addToUi(); 42 | } 43 | 44 | function Clear(){ 45 | sheet.deleteRows(4, sheet.getLastRow()); 46 | SS.toast('Chart cleared', 'ESP8266_Temp_Data_Logger', 5); 47 | } 48 | 49 | function doPost(e) { 50 | 51 | var parsedData; 52 | var result = {}; 53 | 54 | try { 55 | parsedData = JSON.parse(e.postData.contents); 56 | } 57 | catch(f){ 58 | return ContentService.createTextOutput("Error in parsing request body: " + f.message); 59 | } 60 | 61 | if (parsedData !== undefined){ 62 | // Common items first 63 | // data format: 0 = display value(literal), 1 = object value 64 | var flag = parsedData.format; 65 | 66 | if (flag === undefined){ 67 | flag = 0; 68 | } 69 | 70 | switch (parsedData.command) { 71 | case "appendRow": 72 | var tmp = SS.getSheetByName(parsedData.sheet_name); 73 | var nextFreeRow = tmp.getLastRow() + 1; 74 | var dataArr = parsedData.values.split(","); 75 | 76 | tmp.appendRow(dataArr); 77 | 78 | str = "Success"; 79 | SpreadsheetApp.flush(); 80 | break; 81 | 82 | 83 | } 84 | 85 | return ContentService.createTextOutput(str); 86 | } // endif (parsedData !== undefined) 87 | 88 | else{ 89 | return ContentService.createTextOutput("Error! Request body empty or in incorrect format."); 90 | } 91 | 92 | 93 | } 94 | 95 | 96 | function doGet(e){ 97 | 98 | var val = e.parameter.value; 99 | var cal = e.parameter.cal; 100 | var read = e.parameter.read; 101 | 102 | if (cal !== undefined){ 103 | return ContentService.createTextOutput(GetEventsOneWeek()); 104 | } 105 | 106 | if (read !== undefined){ 107 | var now = Utilities.formatDate(new Date(), "EST", "yyyy-MM-dd'T'hh:mm a'Z'").slice(11,19); 108 | //sheet.getRange('D1').setValue(now); 109 | //var count = (sheet.getRange('C1').getValue()) + 1; 110 | sheet.getRange('C1').setValue(count); 111 | return ContentService.createTextOutput(sheet.getRange('A1').getValue()); 112 | } 113 | 114 | if (e.parameter.value === undefined) 115 | return ContentService.createTextOutput("No value passed as argument to script Url."); 116 | 117 | var range = sheet.getRange('A1'); 118 | var retval = range.setValue(val).getValue(); 119 | var now = Utilities.formatDate(new Date(), "EST", "yyyy-MM-dd'T'hh:mm a'Z'").slice(11,19); 120 | // sheet.getRange('B1').setValue(now); 121 | sheet.getRange('B1').setValue("Humidity"); 122 | //sheet.getRange('C1').setValue('0'); 123 | 124 | if (retval == e.parameter.value) 125 | return ContentService.createTextOutput("Successfully wrote: " + e.parameter.value + "\ninto spreadsheet."); 126 | else 127 | return ContentService.createTextOutput("Unable to write into spreadsheet.\nCheck authentication and make sure the cursor is not on cell 'A1'." + retval + ' ' + e.parameter.value); 128 | } 129 | 130 | function GetEventsOneWeek(){ 131 | var Cal = CalendarApp.getCalendarsByName('Test REST API')[0]; 132 | // Need to create 2 separate Date() objects. Cannot do 'OneWeekFromNow = Nowjs' to 133 | // simply get it's value and use that later without modifying 'Now' 134 | // since in JS, an object is automatically passed by reference 135 | var Now = new Date(); 136 | var OneWeekFromNow = new Date(); 137 | OneWeekFromNow.setDate(Now.getDate() + 7); 138 | //Logger.log(Now); 139 | //Logger.log(OneWeekFromNow); 140 | var events = Cal.getEvents(Now, OneWeekFromNow); 141 | //Logger.log(events.length); 142 | var str = '\nEvent Title,\tDescription,\tRecurring?,\tAll-day?,\tFirst Reminder (in minutes before event)\n'; 143 | for (var i = 0; i < events.length; i++){ 144 | str += events[i].getTitle() + ',\t' + events[i].getDescription() + ',\t' + events[i].isRecurringEvent() + ',\t' + events[i].isAllDayEvent() + ',\t' + events[i].getPopupReminders()[0]; 145 | str += '\n'; 146 | } 147 | //Logger.log(str); 148 | return str; 149 | } 150 | -------------------------------------------------------------------------------- /Temperature-Data-Logger-in-Google-Spreadsheet/temperature-data-logger-in-google-spreadsheet.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include "HTTPSRedirect.h" 3 | #include "DebugMacros.h" 4 | #include 5 | 6 | #define DHTPIN D4 // what digital pin we're connected to 7 | #define DHTTYPE DHT11 // select dht type as DHT 11 or DHT22 8 | DHT dht(DHTPIN, DHTTYPE); 9 | 10 | float h; 11 | float t; 12 | String sheetHumid = ""; 13 | String sheetTemp = ""; 14 | 15 | const char* ssid = "WiFi Username"; //replace with our wifi ssid 16 | const char* password = "WiFi Password"; //replace with your wifi password 17 | 18 | const char* host = "script.google.com"; 19 | const char *GScriptId = "AKfycbyTsstjphq6_bBazOsHZ3aOb4p-iOpBtAcMlWIv8X83w-8frMIOGhlTBOnQpe234Qto"; // Replace with your own google script id 20 | const int httpsPort = 443; //the https port is same 21 | 22 | // echo | openssl s_client -connect script.google.com:443 |& openssl x509 -fingerprint -noout 23 | const char* fingerprint = ""; 24 | 25 | //const uint8_t fingerprint[20] = {}; 26 | 27 | String url = String("/macros/s/") + GScriptId + "/exec?value=Temperature"; // Write Teperature to Google Spreadsheet at cell A1 28 | // Fetch Google Calendar events for 1 week ahead 29 | String url2 = String("/macros/s/") + GScriptId + "/exec?cal"; // Write to Cell A continuosly 30 | 31 | //replace with sheet name not with spreadsheet file name taken from google 32 | String payload_base = "{\"command\": \"appendRow\", \ 33 | \"sheet_name\": \"Temp_Data_Sheet\", \ 34 | \"values\": "; 35 | String payload = ""; 36 | 37 | HTTPSRedirect* client = nullptr; 38 | 39 | // used to store the values of free stack and heap before the HTTPSRedirect object is instantiated 40 | // so that they can be written to Google sheets upon instantiation 41 | 42 | void setup() { 43 | delay(1000); 44 | Serial.begin(115200); 45 | dht.begin(); //initialise DHT11 46 | 47 | Serial.println(); 48 | Serial.print("Connecting to wifi: "); 49 | Serial.println(ssid); 50 | 51 | WiFi.begin(ssid, password); 52 | while (WiFi.status() != WL_CONNECTED) { 53 | delay(500); 54 | Serial.print("."); 55 | } 56 | Serial.println(""); 57 | Serial.println("WiFi connected"); 58 | Serial.println("IP address: "); 59 | Serial.println(WiFi.localIP()); 60 | 61 | // Use HTTPSRedirect class to create a new TLS connection 62 | client = new HTTPSRedirect(httpsPort); 63 | client->setInsecure(); 64 | client->setPrintResponseBody(true); 65 | client->setContentTypeHeader("application/json"); 66 | Serial.print("Connecting to "); 67 | Serial.println(host); //try to connect with "script.google.com" 68 | 69 | // Try to connect for a maximum of 5 times then exit 70 | bool flag = false; 71 | for (int i = 0; i < 5; i++) { 72 | int retval = client->connect(host, httpsPort); 73 | if (retval == 1) { 74 | flag = true; 75 | break; 76 | } 77 | else 78 | Serial.println("Connection failed. Retrying..."); 79 | } 80 | 81 | if (!flag) { 82 | Serial.print("Could not connect to server: "); 83 | Serial.println(host); 84 | Serial.println("Exiting..."); 85 | return; 86 | } 87 | // Finish setup() function in 1s since it will fire watchdog timer and will reset the chip. 88 | //So avoid too many requests in setup() 89 | 90 | Serial.println("\nWrite into cell 'A1'"); 91 | Serial.println("------>"); 92 | // fetch spreadsheet data 93 | client->GET(url, host); 94 | 95 | Serial.println("\nGET: Fetch Google Calendar Data:"); 96 | Serial.println("------>"); 97 | // fetch spreadsheet data 98 | client->GET(url2, host); 99 | 100 | Serial.println("\nStart Sending Sensor Data to Google Spreadsheet"); 101 | 102 | 103 | // delete HTTPSRedirect object 104 | delete client; 105 | client = nullptr; 106 | } 107 | 108 | void loop() { 109 | 110 | h = dht.readHumidity(); // Reading temperature or humidity takes about 250 milliseconds! 111 | t = dht.readTemperature(); // Read temperature as Celsius (the default) 112 | if (isnan(h) || isnan(t)) { // Check if any reads failed and exit early (to try again). 113 | Serial.println(F("Failed to read from DHT sensor!")); 114 | return; 115 | } 116 | Serial.print("Humidity: "); Serial.print(h); 117 | sheetHumid = String(h) + String("%"); //convert integer humidity to string humidity 118 | Serial.print("% Temperature: "); Serial.print(t); Serial.println("°C "); 119 | sheetTemp = String(t) + String("°C"); 120 | 121 | static int error_count = 0; 122 | static int connect_count = 0; 123 | const unsigned int MAX_CONNECT = 20; 124 | static bool flag = false; 125 | 126 | payload = payload_base + "\"" + sheetTemp + "," + sheetHumid + "\"}"; 127 | 128 | if (!flag) { 129 | client = new HTTPSRedirect(httpsPort); 130 | client->setInsecure(); 131 | flag = true; 132 | client->setPrintResponseBody(true); 133 | client->setContentTypeHeader("application/json"); 134 | } 135 | 136 | if (client != nullptr) { 137 | if (!client->connected()) { 138 | client->connect(host, httpsPort); 139 | client->POST(url2, host, payload, false); 140 | Serial.print("Sent : "); Serial.println("Temp and Humid"); 141 | } 142 | } 143 | else { 144 | DPRINTLN("Error creating client object!"); 145 | error_count = 5; 146 | } 147 | 148 | if (connect_count > MAX_CONNECT) { 149 | connect_count = 0; 150 | flag = false; 151 | delete client; 152 | return; 153 | } 154 | 155 | // Serial.println("GET Data from cell 'A1':"); 156 | // if (client->GET(url3, host)) { 157 | // ++connect_count; 158 | // } 159 | // else { 160 | // ++error_count; 161 | // DPRINT("Error-count while connecting: "); 162 | // DPRINTLN(error_count); 163 | // } 164 | 165 | Serial.println("POST or SEND Sensor data to Google Spreadsheet:"); 166 | if (client->POST(url2, host, payload)) { 167 | ; 168 | } 169 | else { 170 | ++error_count; 171 | DPRINT("Error-count while connecting: "); 172 | DPRINTLN(error_count); 173 | } 174 | 175 | if (error_count > 3) { 176 | Serial.println("Halting processor..."); 177 | delete client; 178 | client = nullptr; 179 | Serial.printf("Final free heap: %u\n", ESP.getFreeHeap()); 180 | Serial.printf("Final stack: %u\n", ESP.getFreeContStack()); 181 | Serial.flush(); 182 | ESP.deepSleep(0); 183 | } 184 | delay(3000); // keep delay of minimum 2 seconds as dht allow reading after 2 seconds interval and also for google sheet 185 | } 186 | -------------------------------------------------------------------------------- /Temperature-Monitor-Using-DS18B20-and-Blynk-IOT/temperature-monitor-using-DS18B20-and-blynk-iot.io: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Temperature Monitor Using DS18B20 Sensor 3 | 4 | 5 | #define BLYNK_TEMPLATE_ID "TMPL3OfhkabXlCDa2" 6 | #define BLYNK_TEMPLATE_NAME "Temperature Monitor Using DS18B20 Sensor" 7 | #define BLYNK_AUTH_TOKEN "xXwigkJWCXLYcofdgnjIwa_bZdn6CJ5Qnkv_o" 8 | 9 | 10 | #define BLYNK_PRINT Serial 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #define DS18B20 4 //Connect to GPIO2 pin 18 | OneWire ourWire(DS18B20); 19 | DallasTemperature sensor(&ourWire); 20 | 21 | char auth[] = BLYNK_AUTH_TOKEN; 22 | 23 | 24 | char ssid[] = ""; // Enter your wifi name 25 | char pass[] = ""; // Enter your wifi password 26 | 27 | BlynkTimer timer; 28 | 29 | void sendSensor() 30 | { 31 | // Request temperature to all devices on the data line 32 | sensor.requestTemperatures(); 33 | 34 | Serial.print("Celsius temperature: "); 35 | //We can connect more than one IC on the same data wire. 0 refers to the first IC on the wire 36 | Serial.print(sensor.getTempCByIndex(0)); 37 | Serial.print(" - Fahrenheit temperature: "); 38 | Serial.println(sensor.getTempFByIndex(0)); 39 | int tempC=sensor.getTempCByIndex(0); 40 | int tempF=sensor.getTempFByIndex(0); 41 | delay(1000); 42 | 43 | // You can send any value at any time. 44 | // Please don't send more that 10 values per second. 45 | Blynk.virtualWrite(V0, tempC); 46 | Blynk.virtualWrite(V1, tempF); 47 | delay(500); 48 | } 49 | void setup() 50 | { 51 | 52 | Serial.begin(9600); 53 | sensor.begin(); 54 | 55 | Blynk.begin(auth, ssid, pass); 56 | timer.setInterval(100L, sendSensor); 57 | 58 | } 59 | 60 | void loop() 61 | { 62 | Blynk.run(); 63 | timer.run(); 64 | } 65 | -------------------------------------------------------------------------------- /Temperature-Monitor-Using-ThingSpeak/temperature-monitor-using-thingspeak.ino: -------------------------------------------------------------------------------- 1 | #include // Including library for dht 2 | 3 | #include 4 | 5 | String apiKey = "LYP6TUEEUfhjjjjO64MVHV"; // Enter your Write API key from ThingSpeak 6 | 7 | const char *ssid = ""; // replace with your wifi ssid and wpa2 key 8 | const char *pass = ""; 9 | const char* server = "api.thingspeak.com"; 10 | 11 | #define DHTPIN 4 //pin where the dht11 is connected 12 | 13 | DHT dht(DHTPIN, DHT11); 14 | 15 | WiFiClient client; 16 | 17 | void setup() 18 | { 19 | Serial.begin(115200); 20 | delay(10); 21 | dht.begin(); 22 | 23 | Serial.println("Connecting to "); 24 | Serial.println(ssid); 25 | 26 | 27 | WiFi.begin(ssid, pass); 28 | 29 | while (WiFi.status() != WL_CONNECTED) 30 | { 31 | delay(500); 32 | Serial.print("."); 33 | } 34 | Serial.println(""); 35 | Serial.println("WiFi connected"); 36 | 37 | } 38 | 39 | void loop() 40 | { 41 | 42 | float h = dht.readHumidity(); 43 | float t = dht.readTemperature(); 44 | 45 | if (isnan(h) || isnan(t)) 46 | { 47 | Serial.println("Failed to read from DHT sensor!"); 48 | return; 49 | } 50 | 51 | if (client.connect(server,80)) // "184.106.153.149" or api.thingspeak.com 52 | { 53 | 54 | String postStr = apiKey; 55 | postStr +="&field1="; 56 | postStr += String(t); 57 | postStr +="&field2="; 58 | postStr += String(h); 59 | postStr += "\r\n\r\n"; 60 | 61 | client.print("POST /update HTTP/1.1\n"); 62 | client.print("Host: api.thingspeak.com\n"); 63 | client.print("Connection: close\n"); 64 | client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n"); 65 | client.print("Content-Type: application/x-www-form-urlencoded\n"); 66 | client.print("Content-Length: "); 67 | client.print(postStr.length()); 68 | client.print("\n\n"); 69 | client.print(postStr); 70 | 71 | Serial.print("Temperature: "); 72 | Serial.print(t); 73 | Serial.print(" degrees Celcius, Humidity: "); 74 | Serial.print(h); 75 | Serial.println("%. Send to Thingspeak."); 76 | } 77 | client.stop(); 78 | 79 | Serial.println("Waiting..."); 80 | 81 | // thingspeak needs minimum 15 sec delay between updates 82 | delay(1000); 83 | } 84 | -------------------------------------------------------------------------------- /Temperature-Monitor-Using-WhatsApp/temperature-monitor-using-whatsapp.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Temperature Monitor Using Whatsapp 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define DHTPIN 2 9 | #define DHTTYPE DHT11 // DHT 11 10 | DHT dht(DHTPIN, DHTTYPE); 11 | 12 | ThingESP8266 thing("Username", "ProjectName", "ProjectUserName"); 13 | 14 | //int LED = D2; 15 | 16 | unsigned long previousMillis = 0; 17 | const long INTERVAL = 6000; 18 | 19 | void setup() 20 | { 21 | Serial.begin(115200); 22 | 23 | // pinMode(LED, OUTPUT); 24 | 25 | thing.SetWiFi("WiFiUsername", "WiFiPassword"); 26 | 27 | thing.initDevice(); 28 | 29 | } 30 | 31 | 32 | String HandleResponse(String query) 33 | { 34 | 35 | float h = dht.readHumidity(); 36 | // Read temperature as Celsius (the default) 37 | float t = dht.readTemperature(); 38 | // Read temperature as Fahrenheit (isFahrenheit = true) 39 | float f = dht.readTemperature(true); 40 | Serial.println("Temperature :"); 41 | Serial.print(t); 42 | Serial.println("Humidity"); 43 | Serial.print(h); 44 | String humid = "Humidity: " + String(h) + " % \n"; 45 | String temp = "Temperature: " + String(t) + "°C, " + String(f) + "°F \n"; 46 | 47 | 48 | if (query == "temperature") { 49 | 50 | return temp; 51 | } 52 | 53 | else if (query == "humidity") { 54 | 55 | return humid; 56 | } 57 | 58 | else return "Your query was invalid.."; 59 | 60 | } 61 | 62 | 63 | void loop() 64 | { 65 | 66 | thing.Handle(); 67 | 68 | } 69 | 70 | 71 | -------------------------------------------------------------------------------- /Temperature-Pressure-Altitude-Monitor-Using-ESP8266-Blynk-IOT/temperature-pressure-altitude-blynk-iot-esp8266-blynkiot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPLfzdfdKVm-c6" 2 | #define BLYNK_DEVICE_NAME "Temp Pressure and Altitude Monitor" 3 | #define BLYNK_AUTH_TOKEN "LM6X0cjOSutdfdhhhwI7AnoYCwj0kLFLvZENGn" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | 12 | #define BMP_SCK (13) 13 | #define BMP_MISO (12) 14 | #define BMP_MOSI (11) 15 | #define BMP_CS (10) 16 | 17 | Adafruit_BMP280 bmp; // I2C 18 | //Adafruit_BMP280 bmp(BMP_CS); // hardware SPI 19 | //Adafruit_BMP280 bmp(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK); 20 | 21 | 22 | char auth[] = BLYNK_AUTH_TOKEN; 23 | 24 | char ssid[] = ""; // type your wifi name 25 | char pass[] = ""; // type your wifi password 26 | 27 | BlynkTimer timer; 28 | 29 | void sendSensor() 30 | { 31 | 32 | float temp = bmp.readTemperature(); 33 | float pressure = bmp.readPressure(); 34 | float alt = bmp.readAltitude(1013.25); 35 | 36 | Serial.print(F("Temperature = ")); 37 | Serial.print(temp); 38 | Serial.println(" *C"); 39 | 40 | Serial.print(F("Pressure = ")); 41 | Serial.print(pressure); 42 | Serial.println(" Pa"); 43 | 44 | Serial.print(F("Approx altitude = ")); 45 | Serial.print(alt); /* Adjusted to local forecast! */ 46 | Serial.println(" m"); 47 | 48 | 49 | // You can send any value at any time. 50 | // Please don't send more that 10 values per second. 51 | Blynk.virtualWrite(V0, temp); 52 | Blynk.virtualWrite(V1, pressure); 53 | Blynk.virtualWrite(V2, alt); 54 | Serial.print("Temperature : "); 55 | Serial.print(temp); 56 | Serial.print(" Pressure : "); 57 | Serial.print(pressure); 58 | Serial.print(" Altitude : "); 59 | Serial.println(alt); 60 | } 61 | void setup() 62 | { 63 | 64 | Serial.begin(115200); 65 | 66 | 67 | Blynk.begin(auth, ssid, pass); 68 | //dht.begin(); 69 | Serial.println(F("BMP280 test")); 70 | 71 | if (!bmp.begin(0x76)) { 72 | Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); 73 | while (1); 74 | } 75 | 76 | /* Default settings from datasheet. */ 77 | bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */ 78 | Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ 79 | Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */ 80 | Adafruit_BMP280::FILTER_X16, /* Filtering. */ 81 | Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */ 82 | 83 | timer.setInterval(100L, sendSensor); 84 | 85 | } 86 | 87 | void loop() 88 | { 89 | Blynk.run(); 90 | timer.run(); 91 | } 92 | -------------------------------------------------------------------------------- /Temperature-Pressure-Altitude-Monitor-Using-Whatsapp/temperature-pressure-altitude-monitor-using-whatsapp.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Temperature Monitor Using Whatsapp 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #define BMP_SCK (13) 10 | #define BMP_MISO (12) 11 | #define BMP_MOSI (11) 12 | #define BMP_CS (10) 13 | 14 | Adafruit_BMP280 bmp; // I2C 15 | 16 | ThingESP8266 thing("techtrends", "ControlLED", "techtrends"); 17 | 18 | unsigned long previousMillis = 0; 19 | const long INTERVAL = 6000; 20 | 21 | void setup() 22 | { 23 | Serial.begin(115200); 24 | Serial.println(F("BMP280 test")); 25 | 26 | if (!bmp.begin(0x76)) { 27 | Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); 28 | while (1); 29 | } 30 | 31 | /* Default settings from datasheet. */ 32 | bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */ 33 | Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ 34 | Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */ 35 | Adafruit_BMP280::FILTER_X16, /* Filtering. */ 36 | Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */ 37 | 38 | 39 | thing.SetWiFi("WIFI Username", "WIFI Password"); 40 | 41 | thing.initDevice(); 42 | 43 | } 44 | 45 | 46 | String HandleResponse(String query) 47 | { 48 | float temp = bmp.readTemperature(); 49 | float f = bmp.readTemperature()*1.8+32; 50 | float p = bmp.readPressure(); 51 | float alt = bmp.readAltitude(1013.25); 52 | Serial.print(F("Temperature = ")); 53 | Serial.print(temp); 54 | Serial.println(" *C"); 55 | 56 | Serial.print(F("Pressure = ")); 57 | Serial.print(p); 58 | Serial.println(" Pa"); 59 | 60 | Serial.print(F("Approx altitude = ")); 61 | Serial.print(alt); /* Adjusted to local forecast! */ 62 | Serial.println(" m"); 63 | 64 | String pressure = "Pressure: " + String(p) + " pa \n"; 65 | String altitude = "Altitude: " + String(alt) + " m \n"; 66 | String temperature = "Temperature: " + String(temp) + "°C, " + String(f) + "°F \n"; 67 | 68 | 69 | if (query == "temperature") { 70 | 71 | return temperature; 72 | } 73 | 74 | else if (query == "pressure") { 75 | 76 | return pressure; 77 | } 78 | else if (query == "altitude") { 79 | 80 | return altitude; 81 | } 82 | 83 | else return "Your query was invalid.."; 84 | 85 | } 86 | 87 | 88 | void loop() 89 | { 90 | 91 | thing.Handle(); 92 | 93 | } 94 | 95 | 96 | -------------------------------------------------------------------------------- /Temperature-and-Humidity-Monitor-Using-ESP8266-Blynk/temperature-and-humidity-using-esp8266-blynk.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TemplateID" 2 | #define BLYNK_DEVICE_NAME "Temperature and Humidity Monitor" 3 | #define BLYNK_AUTH_TOKEN "AuthToken" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | 12 | char auth[] = BLYNK_AUTH_TOKEN; 13 | 14 | char ssid[] = "Wifi Username"; // type your wifi name 15 | char pass[] = "Wifi Password"; // type your wifi password 16 | 17 | BlynkTimer timer; 18 | 19 | 20 | #define DHTPIN 2 //Connect Out pin to D4 in NODE MCU 21 | #define DHTTYPE DHT11 22 | DHT dht(DHTPIN, DHTTYPE); 23 | 24 | 25 | void sendSensor() 26 | { 27 | float h = dht.readHumidity(); 28 | float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit 29 | 30 | if (isnan(h) || isnan(t)) { 31 | Serial.println("Failed to read from DHT sensor!"); 32 | return; 33 | } 34 | // You can send any value at any time. 35 | // Please don't send more that 10 values per second. 36 | Blynk.virtualWrite(V0, t); 37 | Blynk.virtualWrite(V1, h); 38 | Serial.print("Temperature : "); 39 | Serial.print(t); 40 | Serial.print(" Humidity : "); 41 | Serial.println(h); 42 | } 43 | void setup() 44 | { 45 | 46 | Serial.begin(115200); 47 | 48 | 49 | Blynk.begin(auth, ssid, pass); 50 | dht.begin(); 51 | timer.setInterval(100L, sendSensor); 52 | 53 | } 54 | 55 | void loop() 56 | { 57 | Blynk.run(); 58 | timer.run(); 59 | } 60 | -------------------------------------------------------------------------------- /Theft-Alert-Notification-Using-Blynk-IOT/theft-alert-notification-using-blynk-iot-and-esp8266.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL37ehPCV4r" 2 | #define BLYNK_TEMPLATE_NAME "Theft Alert Notification Using ESP8266" 3 | #define BLYNK_AUTH_TOKEN "jV-XWUbzTxwlFgFsdfhfkkQELvsm-gHRX1uvAoA" 4 | 5 | #define BLYNK_PRINT Serial 6 | #include 7 | #include 8 | 9 | 10 | char auth[] = BLYNK_AUTH_TOKEN; 11 | 12 | char ssid[] = "WiFi Username"; // type your wifi name 13 | char pass[] = "WiFi Password"; // type your wifi password 14 | 15 | #define PIR_SENSOR 4 16 | BlynkTimer timer; 17 | //int flag=0; 18 | void notifyOnTheft() 19 | { 20 | int isTheftAlert = digitalRead(PIR_SENSOR); 21 | Serial.println(isTheftAlert); 22 | if (isTheftAlert==1) { 23 | Serial.println("Theft Alert in Home"); 24 | // Blynk.email("shameer50@gmail.com", "Alert", "Theft Alert in Home"); 25 | //Blynk.notify("Alert : Theft Alert in Home"); 26 | Blynk.logEvent("theft_alert","Theft Alert in Home"); 27 | // flag=1; 28 | } 29 | else if (isTheftAlert==0) 30 | { 31 | // flag=0; 32 | } 33 | } 34 | 35 | void setup(){ 36 | pinMode(PIR_SENSOR, INPUT); 37 | Serial.begin(115200); 38 | Blynk.begin(auth, ssid, pass); 39 | //dht.begin(); 40 | timer.setInterval(5000L, notifyOnTheft); 41 | } 42 | 43 | void loop(){ 44 | Blynk.run(); 45 | timer.run(); 46 | } 47 | -------------------------------------------------------------------------------- /Theft-Alert-Notification-Using-Microwave-Radar-Sensor-RCWL-0516-and-ESP8266/theft-alert-using-microwave-radar-sensor-rcwl-0516-and-esp8266.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3GtKj4QgJ" 2 | #define BLYNK_TEMPLATE_NAME "Theft Alert Notification Using ESP8266" 3 | #define BLYNK_AUTH_TOKEN "Ebci2NrlEBxldgolPFyqG0vFGHdsgh299-qdZaC6m" 4 | 5 | #define BLYNK_PRINT Serial 6 | 7 | #include 8 | #include 9 | 10 | // Replace with your Wi-Fi credentials 11 | char auth[] = BLYNK_AUTH_TOKEN; 12 | char ssid[] = "WiFi Username"; 13 | char pass[] = "WiFi Password"; 14 | 15 | // Define the pin configuration 16 | const int sensorPin = 4; // D2 on NodeMCU corresponds to GPIO4 17 | const int ledPin = 5; // D1 on NodeMCU corresponds to GPIO5 18 | 19 | void setup() { 20 | Serial.begin(115200); 21 | 22 | Blynk.begin(auth, ssid, pass); 23 | 24 | pinMode(sensorPin, INPUT); 25 | pinMode(ledPin, OUTPUT); 26 | } 27 | 28 | void loop() { 29 | Blynk.run(); 30 | 31 | int sensorValue = digitalRead(sensorPin); 32 | 33 | if (sensorValue == HIGH) { 34 | digitalWrite(ledPin, HIGH); 35 | Serial.println("Motion detected!"); 36 | Blynk.logEvent("theft_alert","Theft Alert in Home"); 37 | } else { 38 | digitalWrite(ledPin, LOW); 39 | Serial.println("No motion detected"); 40 | } 41 | 42 | delay(500); 43 | } 44 | -------------------------------------------------------------------------------- /Voltage-Monitor-with-ESP8266-Blynk-IoT/voltage-monitor-with-esp8266-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3M4dEmGdb" 2 | #define BLYNK_TEMPLATE_NAME "Voltage Measurement" 3 | #define BLYNK_AUTH_TOKEN "4kKknYffAu88domL0W6HlrJ8H-b4tDtstYTjK9" 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | // LCD configuration 10 | LiquidCrystal_I2C lcd(0x27, 16, 2); 11 | 12 | // Calibration factor and offset 13 | const float vCalibration = 175.0; 14 | const float offsetVoltage = 0.522; // Observed baseline voltage when power is OFF 15 | 16 | // Variables 17 | int analogValue = 0; 18 | float voltage = 0.0; 19 | 20 | // Wi-Fi credentials 21 | 22 | const char* ssid = "WiFi Username"; // Your WiFi network SSID 23 | const char* pass = "WiFi Password"; // Your WiFi network password 24 | 25 | // Blynk authentication 26 | char auth[] = BLYNK_AUTH_TOKEN; 27 | 28 | // Blynk timer 29 | BlynkTimer timer; 30 | 31 | // Function to send voltage to Blynk 32 | void sendVoltageToBlynk(float actualVoltage) { 33 | Blynk.virtualWrite(V1, actualVoltage); // Send voltage to virtual pin V1 34 | Serial.print("Sent to Blynk: "); 35 | Serial.println(actualVoltage); 36 | } 37 | 38 | // Function to get a stable voltage reading 39 | float getStableVoltage() { 40 | const int sampleCount = 10; // Number of samples for averaging 41 | float totalVoltage = 0.0; 42 | 43 | // Take multiple readings 44 | for (int i = 0; i < sampleCount; i++) { 45 | analogValue = analogRead(A0); 46 | voltage = (analogValue / 1024.0) * 1.0; // Convert to 0-1V range 47 | totalVoltage += voltage; 48 | delay(20); // Short delay between samples 49 | } 50 | 51 | // Calculate average voltage 52 | return totalVoltage / sampleCount; 53 | } 54 | 55 | void setup() 56 | { 57 | Serial.begin(115200); 58 | 59 | // Initialize LCD 60 | lcd.init(); 61 | lcd.backlight(); 62 | lcd.setCursor(0, 0); 63 | lcd.print("Voltage Sensor"); 64 | delay(2000); 65 | lcd.clear(); 66 | 67 | // Connect to Wi-Fi 68 | WiFi.begin(ssid, pass); 69 | Serial.print("Connecting to Wi-Fi"); 70 | while (WiFi.status() != WL_CONNECTED) { 71 | delay(500); 72 | Serial.print("."); 73 | } 74 | Serial.println("\nWi-Fi connected!"); 75 | 76 | // Connect to Blynk 77 | Blynk.begin(auth, ssid, pass); 78 | Serial.println("Connected to Blynk!"); 79 | 80 | // Set up a timer to send voltage data to Blynk every 2 seconds 81 | timer.setInterval(2000L, []() { 82 | float stableVoltage = getStableVoltage(); 83 | float actualVoltage = (stableVoltage - offsetVoltage) * vCalibration; 84 | if (actualVoltage < 1) actualVoltage = 0; 85 | 86 | sendVoltageToBlynk(actualVoltage); 87 | 88 | // Update LCD 89 | lcd.clear(); 90 | if (actualVoltage > 0) { 91 | lcd.setCursor(0, 0); 92 | lcd.print("Voltage: "); 93 | lcd.print(actualVoltage, 2); 94 | lcd.print(" V"); 95 | } else 96 | if(actualVoltage < 1) 97 | { 98 | lcd.setCursor(0, 0); 99 | lcd.print("Power OFF"); 100 | } 101 | }); 102 | } 103 | 104 | void loop() { 105 | Blynk.run(); 106 | timer.run(); 107 | } 108 | -------------------------------------------------------------------------------- /Water-Level-Monitoring-Using-ESP8266-Blynk-IOT/water-level-monitoring-using-esp8266-and-blynk-iot.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | 3 | #define BLYNK_TEMPLATE_ID "TMPL3NKgjZWZjkfyHo" 4 | #define BLYNK_TEMPLATE_NAME "Water Level Monitoring" 5 | #define BLYNK_AUTH_TOKEN "3CX-aksZvi_XsAdfghjjJKStOW_ZuX_UG_VNcJ" 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | //#include // Added BlynkTimer library 13 | 14 | LiquidCrystal_I2C lcd(0x27, 16, 2); 15 | 16 | char auth[] = BLYNK_AUTH_TOKEN; // Enter your Blynk authentication token 17 | 18 | char ssid[] = "WiFi Username"; // Enter your WiFi SSID 19 | char pass[] = "WiFi Password"; // Enter your WiFi password 20 | 21 | BlynkTimer timer; 22 | //#define trig 13 23 | //#define echo 12 24 | const int trig = D5; 25 | const int echo = D6; 26 | int MaxLevel = 18; 27 | 28 | int Level1 = (MaxLevel * 75) / 100; 29 | int Level2 = (MaxLevel * 65) / 100; 30 | int Level3 = (MaxLevel * 55) / 100; 31 | int Level4 = (MaxLevel * 45) / 100; 32 | int Level5 = (MaxLevel * 35) / 100; 33 | 34 | void setup() { 35 | Serial.begin(9600); 36 | lcd.begin(); // Initialize the LCD with correct column and row count 37 | pinMode(trig, OUTPUT); 38 | pinMode(echo, INPUT); 39 | Blynk.begin(auth, ssid, pass, "blynk.cloud", 80); 40 | Serial.print("LCD 1"); 41 | lcd.setCursor(3, 0); //Set cursor to first column of first row 42 | lcd.print("Tech Trends"); 43 | Serial.print("LCD 2"); 44 | delay(3000); 45 | lcd.clear(); 46 | lcd.setCursor(3, 0); 47 | lcd.print("Water level"); 48 | lcd.setCursor(3, 1); 49 | lcd.print("Monitoring"); 50 | delay(7000); 51 | lcd.clear(); 52 | 53 | // Call the functions 54 | timer.setInterval(100L, ultrasonic); 55 | } 56 | 57 | void loop() { 58 | Blynk.run(); 59 | timer.run(); // Run the BlynkTimer 60 | delay(1000); 61 | } 62 | 63 | void ultrasonic() { 64 | digitalWrite(trig, LOW); 65 | delayMicroseconds(4); 66 | digitalWrite(trig, HIGH); 67 | delayMicroseconds(10); 68 | digitalWrite(trig, LOW); 69 | long t = pulseIn(echo, HIGH); 70 | int distance = t / 29 / 2; 71 | 72 | int blynkDistance = (distance - MaxLevel) * -1; 73 | if (distance <= MaxLevel) { 74 | Blynk.virtualWrite(V0, blynkDistance); 75 | Serial.print("Distance: "); 76 | Serial.print(blynkDistance); 77 | Serial.println(" cm"); 78 | } else { 79 | Blynk.virtualWrite(V0, 0); 80 | } 81 | 82 | lcd.setCursor(0, 0); 83 | lcd.print("Level:"); 84 | 85 | if (Level1 <= distance) { 86 | lcd.setCursor(8, 0); // Corrected column position 87 | lcd.print("Very Low"); 88 | } else if (Level2 <= distance && Level1 > distance) { 89 | lcd.setCursor(8, 0); // Corrected column position 90 | lcd.print("Low"); 91 | lcd.print(" "); 92 | } else if (Level3 <= distance && Level2 > distance) { 93 | lcd.setCursor(8, 0); // Corrected column position 94 | lcd.print("Medium"); 95 | lcd.print(" "); 96 | } else if (Level4 <= distance && Level3 > distance) { 97 | lcd.setCursor(8, 0); // Corrected column position 98 | lcd.print("High"); 99 | lcd.print(" "); 100 | } else if (Level5 >= distance) { 101 | lcd.setCursor(8, 0); // Corrected column position 102 | lcd.print("Full"); 103 | lcd.print(" "); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Water-Quality-Monitoring-Using-TDS-Sensor-and-ESP8266-with-Blynk-IoT/Water-Quality-Monitoring-Using-TDS-Sensor-and-ESP8266-with-Blynk-IoT.ino: -------------------------------------------------------------------------------- 1 | #define BLYNK_TEMPLATE_ID "TMPL3IBzVEG9V" 2 | #define BLYNK_TEMPLATE_NAME "Water Quality Monitoring" 3 | #define BLYNK_AUTH_TOKEN "KJRzl2jRdsfcIPL5XD1aHMAhY5RjbRjyhgfBiWO-" 4 | 5 | // Comment this out to disable prints and save space 6 | #define BLYNK_PRINT Serial 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | // Your WiFi credentials. 13 | // Set password to "" for open networks. 14 | char ssid[] = "WiFi Username"; 15 | char pass[] = "WiFi Password"; 16 | 17 | char auth[] = BLYNK_AUTH_TOKEN; 18 | 19 | namespace pin { 20 | const byte tds_sensor = A0; 21 | } 22 | 23 | namespace device { 24 | float aref = 3.3; // Vref, this is for 3.3v compatible controller boards, for Arduino use 5.0v. 25 | } 26 | 27 | namespace sensor { 28 | float ec = 0; 29 | unsigned int tds = 0; 30 | float ecCalibration = 1; 31 | } 32 | 33 | void setup() { 34 | Serial.begin(115200); // Debugging on hardware Serial 0 35 | Blynk.begin(auth, ssid, pass); 36 | } 37 | 38 | void loop() { 39 | Blynk.run(); 40 | readTdsQuick(); 41 | delay(1000); 42 | } 43 | 44 | void readTdsQuick() { 45 | // Read the raw analog value and convert to voltage 46 | float rawEc = analogRead(pin::tds_sensor) * device::aref / 1024.0; 47 | 48 | // Debugging: Print the raw analog value 49 | Serial.print(F("Raw Analog Value: ")); 50 | Serial.println(rawEc); 51 | 52 | // Adjust this offset based on the sensor's dry reading (without immersion) 53 | float offset = 0.14; // Set this to the observed raw analog value in air 54 | 55 | // Apply calibration and offset compensation 56 | sensor::ec = (rawEc * sensor::ecCalibration) - offset; 57 | 58 | // If the EC is below zero after adjustment, set it to zero 59 | if (sensor::ec < 0) sensor::ec = 0; 60 | 61 | // Convert voltage value to TDS value using a cubic equation 62 | sensor::tds = (133.42 * pow(sensor::ec, 3) - 255.86 * sensor::ec * sensor::ec + 857.39 * sensor::ec) * 0.5; 63 | 64 | // Debugging: Print the TDS and EC values 65 | Serial.print(F("TDS: ")); 66 | Serial.println(sensor::tds); 67 | Serial.print(F("EC: ")); 68 | Serial.println(sensor::ec, 2); 69 | 70 | // Send data to Blynk virtual pins 71 | Blynk.virtualWrite(V0, sensor::tds); 72 | Blynk.virtualWrite(V1, sensor::ec); 73 | } 74 | -------------------------------------------------------------------------------- /Weather-Monitoring-System-with-ESP8266-and-Blynk/weather-monitoring-system-with-esp8266-and-blynk.iot: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Weather Monitoring System 3 | 4 | #define BLYNK_TEMPLATE_ID "TMPL3W6pAV-Ui" 5 | #define BLYNK_TEMPLATE_NAME "Weather Monitoring System" 6 | #define BLYNK_AUTH_TOKEN "TcpKdfrYWj8ptgeddfiWNV_gSXdU0w9dhfLIhUdK3Y" 7 | 8 | #define BLYNK_PRINT Serial 9 | 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | //Initialize the LCD display 19 | LiquidCrystal_I2C lcd(0x27, 16, 2); 20 | 21 | 22 | #define BMP_SCK (13) 23 | #define BMP_MISO (12) 24 | #define BMP_MOSI (11) 25 | #define BMP_CS (10) 26 | 27 | // Create an object for the BMP280 sensor 28 | Adafruit_BMP280 bmp; // I2C 29 | 30 | char auth[] = BLYNK_AUTH_TOKEN;//Enter your Auth token 31 | char ssid[] = "WiFi Username";//Enter your WIFI name 32 | char pass[] = "WiFi Password";//Enter your WIFI password 33 | 34 | DHT dht(D3, DHT11);//(DHT sensor pin,sensor type) 35 | BlynkTimer timer; 36 | 37 | //Define Rain and LDR pins 38 | #define rain A0 39 | #define light D0 40 | 41 | //Create three variables for pressure 42 | double T, P; 43 | char status; 44 | 45 | void setup() { 46 | Serial.begin(9600); 47 | bmp.begin(); 48 | lcd.begin(); 49 | lcd.backlight(); 50 | pinMode(light, INPUT); 51 | 52 | Blynk.begin(auth, ssid, pass); 53 | dht.begin(); 54 | 55 | lcd.setCursor(3,0); 56 | lcd.print("Tech Trends1 "); 57 | lcd.setCursor(0,0); 58 | delay(2000); 59 | lcd.clear(); 60 | lcd.setCursor(0, 0); 61 | lcd.print("Weather Monitor"); 62 | lcd.setCursor(4, 1); 63 | lcd.print("System"); 64 | delay(4000); 65 | lcd.clear(); 66 | 67 | //Call the functions 68 | timer.setInterval(100L, LDRsensor); 69 | timer.setInterval(100L, DHT11sensor); 70 | timer.setInterval(100L, RainSensor); 71 | timer.setInterval(100L, BMP280Sensor); 72 | 73 | } 74 | 75 | //Get the DHT11 sensor values 76 | void DHT11sensor() { 77 | float temperature = dht.readTemperature(); 78 | float humidity = dht.readHumidity(); 79 | 80 | if (isnan(temperature) || isnan(humidity)) { 81 | Serial.println("Failed to read from DHT11 sensor!"); 82 | return; 83 | } 84 | Blynk.virtualWrite(V0, temperature); 85 | Blynk.virtualWrite(V1, humidity); 86 | 87 | lcd.setCursor(0, 0); 88 | lcd.print("T:"); 89 | lcd.print(temperature); 90 | 91 | lcd.setCursor(8, 0); 92 | lcd.print("H:"); 93 | lcd.print(humidity); 94 | 95 | } 96 | 97 | //Get the pressure values 98 | void BMP280Sensor() { 99 | //status = bmp.startTemperature(); 100 | float temp = bmp.readTemperature(); 101 | float pressure = bmp.readPressure(); 102 | float alt = bmp.readAltitude(1013.25); 103 | 104 | if (!bmp.begin(0x76)) { 105 | Serial.println(F("Could not find a valid BMP280 sensor, check wiring!")); 106 | while (1); 107 | } 108 | 109 | /* Default settings from datasheet. */ 110 | bmp.setSampling(Adafruit_BMP280::MODE_NORMAL, /* Operating Mode. */ 111 | Adafruit_BMP280::SAMPLING_X2, /* Temp. oversampling */ 112 | Adafruit_BMP280::SAMPLING_X16, /* Pressure oversampling */ 113 | Adafruit_BMP280::FILTER_X16, /* Filtering. */ 114 | Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */ 115 | 116 | Serial.print(F("Pressure = ")); 117 | Serial.print(pressure); /* Adjusted to local forecast! */ 118 | Serial.println(" p"); 119 | 120 | Blynk.virtualWrite(V2, pressure); 121 | lcd.setCursor(0, 1); 122 | lcd.print("P:"); 123 | lcd.print(pressure); 124 | } 125 | 126 | //Get the rain sensor values 127 | void RainSensor() { 128 | int rainvalue = analogRead(rain); 129 | int value = map(rainvalue, 400, 1023, 100, 0); 130 | Blynk.virtualWrite(V3, value); 131 | 132 | lcd.setCursor(11, 1); 133 | lcd.print("R:"); 134 | lcd.print(value); 135 | lcd.print(" "); 136 | } 137 | 138 | //Get the LDR sensor values 139 | void LDRsensor() { 140 | bool value = digitalRead(light); 141 | if (value == 0) { 142 | WidgetLED LED(V4); 143 | LED.on(); 144 | Serial.print("LED ON"); 145 | } else { 146 | WidgetLED LED(V4); 147 | LED.off(); 148 | Serial.print("LED OFF"); 149 | } 150 | 151 | } 152 | 153 | void loop() { 154 | Blynk.run();//Run the Blynk library 155 | timer.run();//Run the Blynk timer 156 | } 157 | -------------------------------------------------------------------------------- /Weather-Station-Web-Server/weather-station-web-server-circuit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Tech-Trends-Shameer/Esp-8266-Projects/af0a60e690551a543f4bd7d024d9c77b7e09b2e0/Weather-Station-Web-Server/weather-station-web-server-circuit.png -------------------------------------------------------------------------------- /Weather-Station-Web-Server/weather-station-web-server.ino: -------------------------------------------------------------------------------- 1 | //Tech Trends Shameer 2 | //Weather Station Project 3 | 4 | // Including the ESP8266 WiFi library 5 | #include 6 | #include "DHT.h" 7 | 8 | //Uncomment the line based on the sensor you are using. 9 | #define DHTTYPE DHT11 // DHT 11 10 | //#define DHTTYPE DHT21 // DHT 21 (AM2301) 11 | //#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321 12 | 13 | //Enter your wifi username and wifi password below 14 | const char* ssid = ""; 15 | const char* password = ""; 16 | 17 | // Web Server on port 80 18 | WiFiServer server(80); 19 | 20 | // DHT Sensor 21 | const int DHTPin = 5; 22 | // Initialize DHT sensor. 23 | DHT dht(DHTPin, DHTTYPE); 24 | 25 | // Temporary variables 26 | static char celsiusTemp[7]; 27 | static char fahrenheitTemp[7]; 28 | static char humidityTemp[7]; 29 | 30 | 31 | // only runs once on boot 32 | void setup() { 33 | // Initializing serial port for debugging purposes 34 | Serial.begin(115200); 35 | delay(10); 36 | 37 | dht.begin(); 38 | 39 | // Connecting to WiFi network 40 | Serial.println(); 41 | Serial.print("Connecting to "); 42 | Serial.println(ssid); 43 | 44 | WiFi.begin(ssid, password); 45 | 46 | while (WiFi.status() != WL_CONNECTED) { 47 | delay(500); 48 | Serial.print("."); 49 | } 50 | Serial.println(""); 51 | Serial.println("WiFi connected"); 52 | 53 | // Starting the web server 54 | server.begin(); 55 | Serial.println("Web server running. Waiting for the ESP IP..."); 56 | delay(10000); 57 | 58 | // Printing the ESP IP address 59 | Serial.println(WiFi.localIP()); 60 | } 61 | 62 | // runs over and over again 63 | void loop() { 64 | // Listenning for new clients 65 | WiFiClient client = server.available(); 66 | 67 | if (client) { 68 | Serial.println("New client"); 69 | // bolean to locate when the http request ends 70 | boolean blank_line = true; 71 | while (client.connected()) { 72 | if (client.available()) { 73 | char c = client.read(); 74 | 75 | if (c == '\n' && blank_line) { 76 | float h = dht.readHumidity(); 77 | // Read temperature as Celsius (the default) 78 | float t = dht.readTemperature(); 79 | // Read temperature as Fahrenheit (isFahrenheit = true) 80 | float f = dht.readTemperature(true); 81 | // Check if any reads failed and exit early (to try again). 82 | if (isnan(h) || isnan(t) || isnan(f)) { 83 | Serial.println("Failed to read from DHT sensor!"); 84 | strcpy(celsiusTemp,"Failed"); 85 | strcpy(fahrenheitTemp, "Failed"); 86 | strcpy(humidityTemp, "Failed"); 87 | } 88 | else{ 89 | // Computes temperature values in Celsius + Fahrenheit and Humidity 90 | float hic = dht.computeHeatIndex(t, h, false); 91 | dtostrf(hic, 6, 2, celsiusTemp); 92 | float hif = dht.computeHeatIndex(f, h); 93 | dtostrf(hif, 6, 2, fahrenheitTemp); 94 | dtostrf(h, 6, 2, humidityTemp); 95 | // The below lines are just need to print in Serial Monitor. You can delete if its not needed. 96 | Serial.print("Humidity: "); 97 | Serial.print(" % "); 98 | Serial.println(h); 99 | Serial.println("Temperature: "); 100 | Serial.print(t); 101 | Serial.print(" *C "); 102 | Serial.print(f); 103 | Serial.println(" *F "); 104 | Serial.println("Heat index: "); 105 | Serial.print(hic); 106 | Serial.print(" *C "); 107 | Serial.print(hif); 108 | Serial.println(" *F"); 109 | } 110 | client.println("HTTP/1.1 200 OK"); 111 | client.println("Content-Type: text/html"); 112 | client.println("Connection: close"); 113 | client.println(); 114 | // Below lines are to display the details in the web page 115 | client.println(""); 116 | client.println(""); 117 | client.println("

Weather Station by Tech Trends

Temperature in Celsius: "); 118 | client.println(t); 119 | client.print(char(176)); //To print the degree symbol 120 | client.println(" C

Temperature in Fahrenheit: "); 121 | client.println(f); 122 | client.print(char(176)); //To print the degree symbol 123 | client.println(" F

Humidity: "); 124 | client.println(humidityTemp); 125 | client.println("%

Heat Index in Celsius: "); 126 | float hic = dht.computeHeatIndex(t, h, false); 127 | client.println(hic); 128 | client.print(char(176)); //To print the degree symbol 129 | client.println(" C

Heat Index in Fahrenheit: "); 130 | float hif = dht.computeHeatIndex(f, h); 131 | client.println(hif); 132 | client.print(char(176)); //To print the degree symbol 133 | client.println(" F

"); 134 | client.println(""); 135 | break; 136 | } 137 | if (c == '\n') { 138 | // when starts reading a new line 139 | blank_line = true; 140 | } 141 | else if (c != '\r') { 142 | // when finds a character on the current line 143 | blank_line = false; 144 | } 145 | } 146 | } 147 | // Closing the connection 148 | delay(1); 149 | client.stop(); 150 | Serial.println("Client disconnected."); 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /WhatsApp-Home-Automation-Using-ESP8266/whatsapp-home-automation-using-esp8266.ino: -------------------------------------------------------------------------------- 1 | //#include 2 | #include 3 | #include 4 | 5 | ThingESP8266 thing("techtrends", "ControlLED", "techtrends"); 6 | 7 | int LIGHT = D2; 8 | 9 | unsigned long previousMillis = 0; 10 | const long INTERVAL = 6000; 11 | 12 | void setup() 13 | { 14 | Serial.begin(115200); 15 | pinMode(LIGHT, OUTPUT); 16 | thing.SetWiFi("WiFi Username", "WiFi Password"); 17 | thing.initDevice(); 18 | } 19 | 20 | 21 | String HandleResponse(String query) 22 | { 23 | if (query == "light on") { 24 | digitalWrite(LIGHT, 1); 25 | return "Done: Light Turned ON"; 26 | } 27 | 28 | else if (query == "light off") { 29 | digitalWrite(LIGHT, 0); 30 | return "Done: Light Turned OFF"; 31 | } 32 | 33 | else if (query == "light status") 34 | return digitalRead(LIGHT) ? "LIGHT is OFF" : "LIGHT is ON"; 35 | else return "Your query was invalid.."; 36 | 37 | } 38 | 39 | 40 | void loop() 41 | { 42 | thing.Handle(); 43 | 44 | } 45 | --------------------------------------------------------------------------------