![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Demo code for a Wi-Fi controlled wall outlet that monitors light intensity, temperature, and motion and can control which plugs are supplied with power based off of user preference.
Dependencies: BH1750 DHT11_Lib mbed
Fork of ECE4180_Lab4_ESP8266_IoT_Outlets by
Diff: main.cpp
- Revision:
- 12:9de0e402ff17
- Parent:
- 11:74be5786e4b0
- Child:
- 13:d2b7aeed050d
--- a/main.cpp Sat Apr 23 22:22:59 2016 +0000 +++ b/main.cpp Sat Apr 23 22:49:05 2016 +0000 @@ -193,7 +193,7 @@ // WEB page data strcpy(webbuff, "<!DOCTYPE html>"); - strcat(webbuff, "<html><head><title>ESP8266 Mbed IoT Controlled Outlets</title></head>"); + strcat(webbuff, "<html><head><title>Wi-Fi Controlled Smart Wall Outlet</title></head>"); strcat(webbuff, "<body>"); strcat(webbuff, "<div style=\"text-align:center; background-color:#F4F4F4; color:#00AEDB;\"><h1>ESP8266 Mbed IoT Web Controller</h1>"); strcat(webbuff, "Hit Count - "); @@ -204,12 +204,12 @@ strcat(webbuff, Vcc); strcat(webbuff, " </sup>V"); strcat(webbuff, "</div><br /><hr>"); - strcat(webbuff, "<h3>Mbed RTC Time -  "); - strcat(webbuff, timebuf); + //strcat(webbuff, "<h3>Mbed RTC Time -  "); + //strcat(webbuff, timebuf); strcat(webbuff, "</h3>\r\n"); - strcat(webbuff, "<p><form method=\"POST\"><strong> Outlet 1 Current:  <input type=\"text\" size=6 value=\""); - strcat(webbuff, Cur1); - strcat(webbuff, "\"> </sup>A <form method=\"POST\"> <strong>   "); + //strcat(webbuff, "<p><form method=\"POST\"><strong> Outlet 1 Current:  <input type=\"text\" size=6 value=\""); + //strcat(webbuff, Cur1); + strcat(webbuff, "\ </sup> <form method=\"POST\"> <strong>   "); if(SetMotion==0) { strcat(webbuff, "<p><input type=\"radio\" name=\"outlet1\" value=\"0\" checked> Outlet 1 off"); strcat(webbuff, "<br><input type=\"radio\" name=\"outlet1\" value=\"1\" > Outlet 1 is motion controlled"); @@ -218,20 +218,20 @@ strcat(webbuff, "<br><input type=\"radio\" name=\"outlet1\" value=\"1\" checked> Outlet 1 is motion controlled"); } if(setOut2==0) { - strcat(webbuff, "<p><input type=\"radio\" name=\"outlet2\" value=\"0\" checked> Outlet 2 off when temp >  <input type=\"text\" name=\"tmpOff\" size=4 value=\""); + strcat(webbuff, "<p><input type=\"radio\" name=\"outlet2\" value=\"0\" checked> Outlet 2 on when temperature <  <input type=\"text\" name=\"tmpOff\" size=4 value=\""); sprintf(setTmpOff, "%d", tmpOff); strcat(webbuff,setTmpOff); strcat(webbuff,"\"> </sup>"); - strcat(webbuff, "<br><input type=\"radio\" name=\"outlet2\" value=\"1\" > Outlet 2 on when temp >  <input type=\"text\" name=\"tmpOn\" size=4 value=\""); + strcat(webbuff, "<br><input type=\"radio\" name=\"outlet2\" value=\"1\" > Outlet 2 on when temperature >  <input type=\"text\" name=\"tmpOn\" size=4 value=\""); sprintf(setTmpOn, "%d", tmpOn); strcat(webbuff,setTmpOn); strcat(webbuff,"\"> </sup>"); } else { - strcat(webbuff, "<p><input type=\"radio\" name=\"outlet2\" value=\"0\" > Outlet 2 off when temp >  <input type=\"text\" name=\"tmpOff\" size=4 value=\""); + strcat(webbuff, "<p><input type=\"radio\" name=\"outlet2\" value=\"0\" > Outlet 2 on when temperature <  <input type=\"text\" name=\"tmpOff\" size=4 value=\""); sprintf(setTmpOff, "%d", tmpOff); strcat(webbuff,setTmpOff); strcat(webbuff,"\"> </sup>"); - strcat(webbuff, "<br><input type=\"radio\" name=\"outlet2\" value=\"1\" checked> Outlet 2 on when temp >  <input type=\"text\" name=\"tmpOn\" size=4 value=\""); + strcat(webbuff, "<br><input type=\"radio\" name=\"outlet2\" value=\"1\" checked> Outlet 2 on when temperature >  <input type=\"text\" name=\"tmpOn\" size=4 value=\""); sprintf(setTmpOn, "%d", tmpOn); strcat(webbuff,setTmpOn); strcat(webbuff,"\"> </sup>");