I wasn't going to put this in the public eye just yet, but who knows when I'll get back to it.
This is definitely a "work in progress", and will probably need substantial additional work but for anyone who's interested, here's the guts of a working system.
This is designed as an extensible system that can handle a great number of weatherstations. Each station initiates the communication with the server, but the server then controls what is sent and how often. The version presented here supports only a precision barometric pressure and temperature sensor, wind direction, average windspeed and 3-second-wind-gust speed. The system can easily support rain gauge, pyranometer, UV sensor, multiple temperature sensors (eg, soil temperature, shaded, direct exposure, inside) and pretty much anything else you can connect to a WC8.
The URL it submits to isn't being made public at this point, because each station will need a unique identifier and I haven't set up a system to provide them. The server-side code isn't being released.
Basically, on power-up, the system waits for the board and attached devices to settle, then initiates a call to the server. The server will identify the IP address of the station. If it isn't already known, the server sends back a response that causes the station to return a number of parameters including the stations ID, altitude, sensor calibration details etc. The server then instructs the station to send each of its sensor values, one at a time, and finally, tells the station when to call again. This lets the server synchronise all remote stations to send data when it's needed.
The server will never initiate communications with the station, thus the station can be behind a NAT router, or firewall, with no problems.
Assuming there's any interest, I'll post circuits of the interface etc. I've used over-the-counter spare parts, and inexpensive common parts from ebay.
Enjoy...
This is definitely a "work in progress", and will probably need substantial additional work but for anyone who's interested, here's the guts of a working system.
This is designed as an extensible system that can handle a great number of weatherstations. Each station initiates the communication with the server, but the server then controls what is sent and how often. The version presented here supports only a precision barometric pressure and temperature sensor, wind direction, average windspeed and 3-second-wind-gust speed. The system can easily support rain gauge, pyranometer, UV sensor, multiple temperature sensors (eg, soil temperature, shaded, direct exposure, inside) and pretty much anything else you can connect to a WC8.
The URL it submits to isn't being made public at this point, because each station will need a unique identifier and I haven't set up a system to provide them. The server-side code isn't being released.
Basically, on power-up, the system waits for the board and attached devices to settle, then initiates a call to the server. The server will identify the IP address of the station. If it isn't already known, the server sends back a response that causes the station to return a number of parameters including the stations ID, altitude, sensor calibration details etc. The server then instructs the station to send each of its sensor values, one at a time, and finally, tells the station when to call again. This lets the server synchronise all remote stations to send data when it's needed.
The server will never initiate communications with the station, thus the station can be behind a NAT router, or firewall, with no problems.
Assuming there's any interest, I'll post circuits of the interface etc. I've used over-the-counter spare parts, and inexpensive common parts from ebay.
Enjoy...
Code:
START
tsync:
tstle CYEAR 2013 ; has time synchronised yet?
goto tsync ; wait until it has
set COUNTER 0 ; clear wind counter
set var8 0
add cts 10 var1 ; wait before calling home.
delay 30 ; wait for chip to settle
loop: ; loop entry after an action is completed
set wsrply 0 ; clear webreply flag
wait:
sub cts ram6 ram1 ; time from last to now
bz notsec ; not a new second, check other stuff
set ram6 cts
sub COUNTER ram8H ram1 ; current counter-(3secAgo)
tstgt ram1 ram7L ; higher than last highest?
set ram7L ram1 ; save highest per-3-seconds value
set ram8H ram8L ; ripple
set ram8L ram7H
set ram7H COUNTER ; current 3 seconds ago in 8H, 2 in 8L 1 in 7H.
set var7 ram7L ; for debugging
notsec:
andb wsrply 255 ram1 ; get reply code
set var2 cts ; also for debugging
tstne ram1 1 ; reply ?
goto n1
div wsrply 256 ram1 ; shift answer to get seconds
add cts ram1 var1 ; set next response time
goto loop ; clear flag and wait
n1:
tstne ram1 2 ; is it cmd2 ? (send avg wind speed)
goto n2
set ram1 wsrply
sub cts var8 ram2 ; seconds since last windspeed
mul COUNTER 10 ram3 ; *10 for a extra precision
div ram3 ram2 ram1H ; pulses/second = metres/second
webset url3 ram1 ; send
goto loop
n2:
tstne ram1 3 ; is it cmd3 ? (send wind gust)
goto n3
set ram1 wsrply
mul ram7L 10 ram2 ; *10 for extra precision
div ram2 3 ram1H ; but it was over 3 seconds
webset URL3 ram1 ; send
goto loop
n3:
tstne ram1 4 ; is it cmd4 ? (wind direction)
goto n4
mul aip1 360 ram2 ; input 0-5V = 360 degrees.
div ram2 500 ram2 ; scale
mod ram2 359 ram1H ; angle is 0-359 degrees
set ram1L wsrply
webset url3 ram1 ; and clear counters
set COUNTER 0
set ram7L 0 ; clear high
set var8 cts ; and set timestamp
goto loop
n4:
tstne ram1 20 ; is it cmd20 ? (send my ID)
goto n20
set ram1 wsrply
set ram1H urom1 ; build reply
webset url3 ram1
goto loop
n20:
tstle ram1 20 ; is reply 21 or upwards?
goto ncal
tsteq ram1 21 ; cal21 = UROM1 (ID)
set ram2H urom1
tsteq ram1 22 ; cal22 = UROM2 (altitude in m AMSL)
set ram2H urom2
tsteq ram1 23 ; cal23 = UROM3 (wind direction offset from north in degrees)
set ram2H urom3
tsteq ram1 24 ; cal24 = UROM4 (unused for now)
set ram2H urom4
tstle ram1 24 ; send UROM cal now
goto sendurom
sub ram1 25 ram1 ; convert to offset
mul ram1 2 ram1 ; double byte offset as required
add ram1 0xaa ram1 ; convert to calibration offset 11->0xaa (1st word), 12->0xab (2nd word) etc
callsub get ; read calibration data specified word
set ram2H ram1L
sendurom:
set ram2L wsrply
webset URL3 ram2 ; send back cal data in upper 16 bits, ID in lower 16 bits
goto loop ; send data, clear flag and wait
ncal:
tstlt cts var1 ; time to call home yet?
goto wait ; no
i2cwrite 1 0 0xee ; set up for temperature conversion
i2cwrite 0 0 0xf4
i2cwrite 0 1 0x2e
delay 10 ; brief pause for conversion to complete
set ram1 0xf6 ; read back uncompensated temperature
callsub get
set ram2H ram1L ; save temp into high byte of ram2
i2cwrite 1 0 0xee ; set up for pressure conversion
i2cwrite 0 0 0xf4
i2cwrite 0 1 0x34 ; OSS x34 for single read, xf4 for max oversample
delay 80 ; brief pause for conversion to complete
set ram1 0xf6 ; read back uncompensated pressure
callsub get
set ram2L ram1L ; add pressure
webset URL3 ram2 ; log
add cts 30 var1 ; do not loop too fast
goto loop
end
get:
i2cwrite 1 0 0xee
i2cwrite 0 0 ram1
i2cwrite 1 0 0xef
i2cread 0 0 ram11
i2cread 1 1 ram10
ret