v. 16-bit thermometer and thermostat: DigiTM application with source code

Thermostat with two ADT7410 temperature sensors. Click on the photo to enlarge it.

Now, go to Downloads section to get 32-bit (Digital thermometer and thermostat (ADT7410) v6.zip) or 64-bit version (Digital thermometer and thermostat (ADT7410) v6 x64.zip) of DigiTM v6 thermometer and thermostat application. There is also an example with two temperature sensors: Go to Downloads section to get 32-bit (Digital thermometer and thermostat (ADT7410) v8 with source code based on SVLIB_PIC32MX2X0 v1.7.NET4.dll.zip) or 64-bit version (Digital thermometer and thermostat (ADT7410) v8 x64 with source code based on SVLIB_PIC32MX2X0 v1.7.NET4x64.dll.zip) of DigiTM v8 thermometer and thermostat application. The new version of application only works with v2.8.4 firmware or later.

NOTE: Do not start two copies of the application at the same time, or you may get false temperature readings.

ALSO READ: Tips on making a fail-safe thermostat with 16-bit digital temperatire sensors

Thermostat schematic. Click on the schematic to enlarge it.

Next, you have to connect the relays. Thou there are many ways to amplify a microcontroller output signal to drive a relay, I recommend ULN2803A chip, which supports up to 8 relays. See subsection 2.a Home appliances and lighting control. Choose any of PIC32MX250F128B port B in outputs for relay control.

The default PIC32MX250F128B firmware configuration defines RB15 as relay 1 control output and RB1 as relay 2 control output. You may alter this configuration with the Windows application bellow. Connect two of ULN2803A inputs to RB15 and RB1 and use the respective ULN2803A open collector outputs for power relay control.

The third step is microcontroller firmware programming and Windows application installation. Go to Downloads section to obtain PIC32F250F128B firmware v2.8.81 - thermostat edition.hex, which is already preset for thermostatic operation (see the schematic above). Alternatively, you can use PIC32MX250F128B v2.8.3 firmware or later (PIC32F250F128B firmware v2.8.4 - all subversions.zip), but you will have use the thermostat application below to make presets for automatic operation.

The ZIP file contains a number of HEX files for different frequencies and oscillator configurations. There are three oscillator configurations: EC – external oscillator (also used in section 2.c.vi circuit schematic), HS – high speed crystal resonator, XT – low speed crystal resonator. See subsection 5.o

for details on XT and HS configurations.

The last step is installation and testing of 16-bit Thermometer/Thermostat application. If everything is alright, the application should load the default thermostat settings and start showing current room temperature.

Temperature control is one of the most important features which make your home comfortable. 16-bit Thermometer/Thermostat application not only measures the temperature from up to two 16-bit ADT7410 sensors, but also controls up to two power relays that turn cooling and/or heating devices on and off. The thermostat accuracy supersedes many of expensive commercial solutions. Precision temperature measurement enables room temperature regulation to a few tenths of a °C.

The application is based on a 32-bit PIC32MX250F128B Microchip microcontroller and a 16-bit Analog Devices ADT7410 temperature sensor. You can buy both at www.farnell.com

or other internet electronic components shops for a few € or $.

Let’s begin! First, you have to assemble the hardware:

Thermometer and thermostat application v6 configured for a single themperature sensor. Click on the screenshot to enlarge it.

Thermometer and thermostat application v7 configured for two themperature sensors. Click on the screenshot to enlarge it

Opened PIC32MX250F128B thermostat photo. Click on the photo to enlarge it.

The application connects to up to two ADT7410 high precision 16-bit temperature sensors. The first sensor measures the outdoor temperature and the second sensor measures the indoor temperature. Temperature regulation has two levels. If the outdoor temperature is higher than maximum temperature regulation temperature (thermostat enable max. temperature), the regulation is switched off. The regulation starts again, if the outdoor temperature gets below the minimum thermostat disable temperature. You may omit using the second sensor functionality, if you write text “always on” instead of a temperature values in respective text boxes (see the screenshoot below).

The next four settings are threshold temperatures for room temperature regulation that apply to the relays 1 and 2. Select an arbitrary temperature from range of -40 °C to +150 °C. It is important that a relay switch off temperature is higher than the relay switch on temperature for the regulation to work. Use relays with alternative contacts (contacts that are on when the relay is not powered) for negative control.

It is also possible to use the thermostat to control a refrigerator or a freezer. In this case, use the “outdoor “sensor to measure the room temperature and the “indoor” sensor to measure the temperature inside the refrigerator or freezer. Alternatively you can use only one sensor to measure internal temperature. See subsection 2.c for more information.

DigiTM application also enables saving the thermostat settings to PIC32MX250F128B’s EEPROM. However, it is advisable to test the settings first. Buttons labeled “Get thermostat configuration” and “Set thermostat configuration” set operational thermostat settings in PIC32MX250128B RAM, but if you want to make them default, you have to click button “Store therm.config to EEPROM”. It will take a while for the new defaults to be programmed into the EEPROM. There is also a checkbox that enables you to set PIC32MX250F128B to start operating as a thermostat as the power is switched on. This gives the thermostat a complete independence from a PC, except when setting the configuration via USB. “Restart µC” button is helpful to test the new configuration in EEPROM, since you can restart the microcontroller without plugging it out and in the USB port.

On the left side of application window there are some extra buttons that enable direct control over certain PIC32MX250F128B functionalities. Read the PIC32MX250F128B programing guide for more information.

WIRELESS OPTION: You may also add a RFM69CW module to the thermostat to enable remote wireless temperature and operational data reading.

ALSO READ:

- K8055 and K8055N to 16-bit ADT7410 temperature sensor I2C bus adapter

- Tips on making a fail-safe thermostat with 16-bit digital temperature sensors

- Modular Weather Station Project (v1.0 and v2.0)