Arduino & ESP8266 Room Heating

After discovering cheap WiFi module ESP8266 I decided to upgrade my heater that was previously controlled by Arduino and connected to my Raspberry Pi via USB cable. Heater elements are connected to Arduino via Solid State Relay. Arduino uses PID control to achieve defined temperature and room temperature is read using digital sensor DS18B20. I had some OLED display that I got from seeedstudio and used it to display current and defined temperature on it. Arduino is connected to ESP8266. On my Raspbery Pi i made web interface and using simple python scripts i get data from Arduino and set temperature back. On front panel there is also rotary encoder used for setting temperature manually. ESP8266 is loaded with NodeMCU Lua firmware and it currently acts as simple telnet client. from RPI I send “uart.write(0,\”!6\\r\\n\”)\r\n” and ESP8266 sends to serial port !6 with carriage return and arduino send back for example 22.0,2000,21.0 (22.0Celsius current temperature, 2000 is PID output (0-4000) meaning that output is actually 50% and last value 21.0 is temperature that is defined). Sending !1,235 to arduino sets defined temperature to 23.5Celsius. I don’t have schematic but It,s pretty simple. DS18B20 data pin is connected to arduino pin 8 (use 4,7k pull up to +5v), rottary encoder is connected to pins 2 and 3 and two 10nF caps are used for debouncing (dont change pin 2 because interrupt on this pin used for trigerring read function). OLED uses 4 wires +5, GND and SDA, SCL connected to arduino SDA SCL pins. RX TX of arduino is connected to ESP8266 TX RX pins via logic level converter (arduino uses +5V and ESP8266 +3.3V) and that’s all.
Here are some making of photos and shaky video (I was recording holding my tablet in one hand and phone in another) code goes after them…

 

Image00001
A
rduino 3.3V power supply, Logic Level Converter and ESP8266 on proto board

Image00003
OLED from seeedstudio

Image00011
…glued to panel

Image00006
SSR

Image00012
Back side

Image00013Installed to wall…

Image00014
Close up of OLED and rottary encoder.

IMG_5401

IOS web app (jquery mobile and jquery knob used to set temperature by rotating knob same as rotary encoder)

I had idea to display custom text and draw images on OLED display but atmega328 has only 2Kb of SRAM and just OLED uses 1Kb and I had to remove code because Arduino was constantly crashing. Code is still there but commented. If someone has idea how to free some more SRAM from this code… On OLED temperature and defined temperature is displayed and after 40 seconds display goes to screensaver mode to save OLED from burning out (I think I read somewhere that OLED can burn out same as TFT when same dots are always lit).

ESP8266 is set to AP and Client mode so that if connection to my router is off I can log manually to Heater (AP mode) and change Client parameters if needed. So you need to execute this…

and this two scripts are uploaded to ESP8266 (you can use Lua Loader)

init.lua

tel.lua

Python scripts for reading and setting temperatures…

set.py

read.py

web interface php page (jquery mobile and jquery knob…)

webint.php

And here are all files zipped


heater_files.zip

15 thoughts on “Arduino & ESP8266 Room Heating”

  1. Great work indeed.
    I wish to replay your work to understand more.
    Can i have the opportunity to view the entire project?
    I have load several files Lua and made same little project
    but please would you explain the use of *.Py where put them?
    and the hardware scheme?
    Thanks a lot
    Claudio

    1. php, html and py files are on my raspberry pi that acts as web server and relays data to esp8266 which relays that same data to arduino.

      1. Hi you are Welcome:
        Can i use esp8266_01 or _03 with Pro mini Arduino without Raspberry?
        And please what is the android app used in your cell?
        I think your project solve many problems that i have with esp8266 according to me.
        so please let me to know what You have done.
        Thanks :-))
        Claudio

        1. It could be used but than you would need to make some android app that would telnet to esp8266 and send commands. Image from my iPhone is actually web app made with jquery mobile and hosted on Raspberry Pi. It can be opened also from desktop or any mobile platform using browser.

          1. Thanks for Your Kindness.
            Well if i start the job without cell but only Client Laptop:
            1)I load last firmware For Lua with the 2 your files.lua………DONE!
            2)Make the electronic circuit (Where find the source) ?
            3)Load the program on PRO MINI (where the code? or a base?)
            4) Testing!
            Sorry for my trouble:-))
            Claudio

          2. Arduino code is included and schematic is pretty simple and I explained it in article. If there is something that you don’t understand feel free to ask.

  2. Hi, what is the reason You are using ESP and Arduino, instead of only ESP ? Are there any limitations on ESP that are preventing it to run this project ?

    1. At the time of making this project there was no Arduino IDE support for ESP8266. Now it would be much easier to make it especially because of memory limitations of atmega. Oled drawing uses “a lot” of memory and I remember that I had to optimize everything and removed some planed things because there was not enough memory.

    1. At the time of making this project there was no Arduino IDE support for ESP8266. Now it would be much easier to make it especially because of memory limitations of atmega. Oled drawing uses “a lot” of memory and I remember that I had to optimize everything and removed some planed things because there was not enough memory.

  3. Hi, I DIY your project, but I’m not a professional programmer. My PI is installed as a Nginx+PHP server. But I did not show the ring when I opened the IP address of the server PI. Excuse me, where is my mistake?

  4. Hi, I DIY your project, but I’m not a professional programmer. My PI is installed as a Nginx+PHP server. But when I open the PI address of the server IP page only shows:
    Heat Controller
    Current Temperature: ℃
    Defined temperature: ℃
    Power Output:%
    Change temperature

    30
    Did not show JQuery knob ring diagram. Excuse me, where is my mistake?

  5. Hi, I DIY your project, but I’m not a professional programmer. My PI is installed as a Nginx+PHP server. But when I open the PI address of the server IP page only shows:
    Heat Controller
    Current Temperature: ℃
    Defined temperature: ℃
    Power Output:%
    Change temperature

    30
    Did not show JQuery knob ring diagram. Excuse me, where is my mistake?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.