Room Thermostat - Arduino + Ethernet

Arduino is a handy embeeded platform that can be used, for example, to build a room thermostat, which we will show today. The thermostat is accessible from the LAN network in which it is located, while it is equipped with a web interface which is used to configure all elements of the thermostat. The web interface runs directly on the Arduino in web server mode. The web server allows the running of several independent HTML pages, which can be informative or even functional. The web server runs on port 80 - HTTP. |500x113 The electromagnetic relay SRD-5VDC-SL-C, which is used in the project, allows switching up to 10A at 230V - power 2300W. In case of switching a DC circuit (load) it is possible to switch 300W (10A at 30V DC). Alternatively, the OMRON G3MB-202P SSR relay is fully compatible for the wiring diagram, which is only suitable for non-inductive loads and exclusively for AC circuits. Maximum switching power 460W (230V, 2A). Consumption of Arduino with Ethernet shield and other peripherals is at the level of 100-120mA with the relay open. When closed, below 200mA at 5V supply. |500x116 The web interface for the thermostat allows:

  • View the real-time temperature from the DS18B20 sensor
  • View real-time relay status with dynamic output change on page
  • Modify the target (reference) temperature in the range of 5 to 50 ° C with a 0.25 ° C step
  • Modify the hysteresis in the range 0 to 10 ° C with a 0.25 ° C step

The web interface is designed to accommodate larger and smaller screens. It is responsive, supports widescreen high-definition screens, but also mobile devices. The interface uses imported CSS styles of the Bootstrap framework from an external CDN server, which loads the client-side device when opening a page running on Arduino. Because the Arduino Uno is memory limited, it can only run pages a few kB in size. By importing CSS styles from an external server, it will reduce the performance and memory load of the Arduino. The software implementation (for Arduine Uno) uses 70% of flash memory (32kB - 4kB Bootloader) and 44% of RAM memory (2kB).

Static parts of a web page (HTML document header and footer, Bootstrap CSS linking, meta tags, HTTP response header, Content Type, form and more) are stored directly in Arduino's flash memory, which can significantly reduce the amount of RAM used for user-generated content. The web server is thus more stable and can handle multi-connection of several devices in the network at the same time. |500x72 In order to keep the set values even after a power failure, they are stored in the EEPROM memory of the Arduino. Reference temperature to offset 10, hysteresis to offset 100. Each of the values occupies a maximum of 5B in the EEPROM memory. The EEPROM transcription limit is at the level of 100,000 transcripts. Data is overwritten only when the HTML form is submitted. In case the device has nothing stored on the mentioned EEPROM offsets at the first start-up, automatic writing will be performed with default values - reference: 20.25, hysteresis 0.25 ° C

The Refresh meta tag refreshes the entire Arduino page every 10 seconds. By this time it is necessary to write the change for the thermostat, otherwise the input windows will be reset when the page is refreshed. Because the Ethernet library does not include the use of an asynchronous web server, the entire page must be rewritten. The dynamic data that is mainly changing is the current value of the output - On / Off.

HTML pages running on Arduino:

  • / - root page containing the form, current logic output listing for the relay, temperature
  • /action.html - processes values from the form, writes them to the EEPROM memory, redirects the user back to the root page
  • /get_data/ - distributes data on current temperature, reference temperature and hysteresis to a third party (computer, microcontroller, other client ...) in JSON format

In terms of hardware, the project uses:

  • Arduino Uno / Mega 2560
  • Ethernet shield Wiznet W5100 / Ethernet module Wiznet W5200-W5500
  • DS18B20 temperature sensor on the OneWire bus
  • Relay SRD-5VDC-SL-C used for boiler switching

Schematics: |500x344

The program implementation for the project can be found at: https://github.com/martinius96/termostat-ethernet/ The implementation contains programs for the static / dynamic IPv4 address assigned to the Ethernet shield.

The thermostat is only intended for indoor temperatures! (above 0 ° C), to which the system logic is adapted. It is possible to replace an existing room thermostat with a thermostat, it is possible to temporarily replace a thermostat in a refrigerator, maintain a constant temperature in a terrarium and the like.