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…


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

OLED from seeedstudio

…glued to panel


Back side

Image00013Installed to wall…

Close up of OLED and rottary encoder.


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)



Python scripts for reading and setting temperatures…

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


And here are all files zipped


 Add your comment
  1. Great project !!!
    Will study what you have done on the weekend, Thanks 🙂

  2. 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

    • 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.

      • 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 :-))

        • 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.

          • 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:-))

          • 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.

  3. Thanks a lot

Leave a Reply