Monday, 19 October 2015

Remote Temperature Monitoring

This post shows how to use the Dual Analogue Radio Transmitter (DART) and the Universal Radio Receiver (URR) to monitor the temperature of one or more freezer.

The DART collects data from 2 analogue inputs and transmits this to a receiver using a 433 MHz FM radio module. Typical range of more than 50 metres through 2 or 3 sets of brick walls. (FM radio modules gives gives significantly better range and noise performance when compared to AM modules). More information on the DART and URR can be found here.

Dual Analogue Radio Transmitter

The TMP36 is very easy to use. The relationship between the temperature and analogue voltage output is as follows:

Temp (in deg C) = voltage (in mv) divided by 10  minus 50

So for example if the TMP36 output volts was 800 mV the temperature would be 800/10 = 80 mnus 50 would be 30 deg C.


The DART has 2 sets of screw terminals. The TMP36 temperature sesnor can be connected directlty to these. The timing of the temperature measurement and transmission can be set to 1 every minute or 1 every 10 minutes.


On this project uses 2 TMP36 devices. One is connected directlty to the screw terminals and the other is on a cable of approximately 1 metre in length. The TMP36 at the end of this is housed in a plastic tube for protection. 

TMP36 temperature sensor


 The image below shows the DART in pace with one of the TMP36 device inside the freezer and one outside. This way we can monitor the temperature inside and outside the freezer (which in this case is in the garage).


Freezer temperature monitor

The Universal Radio REceiver is connected to a Raspberry Pi, using A Custard Pi 1A breakout board. (This has easy connection points and also has 0.1A fuses on the 5V and 3.3V rails to prevent too much current being drawn from the RPi.)

Raspberry Pi




The Python code to receive the data on the serial port is listedat the end of this post. Please read this document for more comprehensive instructions on using the UART on the Raspberry Pi.

The data displayed on the HDMI monitor connected to the Raspberry Pi is hsown here.

Raspberry Pi display
The data is received every minute and is interpreted as follows.

1st digit = device type )always 1 for a DART)
2nd digit = address set on this DART
3rd digit = data count (goes from 0 to 15 and then starts again. Each data set is sent twice)
4th digit = temp 1 = -21 deg C (inside the freezer)
5th digit = temp 2 = 12 deg C (in the garage)
6th digit = batt voltage = 4.417 V

PROJECT IDEA #1: Send an e-mail from the Raspberry Pi if the temperature inside the freezer rises by 5 degrees.

PROJECT IDEA #2: Log the temperature from a number of freezers for food hygiene purposes. (One URR can receive data from a number of DART devices).

Summary: The DART and URR devices allow remote temperature monitoring to be set up very quickly.

Appendix: Python code to recive and display data from the serial port.

#!/usr/bin/env python

import time
import serial

ser = serial.Serial(

    port='/dev/ttyAMA0',
    baudrate = 9600,
    parity=serial.PARITY_NONE,
    stopbits=serial.STOPBITS_ONE,
    bytesize=serial.EIGHTBITS,
    timeout=0

)

ser.flushInput()
while True:
    data1 = ser.read(1)
    data2 = ser.read(1)
    data3 = ser.read(1)
    data4 = ser.read(1)
    data5 = ser.read(1)
    data6 = ser.read(1)
   
    if len(data1) >0:
        localtime = time.asctime( time.localtime(time.time()))
        print localtime
        temp1 = (1024*ord(data4)/2550)-50
        temp2 = (1024*ord(data5)/2550)-50
        battv =  (1024 * ord(data6) * 11)/255
        print ord(data2), ord(data3), ord(data1),
        print "Temp1 = ", temp1,
        print "Temp2 = ", temp2,
        print "BattV", battv    
    
    time.sleep (0.5)


ser.close()














2 comments:

  1. You could stream the temperature to a service like https://www.initialstate.com and see the data in a dashboard along with other data and collect the history of the temperature over time to watch for anomalies. You could combine this with energy monitor data to correlate how much money it costs to keep the freezer at certain temperatures.

    ReplyDelete
  2. Hey - that sounds awesome. Will look into this as I want to progress to monitor energy usage as well.

    ReplyDelete