House Monitor System with Wireless PICAXE14M and PICAXE08M Sensor Modules

lbenson

Senior Member


This is Version 2 of a house monitoring system. Version 1 is currently running in a seasonal home in Canada, monitoring an empty house which I would like to keep from freezing up. The house is 160 years old, and I have been told that in old plaster and lathe houses, freeze/thaw cycles are liable to cause the plaster to separate from the lathe (tho I'm sure that at that age, it has suffered some of those cycles). Still, I want to do what is recommended. Since I want to keep it from freezing, I also want to monitor it to assure that the heating equipment doesn't malfunction and run the oil tank dry, as happened winter of 07/08 when a zone valve stuck.

Version 1 uses a PICAXE 28X1 with wired sensors which monitor the outside temperature, the inside temperature in various places, the boiler run time, and whether the power goes out. The 28X1 is on a breadboard, and a SimpleLan module which connects to the internet is also on board. This module allows the system to present a web page (which has errors and deficiencies which I can't fix remotely), and to send me a status email twice a day, and emergency emails if the temperature drops below the desired level or the power goes off (assuming the internet stays up--breadboard, router, and cable modem are on a UPS). I am pleased with this system, but it is limited.

Version 2 will use wireless sensors in the 315mHz range. The baseboard hot water system has three zones. I figure I need at least three temperature sensors per zone to be able to know exactly what is happening--one for the air, one for the water feed pipe, and one for the water return pipe. I also want to monitor other conditions, like the presence of water in the basement.

The wireless sensors will be powered by PICAXE 08Ms and 14Ms, but I have strayed off the reservation for the control hardware. I have used the NSLU2 NAS device with reflashed operating system for various purposes for nearly four years. It has 8 megabytes of flash memory and 32 megabytes of ram, 2 usb ports and an ethernet port. I am using the slim openWrt Linux operating system (still very much a work in progress). All the programs that I need can fit in the flash. Secure access can be had over the internet, so the programs can be updated. One of the USB ports has a USB->Serial cable to talk to (or rather, listen to) an 08M which receives transmissions from the sensors (use of a message qualifier cleans up a lot of junk). The other connects to a GSM phone which can make an emergency call if the internet goes down. No active control is planned at this point, but it could be added later.

Thanks to all who post on this board--those who answer questions and those who ask the questions that provoke discussion which we non-pros can learn from.
 
Last edited:

lbenson

Senior Member
PICAXE14M and PICAXE08M Sensor Boards

I used ExpressPCB to make the 08M and 14M sensor boards. I ganged them and so was able for $60US to get 3 boards, each of which has 3 08M mini-boards (about an inch square) and 2 14M mini-boards (about an inch by an inch and a half). I had extra room so I also put on 4 8-Pin SOIC to DIP Adapters.

The 08M board is built to have a 315mHz transmitter on pin0, a pushbutton or logic level sensor on pin3, and temperature or other sensors or a battery level monitor (or a reciever) on pins 1, 2, and 4. It is intended to run off of 3-AAs or off of 4-AAs with the voltage brought down to the safe level with one or more diodes.

The 14M board is built to have a 315mHz transmitter on output pin1, a pushbutton or logic level sensor on portc pin1, and temperature or other sensors on input pins 0, 1, 2, and 4. It is intended to run off of 4-AAs with a LM2931Z-5 (which when it has less than .1V headroom, simply passes on the voltage it receives, and so would be good down until the transmitter fails). It can monitor its battery level on ADC3. With additional work, input pin3 is available and output pins 2 and 3. The 14M is a wonderfully versatile chip, but it really doesn't have enough code space to take full advantage of all of its features simultaneously.

The wireless messages consist of a one-byte message ID and two data bytes, plus the inversion of each of the three bytes, so MessageID, inversion, Databyte1, inversion, Databyte2, inversion. Start bytes of "UUU" and a preamble are included. To reduce the effects of collisions, each message is transmitted 3 times with a varying delay between transmissions. The message IDs can be any byte, but I use "A-Z", "a-z", and if needed, "0-9". Some error correction is done, like stripping off a high-order bit.

 

Attachments

Last edited:

lbenson

Senior Member
NSLU2 Control Processor with PICAXE08M Wireless Receiver

The control program on the NSLU2 is written in Lua--a powerful interpreted language available on many platforms, including the PC and the NSLU2. The program at present is over 600 lines long. The trial system uses two of the 14M and three of the 08M boards to monitor eight temperatures, the water heater run time, whether mains power is on or off, and the battery levels of the wireless units. I plan to add more sensors now that the basic system is working. There are two Lua programs. The first runs constantly (as a daemon) reading the serial port and appending messages as lines to a file. The second runs once a minute, reading the file, updating the web page and checking for alarm conditions.

The charts on the web page are drawn by google charts--you simply generate a url which accesses http://chart.apis.google.com and contains all the data needed to draw your chart. I say "simply", but it took a great deal of fiddling to put the chart data into the exact right configuration.

When alarm conditions are detected, the system sends an email. Data in the web page is color coded to signify alert status--red for an ongoing alert, orange for an alert which occurred today but has passed, and green for an alert which occurred in the past. If the internet is down, the system can also send an SMS message over a connected cell phone (this is not implemented, but I have tested it).

The receiver is breadboarded, and runs off of mains with battery backup

I plan another version of the 14M and 08M PCBs (tho each is working fine as is). Once one has wireless sensors working, there is a whole world out there to be sensed.
 

Attachments

Last edited:

lbenson

Senior Member
PICAXE14M 315mHz Transmitter Module Code

Sample transmitter code for 14M board
Code:
' 14Tx_3D: PCB 315mHz Tx, 2 DS18B20s, 1 battery monitor, 1 water sensor
'
#picaxe 14M
'      task IDs--different for each sensor detector module
symbol MyMsgNo1 = "d" ' basement temp
symbol MyMsgNo2 = "e" ' water heater exhaust pipe temp
symbol MyMsgNo3 = "f" ' battery level
symbol MyMsgNo4 = "g" ' water heater flame on
symbol MyMsgNo5 = "h" ' water sensor for drip pan
symbol TxMode = 1     ' 1=3 retries, no Rx; 2=Rx

symbol bWaterAlarmSent = bit0
symbol bFlameOn        = bit1
symbol bSendMsg        = bit2

symbol Flags = b0      ' reserved for bit values

symbol Tmpvar = b3
symbol M_Inv = b4      ' Data1 inverted
symbol D1_Inv = b5     ' Data1 inverted
symbol D2_Inv = b6     ' Data1 inverted
symbol lastTemp1 = b7
symbol lastTemp2 = b8
symbol timePeriod = b9 ' major loop counter of 6-minute periods--240 per day
symbol batData = w5 ' comprised of b10 & b11
symbol Data1= b10 ' battery LSB; temperature data
symbol Data2= b11 ' battery MSB; not used for temperature
symbol loopCnt = b12
symbol MsgNo= b13

'output pins 0-5
symbol Tx433 = 1  ' output
symbol inTEMP1 = 0
symbol inTEMP2 = 2
symbol inBat3 = 3       ' ADC port--leg 8
symbol inFlame4 = pin4
symbol inWater5 = pin1
symbol pushbutton1 = pin1   ' portc

symbol ADCON0 = $1f   ' ADC control SFR register to turn off ADC module
symbol OSCCON = $8f   ' Oscillator control SFR register for speed up/down

dirsc = %000001 ' portc 0-output;1,2-input; 3,4,5 used on porta

start:
'pause 1000
disablebod
low Tx433

initiate:   ' or roll over to new day by rough counting
'  sertxd("Module ",MyMsgNo1,CR,LF)
  timePeriod = 239  ' set to roll to effective end of 24 hours
  pause 4000
newday:
  lastTemp1 = 254
  lastTemp2 = 254
'  bWaterAlarmSent = 0  ' send only one a day
    
main:
  do   ' this loop completes about once every 6 minutes
    readtemp inTEMP1,Data1
    b1 = lastTemp1 - Data1 + 1
    if b1 > 2 then  ' change of more than one degree C
      lastTemp1 = Data1
'      Data2 = Data1
      MsgNo = MyMsgNo1
      gosub TxData
    endif
    readtemp inTEMP2,Data2
    b1 = lastTemp2 - Data2 + 1
    if b1 > 2 then  ' change of more than one degree C
      lastTemp2 = Data2
      Data1 = Data2
      MsgNo = MyMsgNo2
      gosub TxData
    endif
'    if inWater5 = 1 then
'      serout 0,N2400_4, ("Water alarm",cr,lf)
'    endif
'  goto initiate  ' for testing

    poke OSCCON,%00000000 ' = 31 kHz slow down 1/128th
    for b1 = 1 to 120 ' idle for 6 minutes--6 second loops
'pause 25 ' for testing at full speed (~3 secs @ 120 loops)
      pause 17   ' ~360 seconds or 6 min@ 120 loops
      if inFlame4 = 1 then   ' burner is on
        if bFlameOn = 0 then  ' not yet reported
          bFlameOn = 1
          MsgNo = MyMsgNo4
          Data1 = 1  ' we don't care what Data2 is
          bSendMsg = 1
        endif
      else
        if bFlameOn = 1 then  ' burn off must be reported
          bFlameOn = 0
          MsgNo = MyMsgNo4
          Data1 = 0  ' we don't care what Data2 is
          bSendMsg = 1
        endif
      endif
      if inWater5 = 1 then   ' burner is on
        if bWaterAlarmSent = 0 then  ' not yet reported
          bWaterAlarmSent = 1
          MsgNo = MyMsgNo5
          Data1 = 1  ' we don't care what Data2 is
          bSendMsg = 1
        endif
      else
        if bWaterAlarmSent = 1 then  ' burn off must be reported
          bWaterAlarmSent = 0
          MsgNo = MyMsgNo5
          Data1 = 0  ' we don't care what Data2 is
          bSendMsg = 1
        endif
      endif
      if bSendMsg = 1 then
        bSendMsg = 0
        poke OSCCON,%01100000 ' = 4 MHz; speed back up
        gosub TxData
        poke OSCCON,%00000000 ' = 31 kHz slow down
        pause 10
      endif
'      if portc pushbutton1 = 1 then ' send temps
'        pause 1000
'         lastTemp1 = 254
'         lastTemp2 = 254
'         exit
'      endif
'      toggle Tx433  ' time approximately the pause
    next b1
    poke OSCCON,%01100000 ' = 4 MHz; speed back up
    pause 100
'  goto initiate ' for testing
    inc timePeriod
    if timePeriod = 240 then   ' approximately 24 hours
      timePeriod = 0  ' reset
      readADC10 inBat3,batData ' Data1 & Data2
      peek ADCON0, b0
      bit0 = 0           ' turn off the ADC module to save power
      poke ADCON0, b0
      MsgNo = MyMsgNo3
      gosub TxData
      b0 = 0  ' reset all flags for day
      goto newday  ' for testing
    endif
  loop
  
TxData:
  M_Inv = 255 - MsgNo  ' more balance in the bits
  D1_Inv = 255 - Data1 ' more balance in the bits
  D2_Inv = 255 - Data2 ' more balance in the bits
  loopCnt = 0
  do while loopCnt < 3
'    pause 100
'    serout Tx433, N2400_4, ("UUU") ' per womai: t=11531
'    pause 5
    serout Tx433,N2400_4,("UUU~~~",MsgNo,M_Inv,Data1,D1_Inv,Data2,D2_Inv,cr,cr,cr)
'  serout 0,N2400_4,("~~~",MsgNo," ",#Data1," ",#Data2, " ",#batData,cr,lf)
'    pause 50
    inc loopCnt
    Tmpvar = Msgno - "@" * loopCnt * 20 + 150 ' delay 
    pause Tmpvar   ' variable pause
  loop
'  sertxd("Tx ",MsgNo," ",#Data1," ",#Data2,CR,LF)
  return
 
Last edited:

nbw

Senior Member
Wow - that's awesome! Everything from wireless, to SimpleLan, to... does it play mp3s!?!?!?
 

lbenson

Senior Member
SimpleLan omitted in this version--the NSLU2 does the internet connection. And it can certainly play mp3s and internet radio.
 

lbenson

Senior Member
The RF transmitters solve lots of problems. If I think of something else I want to monitor, I just add another sensor and transmitter module. For the most part, the sensor only transmits a change in status--even with three randomly spaced transmissions per sensing, it only comes to some dozens transmissions a day overall, with little likelihood of collision. As I watch the behavior, I can fine-tune things.
 

Masters

New Member
That is really really impressive, how long did it take you to come up with that system?? Have you made any modifications to it since this was last updated??
 

lbenson

Senior Member
>how long

I've been fiddling with parts of this system in two locales for over two years now, and am working up the third major revision at present. This revision incorporates the 20X2 to monitor and (for the first time) control the three zones of a boiler heating system. Wireless monitors will use 08Ms and 14Ms. I will still use the NSLU2 for the internet connection--it allows remote programming which cannot be achieved with the picaxe.

Version 1, in which everything is wired into a 28x1 and connected to the internet using the SimpleLan module (unfortunately no longer being sold) will remain as my back up (last spring it notified me of rising temperatures in the unoccupied house, which, when someone got there, resulted in a diagnosis of "stuck zone valve", which would have run the oil tank dry if not promptly fixed).

I will post a new thread when the new version is running.
 
Top