Difference: SHT30NopI2CTemperatureAndHumiditySensor (2 vs. 3)

Revision 32020-05-23 - UliRaich

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

The SHT30 I2C Temperature and Humidity Sensor

Introduction

Line: 93 to 93
  sht30.stopPeriodicMeas(): Stops "continuous measurement mode"
Changed:
<
<
sht30.measPeriodic(self,mps=0.5, repeatability=REP_P_HIGH, raw=False, noOfMeas=50): Starts continuous measurements using sht30.startPeriodicMeas(), reads out the data after each measurement cycle and stores them into a list, stops continuous measurements using stopPeriodicMeas() as soon as "noOfMeas" measurements have been reached. Returns the list of acquired measurements.
>
>
sht30.measPeriodic(self,mps=0.5, repeatability=REP_P_HIGH, raw=False, noOfMeas=50, callback=None): Starts continuous measurements using sht30.startPeriodicMeas(), reads out the data after each measurement and stops continuous measurements using stopPeriodicMeas() as soon as "noOfMeas" measurements have been reached. You can specify a callback function which is called with [tempC,humi], the temperature in °C and the humidity value in % as parameter if raw is False or with the raw data [tempRaw,humiRaw,checksum] as parameter if raw is True.

sht30.readAlert(high=True,set=True,raw=False): Reads the alert limits. Returns temperature and humidity limits for alerts in °C and % or the raw data read out if raw == True.

sht30.writeAlert(self,tempC,humi,high=True,set=True): Write the alert limits

Here you find the driver itself:

https://afnog.iotworkshop.africa/pub/IoT_Course_English/SHT30NopI2CTemperatureAndHumiditySensor/sht3x.py.txt

and here some test code exercising the driver:

https://afnog.iotworkshop.africa/pub/IoT_Course_English/SHT30NopI2CTemperatureAndHumiditySensor/sht3xTest.py.txt

And here is the result printed out by the test program:

>>> %Run -c $EDITOR_CONTENT
Serial number: 0x317d411
Measure with clock stretching, the delay between writing the cmd and reading back the result
is calculated from the repeatabilty parameter (see data sheet)
Temperature: 24.26994 °C, Humidity: 61.74011 %
Measure without clock stretching
After sending the command the SHT30 is polled for the result every 1ms
Generates a timeout exception if the SHT30 does not respond in time
Temperature: 24.28329 °C, Humidity: 61.75385 %
Read and print the alert settings: High limit to set the alert
The data sheet says that this should be 60°C and 80%
Temperature limit high: 59.93164 °C Humidity limit high: 79.6875 %
Set accelerated response time
Print the current status register contents
--------------------------------------------------
Status register content: 0x2060
--------------------------------------------------
No alert pending
Heater is enabled
Last command succeeded
Checksum of last write command was correct
Clear the status register, switch on the heater and print the values again
Switch on the heater
--------------------------------------------------
Status register content: 0x20a0
--------------------------------------------------
No alert pending
Heater is enabled
Last command succeeded
Checksum of last write command was correct
Start periodic measurement
We pass the function printContinuousValues as callback routine, printing the temperature and humidity values
read out in each measurement cycle
Period measurement will take 20.0 s
Interval: 2.0
Temperature: 24.21387 °C, Humidity: 61.6684 %
Temperature: 24.26994 °C, Humidity: 61.78131 %
Temperature: 24.28329 °C, Humidity: 61.79504 %
Temperature: 24.24057 °C, Humidity: 61.80878 %
Temperature: 24.25392 °C, Humidity: 61.83167 %
Temperature: 24.24057 °C, Humidity: 61.82861 %
Temperature: 24.22722 °C, Humidity: 61.85608 %
Temperature: 24.24057 °C, Humidity: 61.91101 %
Temperature: 24.22722 °C, Humidity: 61.92932 %
Temperature: 24.21387 °C, Humidity: 61.90643 %
--------------------------------------------------
Status register content: 0x2000
--------------------------------------------------
No alert pending
Heater is enabled
Last command succeeded
Checksum of last write command was correct
>>>

  -- Uli Raich - 2020-05-22

Comments

<--/commentPlugin-->
Added:
>
>
META FILEATTACHMENT attachment="sht3x.py.txt" attr="" comment="" date="1590263292" name="sht3x.py.txt" path="sht3x.py.txt" size="18915" user="UliRaich" version="1"
META FILEATTACHMENT attachment="sht3xTest.py.txt" attr="" comment="" date="1590263292" name="sht3xTest.py.txt" path="sht3xTest.py.txt" size="2814" user="UliRaich" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback