From be0aa0fb873f46a9b30caa525b829f0723de0a84 Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Wed, 9 Feb 2022 10:49:00 +0000 Subject: [PATCH] Testing script for Si7201 and TMP006 --- main.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index cc8d835..b3717e1 100644 --- a/main.py +++ b/main.py @@ -1 +1,26 @@ -print("Raspberry Pi Zero W, up and running!") \ No newline at end of file +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