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