Testing script for Si7201 and TMP006

This commit is contained in:
Aadi Desai 2022-02-09 10:49:00 +00:00
parent 66403e9e03
commit be0aa0fb87
No known key found for this signature in database
GPG key ID: CFFFE425830EF4D9

27
main.py
View file

@ -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