Make it happen

Make it happen

Some code

ESP8266Posted by Thu, March 03, 2016 10:09:31
Let's write some code and see if this works out as planned. This blog does not allow me to paste the code here so I have created an attachment containing the code instead.

This sketch is compiled and uploaded to the ESP8266. Set the bord in the Ardino IDE to "Generic ESP8266 Module". (I'm getting some warnings during compile but it works anyway) Remember to set GPIO00 to LOW before powering up the ESP and uploading the sketch.

The code might be a bit confusing since I'm "listening" for an incoming request for 60 seconds and then that just loops over and over again.. which of course makes no sence at all.

The reason is that I'm planning to add a schedule to my lighting. I don't have a problem to to turn on and off lights manually when I'm at home but when I'm not at home I would like the lighting to turn on/off based on a predefined schedule. The ESP8266 will check if the schedule is active every 60 seconds ( but this is not developed yet) . But again how hard can it be :)
There is also a PHP file on my webpage with my floor plan, when clicking a lightbulb we send the HTTP request that the sketch is looking for. Attached you find a basic version of that file. (This basic PHP page does not have to be PHP since it only contains HTML.. but I'm expanding it with additional functionality as well)

I guess that's it.. a webpage to control the power outlets. DONE!

The future plans for this is more functionallity such as;
- Update a mySQL database with the state of all outlets.
- Create schedule to control outlets when not at home
- When ESP updates state based on schedule it should also send a HTTP request back to the webserver to update the database
- Add on additional home automation functionality to the same dashboard.

  • Comments(0)

Fill in only if you are not real

The following XHTML tags are allowed: <b>, <br/>, <em>, <i>, <strong>, <u>. CSS styles and Javascript are not permitted.