mirror of
https://github.com/supleed2/ELEC60013-ES-CW1.git
synced 2024-12-22 21:45:48 +00:00
Testing script for Si7201 and TMP006
This commit is contained in:
parent
66403e9e03
commit
be0aa0fb87
27
main.py
27
main.py
|
@ -1 +1,26 @@
|
||||||
print("Raspberry Pi Zero W, up and running!")
|
from time import sleep
|
||||||
|
import smbus2
|
||||||
|
import si7201
|
||||||
|
import tmp006
|
||||||
|
|
||||||
|
bus = smbus2.SMBus(1) # set up I2C bus 1
|
||||||
|
|
||||||
|
print("========== Testing Si7201 ==========")
|
||||||
|
temphumsensor = si7201.Si7201(bus) # set up Si7201 sensor
|
||||||
|
temphumsensor.reset() # reset the sensor
|
||||||
|
sleep(1) # wait for sensor to reset
|
||||||
|
print(temphumsensor.temperature) # read the temperature and print
|
||||||
|
print(temphumsensor.humidity) # read the humidity and print
|
||||||
|
|
||||||
|
print("========== Testing TMP006 ==========")
|
||||||
|
irtempsensor = tmp006.TMP006(bus, 0x41, tmp006.SAMPLERATE_4HZ) # set up TMP006 sensor
|
||||||
|
irtempsensor.active(1) # turn on the sensor
|
||||||
|
sleep(1) # wait for sensor to turn on
|
||||||
|
print(irtempsensor.manID) # read the manufacturer ID and print
|
||||||
|
print(irtempsensor.devID) # read the device ID and print
|
||||||
|
print(irtempsensor.temperature) # read the temperature and print
|
||||||
|
|
||||||
|
print("========= TMP006 Test Loop =========")
|
||||||
|
while True:
|
||||||
|
print(irtempsensor.temperature) # read the temperature and print
|
||||||
|
sleep(1) # wait for 1 second
|
||||||
|
|
Loading…
Reference in a new issue