Light(ADC-A905014) and Temperature(I2C-TNC75AOA) Project
Posted: Sun Nov 22, 2015 3:23 pm
Hello, a little Temperature and Light Project,
I use a TNC75AOA I²C-Sensor and a A905014 on the ADC, Schematic and Board under http://www.grautier.com/wiki/doku.php?id=raumsensor-wlan, this is my first Project with the ESP and Basic
Its Works !!!
A littel code to Readout from Bash:
sh wlansensor.sh <ip> <sensor>
Edit: Readout from Bash
Edit: ADC Code
Edit: i2c Code
Remove the BDC and use the hex() Funktion is Faster
I use a TNC75AOA I²C-Sensor and a A905014 on the ADC, Schematic and Board under http://www.grautier.com/wiki/doku.php?id=raumsensor-wlan, this is my first Project with the ESP and Basic
Its Works !!!
Code: Select all
' Variablen
'
addr = 73 ' I2C-Adresse 7bit Dezimal fuer den TNC75
mwkp = 1.5 ' Positive Messwertkorrektur fuer den TNC75
mwkn = 0 ' Negative " "
'
' ADC
'
ai adc
wprint ("Licht: ")
adc = adc / 10.24
wprint (adc)
wprint (" %")
wprint ("<br>")
'
' I2C -> TNC75
'
i2c.begin(addr)
i2c.write(0)
i2c.end()
i2c.requestfrom(addr,2)
lsb = i2c.read()
msb = i2c.read()
'
' I2C Daten Auswertung -> TNC75 +0 - +125c
'
wprint ("Temperatur: ")
tmp = lsb / 2
tmp = tmp + mwkp
tmp = tmp - mwkn
wprint (tmp)
wprint (" C")
wprint ("<br>")
end
A littel code to Readout from Bash:
sh wlansensor.sh <ip> <sensor>
Code: Select all
data=$(wget -qO- http://${1}/run)
data=$(wget -qO- http://${1}/index.html)
### Werte holen ###
case "$2" in
licht)
data=$(echo $data | grep Licht: | awk '{print $3}' | cut -d "." -f 1)
;;
lichtdz)
data=$(echo $data | grep Licht: | awk '{print $3}')
data=$(echo "scale=1; $data / 10" | bc)
;;
temp)
data=$(echo $data | grep Temperatur: | awk '{print $5}')
data=$(echo "${data%?}")
;;
*)
echo "Parameter:"
echo "wlansensor.sh <ip> <sensor>"
echo "<Sensor> = licht=Lichtsensor lichtdz=Lichtsensor/10, temp=Temperatur"
;;
esac
### Wert ausgeben ###
echo $data
exit 0
Edit: Readout from Bash
Edit: ADC Code
Edit: i2c Code
Remove the BDC and use the hex() Funktion is Faster