Hi All
Have being having a play around with the drf1276dm and the adafruit htu21d-f breakout board to create a remote connection
between 2- 28x2
The code for the htu21d is a rework of Phil Hornsbys htu21d demo.bas on the remote unit.
The only problem I encounted with the drf1276dm was with the DRF tool not recongising the presense of the unit when using the dac02 driver
This was over come by using jumper wires (male-female) connecting the 2 units from 1 to 5 omitting 6 and 7. Other than that its quite an impresive and simple to use piece of kit
Master Code
slave to follow
Have being having a play around with the drf1276dm and the adafruit htu21d-f breakout board to create a remote connection
between 2- 28x2
The code for the htu21d is a rework of Phil Hornsbys htu21d demo.bas on the remote unit.
The only problem I encounted with the drf1276dm was with the DRF tool not recongising the presense of the unit when using the dac02 driver
This was over come by using jumper wires (male-female) connecting the 2 units from 1 to 5 omitting 6 and 7. Other than that its quite an impresive and simple to use piece of kit
Master Code
Code:
'Connection for the DRF1276DM to the picaxe 28X2
'picaxe A.1(TXD)--------Pin 4 (RXD) DRF
'picaxe A.2(RXD)--------Pin 5 (TXD) DRF
'used to wake up Picaxe up from sleep mode
#picaxe 28x2
#no_data
#no_table
Symbol Qualifier= 254
symbol fail=b25
symbol lamp=w7
symbol dry=w8
symbol rh=w9
symbol linked=b8
symbol fr=b10
pause 2000
MAIN:
do
sertxd("MAIN",cr,lf)
low b.7
serout A.1,T9600,(85,85,85,85,Qualifier,"Hello")'wake up slave call
serin A.2,T9600,(Qualifier,"ACK")' slave connected responce
serin[2000], A.2,T9600,linked
if linked="X" then 'X indicates running slot 1 on slave to initalise HTU21D on first up power
linked=0
pause 1000
goto lingalong
endif
obtain:
b5=0'call to measure light levels
serout A.1,T9600,(b5)'tell remote unit which reading to undertake
do
serin A.2,T9600,lamp 'result from remote unit
serout A.1,T9600,(lamp) 'bounce result back to check for errors
serin A.2,T9600,b0 'master waits until conformation of value or error from slave
loop until b0="Y" or b0="N"
if b0="N" then
sertxd("light sensor error",cr,lf)
endif
'sertxd("lamp ",#lamp," b0 ",#b0," b5 ",#b5,cr,lf)
'call to test supply state prior to read
do
b5=1
serout A.1,T9600,(b5):pause 20 'want case
serin A.2,T9600,b0,b1 'yes or no answer no value
loop until b0="Y" or b0="N"
if b0="N" then
sertxd(" sensor error",cr,lf)
'pause 2000
'goto main
endif
'sertxd("1st Supply b0 ",#b0," b1 ",#b1,cr,lf)
do
b5=2
serout A.1,T9600,(b5):pause 20
serin A.2,T9600,b0,b1 'yes or no answer no value
loop until b0="Y" or b0="N"
if b0="N" then
sertxd("Battery Low Change",cr,lf)
'pause 2000
'goto main
endif
'sertxd("2nd Supply b0 ",#b0," b1 ",#b1,cr,lf)
b5=3'call to measure tempreture
serout A.1,T9600,(b5)'tell remote which reading to undertake
do
serin A.2,T9600,dry
serout A.1,T9600,(dry)
serin A.2,T9600,b0,b1
loop until b0="Y" or b0="N"
if b0="N" then
sertxd("tempreture sensor error",cr,lf)
endif
'sertxd("dry ",#dry," b0 ",#b0," b1 ",#b1," b5 ",#b5,cr,lf)
b5=4'call to measure humidity
serout A.1,T9600,(b5)'tell remote which reading to undertake
do
serin A.2,T9600,rh
serout A.1,T9600,(rh)
serin A.2,T9600,b0,b1
loop until b0="Y" or b0="N"
if b0="N" then
sertxd("humidity sensor error",cr,lf)
endif
'sertxd("rh ",#rh," b0 ",#b0," b1 ",#b1," b5 ",#b5,cr,lf)
b5=5'call to measure light levels
serout A.1,T9600,(b5)'tell remote unit which reading to undertake
do
serin A.2,T9600,fr 'result from remote unit
serout A.1,T9600,(fr) 'bounce result back to check for errors
serin A.2,T9600,b0 'master waits until conformation of value or error from slave
loop until b0="Y" or b0="N"
if b0="N" then
sertxd("light sensor error",cr,lf)
endif
b5="z"
serout A.1,T9600,(b5)'w5 end loop in slave return to main
sertxd("lamp ",#lamp," Dry ",#dry," Hum ",#rh," FR ",#fr,cr,lf)
lingalong:
high B.7
sertxd("in timing loop",cr,lf)
for b10= 1 to 30
pause 1000
next b10
sertxd("out of timing loop",cr,lf)
sertxd(cr,lf)
loop
none: 'for future development
serout B.1,N9600,("sensor unit failed to read")
b0="z"
return