Wireless Temperature Sensor

46K653

Intro: Wireless Temperature Sensor

Consisting of 2 circuits
One reads the temperature using a DS18B20 and then transmitts it over the radio waves.
The other receives the data and displays it.

I've not fully tested the range yet, but I've had it working over 12 feet going through 2 walls.

Transmitter Parts List:
  • Picaxe 08m
  • DS18B20 temp sensor
  • AM RT4-433.9 transmitter module
  • LED
  • 4k7 resistor
  • 1k resistor
  • 3.5v Battery

Receiver Parts List
  • Picaxe 18X
  • AM HRR3 433.9 Receiver module
  • 7 segment I2c module
  • 5mm 2 pin Bi-Colour LED -- red and green


STEP 1: Build the Circuit

The diagram below shows the circuit to build. I apologies for the poor quality, I did attempt drawing it in Eagle at first, but didn't get too far and decided it would be quicker to just draw it in Ms Paint !

The transmitter circuit is shown at the top, I actually didn't use 5v, instead I ran it off a 3.5v button battery. The button battery was hooked up to a solar cell; a module I pulled from a cheap solar torch. I've had the transmitter circuit lying on my window sill, happily transmitting for a week with no power problems.
The AM transmitter/Receiver I had bought years ago from Maplin.

The receiver circuit is shown below, it is very simple. Pins 11 and 12 on the chip is actually a bi-colour LED, I wasn't sure how best to draw it.
The counter looking object in the top right makes displaying a number easy work. I needed a chip that could use the I2C, which is why I'm using a Picaxe18X. The 7 segment module was bought off ebay for about �15, but they do sell it on their website

I've not shown the programming header, partly to keep it simple and clean and partly because I was using a seperate circuit to program the chip.

STEP 2: Writing the Transmitter Code

The code for the 08M Transmitter circuit:
'------------------------------------------------------------
'08M Project Board - Transmitter
SYMBOL TX_PIN = 1
SYMBOL TXLED_PIN = 2
SYMBOL TempSend_PIN = 4

SYMBOL BAUDRATE = N1200
SYMBOL TmpReading = b1
pause 2000
main:

'read temp
readtemp TempSend_PIN,TmpReading ' read value into b1
pause 150

'blink LED
high TXLED_PIN
pause 50
low TXLED_PIN

send
pause 50
SerOut TX_PIN, BAUDRATE, ("UUUUUUUUUUUUUUUUUUUUU")
pause 20
if TmpReading > 127 then 'negative number
let TmpReading = TmpReading - 128 ' adjust neg value
b2 = "-"
Else 'positive
b2 = " "
End if
serout TX_PIN, BAUDRATE, ("TP",b2,TmpReading,"x")

SerTxD (#TmpReading)
'nap 6
GOSUB Wait1Minute

goto main

Wait1Minute:
'turn clock speed down
poke $8F,%01100000 'Set clock to 31kHz ~19bps
'Disable Brown Out Detection
DisableBod

sleep 4 'in multiples of 2.3

'change it all back
EnableBod
poke $8F,%01100000 'Set clock to 4MHz 2400bps

RETURN
End
'------------------------------------------------------------

The Wait1Minute sub procedure uses a few techniques to lower the power consumption.

STEP 3: Writing the Receiver Code

The Receiver code is a little more complicated because of the 7 segment I2c module, but the CONVERT sub does most of the hard work.

'------------------------------------------------------------
'18X - Receiver
SYMBOL RCV_PIN = 7
SYMBOL DATA_RCVD =w3
SYMBOL DATA_RCVD_SIGN = b3
SYMBOL CHECK_DATA= b1
SYMBOL BAUDRATE = N1200 'Must b T2400 if using USB-Serial

symbol temp = b12
symbol Cnt= w2 ' Counter
symbol Digit0 = b8 ' Hold digit0 data
symbol Digit1 = b9 ' Hold digit1 data
symbol Digit2 = b10 ' Hold digit2 data
symbol Digit3 = b11 ' Hold digit3 data
symbol slvAddrWR = $70 ' I2C write address
symbol slvAddrRD = $71 ' I2C read address

PAUSE 1000

i2cslave slvAddrWR, i2cslow, i2cbyte 'Initialize I2C-7SEG
writei2c 0,(%01000111)

NXT:
LOW 5
LOW 6

SERIN RCV_PIN, BAUDRATE,("TP"), DATA_RCVD_SIGN, DATA_RCVD, CHECK_DATA

if CHECK_DATA = "x" then

SERTXD ("Val ", DATA_RCVD_SIGN, #DATA_RCVD,13,10)

'turn green
LOW 5
HIGH 6
pause 100

Else 'Check bit failed to receive properly
sertxd ("bad. ","sign ",DATA_RCVD_SIGN," - " , #DATA_RCVD_SIGN ," ,rcvd1 ",DATA_RCVD, " - ", #DATA_RCVD , ", chk ", CHECK_DATA, " - ", #CHECK_DATA,13,10)

'Turn Red
LOW 6
HIGH 5

End if

pause 100
let cnt = DATA_RCVD

GOSUB CONVERT ' Convert decimal into each LED segment

'clear first 2 digits
Digit3 = $0
Digit2 = $0
writei2c 1,(Digit0,Digit1,Digit2,Digit3) ' Write each digit to 7-segment

GOTO NXT

CONVERT: ' Lookup table for 7-segment

temp = cnt % 10
LOOKUP temp, ($3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F,$77,$7C,$39,$5E,$79,$71), Digit0
temp = cnt / 10 % 10
LOOKUP temp, ($3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F,$77,$7C,$39,$5E,$79,$71), Digit1
temp = cnt / 100 % 10
LOOKUP temp, ($3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F,$77,$7C,$39,$5E,$79,$71), Digit2
temp = cnt / 1000 % 10
LOOKUP temp, ($3F,$06,$5B,$4F,$66,$6D,$7D,$07,$7F,$6F,$77,$7C,$39,$5E,$79,$71), Digit3

RETURN
'------------------------------------------------------------

When I first started using the module I was getting some interference and so sometimes it wouldn't show the correct value, so I added a check byte at the end, to check that the data was received properly. When the data is received properly the LED will flash green, if "bad" data is received it'll flash red.

The lines
Digit3 = $0
Digit2 = $0
are added to stop the first 2 digits on the display from showing, as they don't need to be on.

STEP 4: The Future

Many things could be improved.

The first thing I did was take the components of the prototyping board and put them into a permanent breadboard home. Partly because I wanted something permanent I could place on my window sill and partly because I wanted to free the proto board to test out some 7 segment driver chips.

The transmitter
  • Could detect light levels and send signal less often if it's dark outside, as this would conserve power
  • It could check the voltage of the battery and not send if the battery is low - this would requite a reference voltage though.
  • A better arial than my coiled up single core wire.
  • When sending, transmit a Device ID, so more than one transmitter could be used
  • Show battery level on a LED - red blink if very low, green led if power level is good.
  • Manual button for sending temperature
  • Add a single 7 segment display to show temp at the touch of a button - For simplicity I would probably use a different picaxe chip, one with more outputs.

The Receiver
  • Instead of displaying on a 7 segment it could show on a LCD send to a PC via serial
  • If sending via serial cable the device could be powered of USB and use a virtial USB port to send serial data. There are a few of these modles on ebay using FTDI's FT232BM chip.
  • Display negative numbers - I don't know how to show negative numbers with the current 7 segment display

8 Comments

I made a variation of this using x2 picaxe 08m, x1 315mhz tx rx pair, 4.7k, x2 ds18b20 and a usb uart to ttl converter (uses cp2102 IC).

I managed to get current consumption down to about 8-9mA when transmitting with a standby current of about 2mA by powering the tx module through pin 2 of the picaxe 08m.

The receiver is powered by the uart to ttl converter connected to a PC which also receives the internal and external temperature.

I hope to write an instructable soon.

Dear Manager/Sir,
How are you?
This is Yoseph from Wuhan Amate Technology Co., Ltd, a leading wireless temperature monitoring system & solution provider from China.

Dear Manager/Sir, we came across your esteemed company info on the internet, and guess your esteemed company (specializing in similiar temperature measurement industry or logistics transportation) may have potential need or interest in our Wireless Temperature Monitoring/Measuring System or Solutions, thus we take the liberty to write to you, with hope of self-introduction & communication bridging.

A brief introduction of us, Wuhan Amate has established on the base of two Chinese national key universities’ laboratories professionals in 2001. After more than 10 years development, featured in customer oriented and innovation-driven, we are now ranking among the top three Industrial Wireless Temperature Monitoring System Providers domestically. Our products mainly consist of Wireless Temperature Sensors/Transmitters, Wireless Temperature Display/Monitor/Data Logger/Data Receiver/Collector, Wireless Temperature Workstation/Data Server/Software that constitute the whole wireless temperature monitoring system.

Dear Manager/Sir, should you are in the relevant field and have potential need of or interest in our wireless temperature monitoring systems or solutions, please feel free to contact us. If our info doesn’t appeal to you, we apologize for this boring “Email marketing” in advance and please kindly inform us to avoid further “junk emails”.

And finally, we do appreciate your precious time of viewing this letter and looking forward to your favorable response..
Best Regards,
Yoseph
----------------------------------------------
Yoseph Tsin Marketing Director
Overseas Marketing & Sales Dept. of Wuhan Amate Technology Co., Ltd
Add.: No.5 Building, Guandong Science Park, Wuhan East Lake National High-Tech Development Zone, Wuhan, Hubei
Tel:+86-27-67849619
Fax:+86-27-67849466
Email:yoseph@amate.com.cn Skype:yoseph_amate
Backup email:yoseph_amate@hotmail.com (MSN)
URL: www.amate.com.cn
Could you please modify the code to read temps from o to 100 oC?

Thanks,

Costas.

THOUGHT: Consider a simplified setup using just a single LED for the readout?! Coding to show tens as a long flash & units as short ( hence 23 Celsius would be long, long, short, short,short ) allows reading clear across a room, or even further at night ! Power saving will be quite significant ( as only a single LED needs to be lit) & just a PICAXE-08M can then be used at each end. Refer http://www.picaxe.orcon.net.nz/ntcswancode.bas for a standalone NTC thermistor based approach that's good to ~a degree Celcius.

Ok -the bare code is probably not enough ! I've hence now further packaged up that 'winking LED" approach as a downloadable .doc => http://www.picaxe.orcon.net.nz/NTC_thermo-Swan-code.doc Feel free to grab ( although credit appreciated)-it was recently used to good effect as a hands on activity with a High School electronics class here in NZ

EXTRA: New "M2" Picaxes have just been released - refer http://www.picaxe.com for details

Hi Richard,  I'm looking to use those modules in a simple home security system.  What did you use for the antenna? The datasheet doesn't suggest anything but I think the logical choice would be a 13.6" (1/2 wavelength) wire.

(I suggest you re-enter your tags to appear as separate words.to make it easier for the search engine to find.)
Very nice! I would love to copy this for myself (unfortunately I do not have a Picaxe cable and development environment). This is one of the few wireless solutions I have seen for the DS18B20. Thank you for sharing.

Typo? "4k7 resistor" means 4.7K resistor, or 47K resistor? I assume the former.

I see you have some ideas lined up for future revisions. If you are looking for suggestions, would it be possible to eliminate the Pic chip? (Timing could be replaced with an analog chip, but not sure about the data encoding...). If you have a Picaxe dev environment, these chips make perfect sense... but if you do not have it already, it might be cheaper to go with XBee (which is still not cheap). I'm looking for low cost. :-)

FYI - This other tutorial (one year newer than yours) is similar: http://www.dehnes.com/60/2010/02/09/wireless-temperature-and-humidity-sensor/
OK I was looking to replicate this, and all the usual Arduino parts seemed like overkill in both power in expense. But I didn't want to dabble in PIC so soon.

So I found this - the JeeNode wireless mini-Arduino ($22 complete!):
http://shop.moderndevice.com/products/jeenode-kit
It looks like all I would need is the temp sensor, and a power supply, and a home base receiver, and I am good! This will be for wireless temp monitoring of beer mash, and another for my kegerator. For portable power, there's lots of options but I'll just use a spare MintyBoost (and some power management on the 'duino).

This next part does not interest me at the moment, but FYI while searching on the "cheapest" wireless temp sensors that can be read (received) by a PC or Arduino, it looks like you can wire temp sensors directly into the serial inputs on an XBee or some Bluetooth modules (negating the need for a host processor). Not 100% sure how that works, but someone reading this might benefit. Cheers!