Close
0%
0%

ESP8266 Light Switch + Temp Logger

Title really says it all.

Similar projects worth following
Uses modified version of mathew-hall's esp8266-dht git files to toggle GPIO0, which I hooked to relay, on button press (web button not physical), and reads temperature from ds18b20 on GPIO2. Then it shoots temperature over to raspberry pi over UDP to be timestamped, stored to a file, and then graphed using python and pygal. The raspi serves up the graph to 'http://chacebutterworth.tk' (Oops. I hope my pi can keep up with you guys.)

The code will be up on git soon, but don't expect to be impressed because I was confused the entire time making this. It's mostly the same as mathew-hall's original except for the html UI changed and I deleted a ton of code that I'm not using (or I hope I'm not. Anyway it's gone now).

Please if you have sugesstions let me know (i would really like to know how to BG the raspi python code instead of always having an open ssh term)

So as I said this is mathew-hall's repo I cloned and edited. You can read on his page and in various licenses to see who all else was involved. I don't know really much about C so I just did whatever I had to to get this code to toggle GPIO0 on web click and to read DS18B20 and broadcast. Anything that Didn't look important I deleted entirely not just comments. So it's probably a mass, but I'm sorry idk what else to do. I have made no changes to the licenses though as idk anything about it.

  • 1 × ESP8266 I used ESP-01, but you can use others.
  • 1 × 120v relay To control house lights.
  • 1 × 120VAC to 3.3VDC wall wart To power esp
  • 1 × DS18B20 Sensors / Temperature, Thermal

  • Ideas and issues

    Chace Butterworth05/06/2015 at 20:32 0 comments

    So being an IoT device means that sometimes the connection must be refreshed and, while the ESP module seems to be doing an ok job of reconnecting on its own, my router isn't always up to the task. I guess I can plug in a light timer to manually power cycle my router every night, but I really think I'd like to have a manual method for triggering the relay to go along with the web interface. On my last light switch I used an arduino and was able to simply use the capacitive touch library and some tin foil and resistor to accomplish the task. My question to the community is: s there such a library available for the esp8266?

View project log

  • 1
    Step 1

    Wire it up as shown with a 4.7k pull-up on DS18B20's signal pin. I used a wall wart for power, but you can use whatever, maybe add a large capacitor if your power supply is weak. Be sure to wire cathode from LED to GPIO0 otherwise it will act as a pull-down and send esp to bootloader mode. You can also put a relay instead of LED since this is a lightswitch after all.

  • 2
    Step 2

    Grab the files from git and cd into "ESP_Code". Be sure your usb to UART is 3.3v and hook it up to tx n rx pins on ESP. Pull GPIO0 low and reset to send it to bootloader.

    Run:

    $ make

    $ make flash

    Partway through make flash it will say sleep 3. Use this time to reset your esp or it will exit bootloader and will not flash completely. Then reset it again before running:

    $ make htmlflash

  • 3
    Step 3

    With UART still connected to PC watch minicom or other serial terminal and then reset chip with GPIO0 floating or pulled high to exit bootloader mode. Output should tell you what ip address it has. Then you can open a browser and type in that ip to see user interface. If esp has never connecteed to your home's wifi then it will become a wifi AP itself. If that's the case you need to connect to it's nnetwork and go to 192.168.4.1/wifi.html to connect to your home's AP.

View all 4 instructions

Enjoy this project?

Share

Discussions

Chace Butterworth wrote 02/03/2015 at 22:44 point

No, but I'm happy with it after comparing to dht11 readings They were so much more jittery

  Are you sure? yes | no

PointyOintment wrote 02/03/2015 at 22:38 point

Any idea what causes those individual temperature readings that are about a degree higher than they should be?

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates