Who is using the water?... the bore monitor speaks

At the top of the hill on my rural property is a bore that provides stock water for my stock and three neighboring properties.

 

Bore Shed

 

So what does this have to do with thingspeak?

From time to time faults in the various farm system drain water from the header tank faster than the bore pump can pull water out of the ground.... so the pump runs continually.  Expensive on power but also potentially damaging.  Normal use is about 1 hour per day in summer, much less in winter.

 

Pump

 

(Pump)

The problem was how to know if the pump was running excessively without climbing the hill.... and even if I did check it was hard to know if the pump was running because it had just reached to refill point or had been running for three days.

A couple of years back I built a bore monitor that used an IR beam to determine of the bore pump was running and could be queried over the wireless network by a ruby application. 

The IR source and receiver are both powered by PICAXE08M microcontrollers.

 

IR Sender

(IR Beam Sender)

 

 

IR Receiver

 

(IR Beam Receiver)

The PICAXE code for the IR Beam Sender and Receiver are available here.  The Receiver uses a TTL output to indicate the bore running state. 

By querying every 5 minutes and storing the data in a MYSQL database on my server I could graph daily usage over time and see when things had gone awry.

The network connection in the original design was performed using an AVR AT90S8515 and a Packet Wacker ethernet interface.  For 2 years this worked well and then the Packet Wacker died.

Around this time i had been playing with DLink DSL-502T ADSL models and reflashing them with OpenWRT to provide Amateur Radio IGate services.  These worked really well in the APRS application so I wrote a Ruby application that monitors the IR sensor via a GPIO pin on the DSL and provides a browser based summary of the last 30 days activity.

Bore Running Summary

The status pages work well inside my network but I wasn't keen on opening a port on my router so I can check the status while I was at work or on vacation.  Unfortunately problems only happen when you go on vacation.

 

Thingspeak to the rescue....

 

Building a DLink DSL-502T Based IGate - TNC Schematic and Firmware

As mentioned elsewhere the TNC we use in the Igates is based on the ATMega8 based TNC design from Henry Carl Ott (N2RVQ).

For those interested in constructing their own here is the schematic

Mega8TNC Schematic

and version 1.9 AVR TNC firmware.

The firmware is a slightly modified version of N2RVQ's version 1.8 firmware which we call version 1.9.  

The difference is a startup delay to prevent the TNC transmitting via the serial port and preventing the DSL-502T from booting.

When programming an ATMega8 with the firmware ensure you set the fuses to 0xDA (High) and 0xBF (Low).   Incorrect fuse settings will prevent the chip from starting correctly.

 

DSL-502T IGate Front Panel LEDs

There are 5 LED's on the front of the DSL-502T.
 
DSL-502T IGate Front Panel 
 
Not much to say about the Power LED.  If the power is connected it should be lit.
 
The Status LED will start flashing as the unit boots and once the boot process is complete it will continue flashing at a slower rate (approximately once per second) as a "heartbeat".
 
The third (ADSL) LED does nothing.  Unfortunately it is not connected to a GPIO pin so we can't do anything useful with it.
 
The fourth Ethernet/Network LED has three states:
Off = Only during the initial stages of boot.
Flashing = Could not get an IP address on the network.  Check your network connection and that you have a DHCP server somewhere that will allocate an address.
On = Network running and IP address correctly assigned.
 
The USB/APRSD LED has three states:
Off = Only during the initial stages of boot.
Flashing = Could not find a configuration file for this unit at http://www.qsl.net/zl1vkaprs/dsl502t.  The configuration files are named with the Ethernet MAC Address of the unit.
On = Configuration file loaded and aprsd running.
 
So if everything boots OK and is operational then the Power, Ethernet and USB LED's should be steady on and the Status LED will be flashing.
 
 

Programming the DSL-502T IGate using “Damn Small Linux”

Items you need to get started:
 
1.  The “Damn Small Linux” ISO from http://distro.ibiblio.org/pub/linux/distributions/damnsmall/current/current.iso burn to a CD (approx size 50mb).
2.  A PC able to boot the Damn Small Linux CD with a connection to the internet.
 
Follow the programming steps as follows:
1.  Boot the “Damn Small Linux” ISO.
 


 
2.  To program the DSL502T the PERL and CURL software in the “Damn Small Linux” image needs to be updated
Start the “MYDSL Browser”.
 

 
Download the “MYDSL” application database if prompted.
Use “Text Search” to locate the “Perl 5.8.0DSL” package.

Select the “Perl5.8.0DSL” package and “Install Selected” (approx size 8mb).

Use “Text Search” to locate the “CURL.tar.gz” package.
Select the “CURL.tar.gz” package and “Install Selected” (approx size 300kb).
Close the “MYDSL Browser”.
 
3. Download the latest DSL-502T firmware:
Press the “Term” button on the toolbar to open a terminal window.
Download and extract the firmware with the command:
 
curl http://www.quicktrip.co.nz/igate_dsl502t.tar.gz | tar xvz

On completion of the download you will have a “dsl502t” folder containing three files.
To program a DSL-502T with the downloaded firmware:
Change to the dsl502t folder
 
cd ./dsl502t
 
Ensure the DSL-502T is switched off.
Disconnect your PC from the internet connection and connect it the DSL-502T.
 
Ideally this should be done using a hub as most modern Ethernet cards take too long to power up if connected directly to the DSL-502T.
It is recommended that there be no other devices connected to the hub as other network traffic can interfere with the programming process.
 
4.  Set the IP address of “Damn Small Linux” to “192.168.1.3”.
 
Press the “Panel” button on the toolbar to open the “DSL Control Panel”.

 
Press the "NetCardConfig" button to open the network configuration dialog.
Enter the network configuration as follows:
 

Use DHCP Broadcast  No 
Address IP  192.168.1.3
Network Mask  255.255.255.0
Broadcast 192.168.1.255 
Gateway  192.168.1.254
Save Configuration  Yes
 


Press “Apply” to activate the configuration.
Close the “DSL Control Panel”.
 
5. Program the DSL-502T in the terminal window by:
 
Entering the command:
 
./flash
 
Power on the DSL-502T.
 
All going well the DSL-502T will be detected, the programming will be performed and the DSL-502T will reboot at the end of the process.
 
Possible problems are:
1. The DSL-502T is not found on the network and the programming fails.

Repeat step 5 to ensure the IP address is correctly configured as 192.168.1.3
Try using a different network cable or hub.
 
2. A device is recognised but it is reported as being the wrong type. This may occur if you have a Generation II (C5 Hardware revision) DSL-502T or a different device. You will not be able to program the device using this procedure.
3. The device is recognised and the programming starts but the dots stop. This can occur due to other network traffic or timing issues when transferring data to the DSL-502T.
 
Press Cltr-C to stop the programming script.
Repeat step 5 without powering off the DSL-502T.
 
 
 


Page 16 of 25

Powered by Easytagcloud v2.1

Contact Andrew Quinn

jaquinn@ihug.co.nz http://twitter.com/jaquinn