Basement/Cellar Water Alert System

Anobium

Senior Member
Just completed my latest Picaxe project the Cellar Water Alert System.

The system detects water, moisture and dampness in the cellar of my Victorian home. The cellar is meant to sealed but over the last 150 years the sealed walls seep water. The water/dampness is removed by de-humidifiers but if water does enter we need to act with speed to remove equipment and valuables from the cellar. In 1998 the cellar was flooded so this is a real concern for us and as the water table rises water is seeping more and more often.

The system provides alerts when water does enter the cellar!!

The sysems architecture is:

  • Sensor > Picaxe
  • Picaxe
    • > Ethernet Serial Port Adapter
  • > Data Capture Web Service
  • > iPod/iTouch 'Dampness App'
  • > Desktop 'Dampness App'
  • > Service Monitoring Application with email alert
  • > K107 LCD
  • > Local User Interface

So what does the system do?

The sensor is driven by the Picaxe, and the Picaxe subsquently drives the LCD, the User Interface (visual and audio). I have applications driven via the serial/ethernet interface to provide a remote user experience and email alerting.

Over the next few days/weeks I will post the sub-components for sharing. I have had great fun building this project!

  1. Picaxe code
  2. Sensor
  3. K107 LCD
  4. Local User Interface - the wonderful Epson FX850 printer interface
  5. Wiznet 107SR Serial/Ethernet adapter
  6. Web Service to monitor Wiznet 107SR
  7. HTML web pages for iPod App, with Auto Refresh and Status page.
  8. HTML web pages for other Browsers, with Auto Refresh and Status page.
  9. Monitoring solution with email alert and auto restart for Web Service

I will post each section as I document/photograph etc. Today I will simply post a few pictures of the iTouch UX (user experience).

Anobium
________
 

Attachments

Last edited by a moderator:

Anobium

Senior Member
It rained! We are saved.....

So funny, I am still completing the final testing and tonight the probe was detecting water. After a few hours I did go and look.. there is water in the cellar!

Justification for the project!
 
Last edited by a moderator:

Anobium

Senior Member
YouTube Video of the iPod User Experience

This is the video of the user interface.

This is rendered via standard HTML and the web service. The same HTML pages support standard workstation browsers. Tested on IE, Safari and Chrome.

See http://www.youtube.com/watch?v=B4EkQ17Q8Y4
________
 
Last edited by a moderator:

1968neil

Senior Member
Sensor

How do you sense the liquid/dampness ?
Great interface like the ipod app, Well done

Neil
 

Anobium

Senior Member
Sources

Picaxe code
Initially based on Ken Moffetts and MPeps (mods) code but highly modified to support the full set of component and interfaces. Search the forums for 'XMAS TREE'.​
Sensor and Sensor Electronics
Initally based on Ken Moffetts probe but again highly modified.​
K107 LCD
Wulfden and PH Anderson hardware and microcode.​
Local User Interface - the wonderful Epson FX850 printer interface.
All my own research to understand interface.​
Wiznet 107SR Serial/Ethernet adapter
All my own research to define interface and code for Picaxe.​
Web Service to monitor Wiznet 107SR
All my own development. OMG this was hard. Two major components to drive and monitor the WS.​
HTML web pages for iPod App, with Auto Refresh and Status page.
All my own development.​
HTML web pages for other Browsers, with Auto Refresh and Status page.
All my own development.​
Monitoring solution with email alert and auto restart for Web Service
All my own development.​
________
 
Last edited by a moderator:

MPep

Senior Member
Hi Anobium,

Congratulations. Well done.
Pleased to see that your project has already proven itself.

Thanks for the acknowledgement :D.

For people wanting to find the original code base, here is a link to it: http://www.picaxeforum.co.uk/showthread.php?t=12266

Are you going to show how everything is linked together? PICAXE code, HTML, etc? Photos of layout?

MPep.
 

Anobium

Senior Member
I will post documentation as soon as practical. So, yes. :)

It will take a day or two as I am currently moving all components to a smaller housing box and we need the alarm!

Next, I can post the UX for the workstation, followed by the Picaxe code.

Anobium.
 
Last edited by a moderator:

hippy

Technical Support
Staff member
Very nice diagram showing functionality and connectivity. I'm intrigued by the 'serial line(s)'; are they for programming the 08M and 18X ?
 

Anobium

Senior Member
Clarified Diagram

The diagram now shows the Serial line used for component connectivity.

The serial lines for program are not shown and but are present in the solution. Also now shown are power supplies, network etc.

I will start posting code based on this diagram soon.

Anobium
________
 

Attachments

Last edited by a moderator:

Anobium

Senior Member
Web Service, server and monitoring application

The latest instalment of the Damp Checker architecture.

http://www.youtube.com/watch?v=9V96nfXcXk4

A video showing the web service consuming the XML (produced by the Picaxe), then the web server and the associated management application to monitor and manage events.

Anobium

PS its raining... and the alarm went off last night!
 
Last edited by a moderator:

Anobium

Senior Member
Picaxe 18x code

This is the listing for the Pixace 18x code. This is the main body of the system and can be implemented independently as described in the videos.

Comments please.

Enjoy.


#rem 0.15

Picaxe 18x water dampness @ Anobium
based on the concept by Ken Moffett 311209 and MPep.

Uses simple probe in the basement (cellar) and checks for dampness, moisture and water.
The UI consists of audible alarm, visual alerts, device reset/restart, mute audible alarm, test device and output to an option K107 display.

The UI device shows:

Power On LED (not controlled by Picaxe)
Sensor On LED (output controlled by Picaxe but hardware flashes the LED)
Alarm LED (output controlled by Picaxe and shows pulses related to current status and past status)

Muted LED (output controlled by Picaxe)
Mute Button (interrupts Picaxe to mute alarm, therefore controlled by Picaxe)
Test Button (raises input on Picaxe. An OPTIRELAY connects sensors (IN and OUT) together to check device.
Power Reset button (hardware reset for Picaxe and all other hardware)


XML definition

DZ - Data Schema defintion. Required for Web Service.
V1 - Integer: Current value returned from sensor
H1 - Integer: Highest historical value returned from sensor
S1 - Integer: Wet count value. Returns the value of WetCount.
M1 - Integer: Returns 1 for muted and 0 for not muted
A1 - String: String value of the current status.

Typical usage;

<dz><v1>Picaxe</v1><h1> </h1><s1>Booting</s1><c1>0</c1><a1> </a1></dz>
<dz><v1>0</v1><h1>1</h1><s1>Dry</s1><c1>0</c1><a1>Dry</a1></dz>


#endrem


#picaxe 18x


' Variables defined in memory
symbol HSval = b0 'Sensor value
symbol Muted = b1 'State variable. Siren status. Muted/Unmuted
symbol Loopx = b2 'For/Next loop usage
symbol MaxHSval= b3
symbol WetCount = b4

' Double byte variables defined in memory
symbol Mask = w3 'Bitwise variable used during LED flash routine
symbol Value = w4 'Temp variable used during LED flash routine
symbol AlertVal = w5 'Alert variable
symbol HiAlertVal = w6 'State variable. Historical alert variable

' Constants. Return values from the sensor
symbol xlimit = 22 'It's WET!
symbol moist = 17 'It's MOIST!
symbol damp = 12 'It's DAMP!

' These are binary values flash of the alert LED!
symbol WetAlert = 65535 ' On all the time
symbol WasWetalert = 61680 ' On/Off....
symbol MoistAlert = 61455 ' On/Off....
symbol DampAlert = 21845 ' On/Off....

symbol BigDelay = 1000

' Port assignments
symbol LedAlertPort = 0 'needs to be an output
symbol SirenPort = 1 'needs to be an output
symbol PwmPort = 3 'needs to be an output
symbol MutedPort = 2 'needs to be an output
symbol LCDPort = 4 'needs to be an output
symbol BuzzerPort = 5 'needs to be an output
symbol SerialPort = 6 'needs to be an output



symbol SensorPort = 0 'needs to be an input
symbol MutePortPin = pin1 'needs to be an input
symbol MutePort = 1 'needs to be an input
symbol TestPort = pin7 'needs to be an input
' Commence program

' reset PWM port
pwmout PwmPort, off

for loopx = 0 to 2
toggle SirenPort 'turn off/on Siren... Picaxe is operational
pause 75
next

' reset the ports
low LedAlertPort 'turn off the Alert LED
low SirenPort 'turn off the Siren
low MutePort 'turn off the Mute LED

' set state of global state variables
Muted = 0
HiAlertVal = 0
MaxHSval = 0



pwmout PwmPort,249,500 'PWM output 4kHz@50% to sensor driver probe
setint %00000010,%00000010 'Setup interupt for Mute button on Pin1

' Setup K107
High LCDPort ' Be sure Tx Pin is idle for some time
Pause 1000 ' wait for PICAXE LCD to boot
SerOut LCDPort, T2400, ("?G420") ' configure LCD as 4 X 20
pause 200
SerOut LCDPort, T2400, ("?G420") ' configure LCD as 4 X 20
pause 200
SerOut LCDPort, T2400, ("?!01") ' configure LCD as 4 X 20
pause 200

SerOut LCDPort, T2400, ("?f")
SerOut LCDPort, T2400, ("Booted")
for b0 = 0 to 10
serout SerialPort,N2400,("<dz><v1>Picaxe</v1><h1> </h1><s1>Booting</s1><c1>0</c1><a1> </a1></dz>",cr,lf)
pause 1000
next

Main:
serout SerialPort,N2400,("<dz>")

readadc SensorPort,HSval 'read value from the probe

serout SerialPort,N2400,("<v1>",#HSval,"</v1>")
SerOut LCDPort, T2400, ("?f") 'Output to K107 LCD
pause 20
SerOut LCDPort, T2400, ("?y3?x00v0c?y0?x00") 'Output the version of firmware
pause 200


if HSval > MaxHSval then
MaxHSval = HSval 'Store highest sample value
end if
serout SerialPort,N2400,("<h1>",#MaxHSval,"</h1>")

if HSval > 99 then
HSval = 99
end if

if HSval > xlimit then 'Test the returned value
if Muted = 0 then 'Test mute state
if TestPort is Off then
high SirenPort 'Turn on siren
else if WetCount => 10 then
high SirenPort 'Turn on siren
WetCount = 10
end if
end if
inc WetCount ' Increment WetCount
SerOut LCDPort, T2400, ("Wet=", #WetCount) 'Output to K107 LCD
serout SerialPort,N2400,("<s1>Wet</s1>")

AlertVal = WetAlert 'Set LED alert sequence value
HiAlertVal = WasWetAlert 'Set historical alert value

else if HSval > moist then 'Test the returned value
SerOut LCDPort, T2400, ("Moist ") 'Output to K107 LCD
serout SerialPort,N2400,("<s1>Moist</s1>")
AlertVal = moistalert 'Set LED alert sequence value
if AlertVal => HiAlertVal then 'Test historical value
HiAlertVal = MoistAlert 'Set historical alert value
end if

else if HSval > damp then 'Test the returned value
SerOut LCDPort, T2400, ("Damp ") 'Output to K107 LCD
serout SerialPort,N2400,("<s1>Damp</s1>")
AlertVal = dampalert 'Set LED alert sequence value
if AlertVal => HiAlertVal then 'Test historical value
HiAlertVal = DampAlert 'Set historical alert value
end if
AlertVal = %0

else 'Must be dry!
AlertVal = %0 'Set LED alert sequence value
SerOut LCDPort, T2400, ("DRY ") 'Output to K107 LCD
serout SerialPort,N2400,("<s1>Dry</s1>")
Pause 30
WetCount = 0
end if

serout SerialPort,N2400,("<c1>", #WetCount ,"</c1>")

if HSval <= damp then 'Test the current value is less then Wet
low SirenPort 'Silence siren
Muted = 0 'Set mute state
low MutedPort 'Turn off Mute LED
low LedAlertPort 'Turn off Alert LED (ensure it is off!)
end if
pause 20 'Pause for K107

if Muted = 1 then
serout SerialPort,N2400,("<m1>1</m1>")
SerOut LCDPort, T2400, ("?y0?x15Muted") 'Output to K107 LCD
pause 15
else
serout SerialPort,N2400,("<m1>0</m1>")
end if


if HiAlertVal <>0 then
SerOut LCDPort, T2400, ("?y2?x15Been?y3?x15") 'Output to K107 LCD
pause 20
end if

SerOut LCDPort, T2400, ("?y0?x06?>3",#HSval, "?<") 'Output to K107 LCD
pause 20
SerOut LCDPort, T2400, ("?y3?x15")
pause 10

if HiAlertVal = WasWetAlert then
SerOut LCDPort, T2400, ("Wet") 'Output to K107 LCD
pause 5
serout SerialPort,N2400,("<a1>Been Wet</a1>")
end if
if HiAlertVal = MoistAlert then
SerOut LCDPort, T2400, ("Moist") 'Output to K107 LCD
pause 5
serout SerialPort,N2400,("<a1>Been Moist</a1>")
end if
if HiAlertVal = DampAlert then
SerOut LCDPort, T2400, ("Damp") 'Output to K107 LCD
pause 5
serout SerialPort,N2400,("<a1>Been Damp</a1>")
end if

if HiAlertVal = 0 then
serout SerialPort,N2400,("<a1>None</a1>")
end if
serout SerialPort,N2400,("</dz>",cr,lf)

Gosub flash 'Flash the Alert LED based on the variable AlertVal

goto main


flash: 'Test current AlertVal
if AlertVal <> 0 then 'Set Value variable. This variable is destroyed during this process
Value = AlertVal
else
Value = HiAlertVal
end if

if Value <> 0 then 'Test for Zero value, no need to change LED state, should be off anyway.
low LedAlertPort 'Turn off the AlertLED
For Loopx = 1 To 16 'Loop through the double byte value bit by bit
Mask = Value & 32768 'Using a mask examine the uppermost bit
If Mask = 32768 Then 'Test mask value. It will be 0 or 1
high LedAlertPort 'Turn on LED
Else
low LedAlertPort 'Turn off LED
End if
Value = Value * 2 'Shuffle the bits
pause 125 'Delay
Next Loopx
else
pause 2000 'Delay
end if
pause BigDelay

return;

interrupt:


SerOut LCDPort, T2400, ("?fHiVal")
pause 10
SerOut LCDPort, T2400, ("?y0?x06?>3",#MaxHSval, "?<")
pause 25

do while MutePortPin is on 'Debounce routine

high BuzzerPort 'Set Buzz on
pause 50
low BuzzerPort 'Set Buzz off
pause 50

loop

if Muted = 0 then 'Test current state of MUTE
Muted = 1 'Set state
high MutedPort 'Turn LED on
low SirenPort 'Turn Siren off
else
Muted = 0 'Set state
low MutedPort 'Turn LED off
end if
SerOut LCDPort, T2400, ("?f")
pause 2
setint %000000010,%00000010 'Reset mute button interupt
return
 
Last edited by a moderator:

MPep

Senior Member
What does the Epson printer interface do?
Do you need a computer to be on at all times? If so, why bother with the WizNet interface? Use Serial data.

If I've missed something, let me know.

Cheers,
MPep.
 

Anobium

Senior Member
Epson Printer Interface

This is not the correct title for the device, I guess. I have re-used the Epson FX printer interface for Picaxe projects as is very useful and it fits into a very simple slot in the case/box. It is set of touch switches and leds all in a very nice case.

I have attached a one picture I use to print the new interface (I print in reverse on overhead slides), remove the old interface and glue the new interface in place (all completed in PowerPoint).

The other picture is the interface fitted to the working solution. Not the best picture.

Simple, but very effective.

I will post a video of the assembled box asap this may be show the re-use of the Epson Printer Interface.

Anobium.
________
FORD CE14 PLATFORM SPECIFICATIONS
 

Attachments

Last edited:

Anobium

Senior Member
Computer and Serial Connnectivity

@Mpep

The computer DOES NOT have to be on at all times. I do, I have the serial interface installed into the back of the digital PBX.

Let me clarify. The solution can be standalone with sensing, local UX (audio and visual) and power. If it is wet.... you can see alerts and here it! Local mute, local test and local reset.

To the standalone configuration you can add an optional K107 LCD, this really should have another 250ma 5v supply. The unit I have built can delivery 1a but then I think I would melt the plastic casing. If it is wet.... you can see the current and previous values of the solution.

To the standalone configuration you can add the serial connectivity to a Wiznet port or a PC serial port (both options are supported but only one operational). To this serial connectivity you can add the web service/web server of intranet/internet access. If it is wet.... you get to see lots of stuff, remote reset, remote mute, remote test etc. etc.

My finally installed solution? The sensor, the box of stuff, the serial port in the PABX with the web service.

I have built the solution in modules on purpose to ensure I can re-use the archirectural layers.

I am already re-using the XML/Web Service - it is faster to set-up than any LCD interface!

So, if you want intranet/intranet access you will need either the Wiznet or the Web Service. I hope this clarifies the use case.

(Send me an private note and I will point you to the URL! and you can play!).
________
 
Last edited by a moderator:

Anobium

Senior Member
A photo of the Epson Control Panel

I have just extracted this from another old Epson printer.

The control panel is connected via a 10 pin (.1 pitch) and I have documented the internals. It is essentially as set of LEDs and assiocated resisitors and switches.
________
Wellbutrin lawsuites
 

Attachments

Last edited:

Anobium

Senior Member
Update

I have now returned to work, but, before I did... I re-wrote the web service completely. The web service reads the XML data stream from the Pixace and transforms into a page for the browser.

The previous web service solution used a piece of code that was 'freeware'. It kept crashing and I was force to write a script to monitor the web service - not clever.

The new approach uses PERL. This means it can be easily re-used by others, adapted and improved. The new approach responds to browser requests, it reads/transforms the XML data stream or is passes instruction requests (MUTE/RESET/TEST etc.) directly to the Picaxe. The new approach also includes data logs, error logs that the original approach lacked. I have adapted the web pages to support the new approach - no change from the users perspective apart from the solution is much faster a request no longer can crash the web service.

If anyone ever wants this mash-up let me know.

@dippy.... I cannot respond to your private messages, so, a personal email may help me respond.

Anobium
 
Last edited by a moderator:
Top