Exercise 5: The I2C bus and the SHT30 Temperature and Humidity Sensor

Introduction

While the DHT11 uses a proprietary protocol the SHT30 make use of a standardized protocol: the I2C protocol, invented by Philips at the beginning of the 1980's. To get you going with I2C please have a look at https://learn.sparkfun.com/tutorials/i2c/all where the protocol is nicely described. You can find all the details about the SHT30 in its data sheet:

https://iotworkshop.africa/pub/IoT_Course_English/TheI2CBusAndTheSHT30TemperatureAndHumiditySensor/SHT30Datasheet.pdf

Exercise 1: I2C Bus Scan

I2C is supported by a driver in the MicroPython binary.

Write a script that scans the I2C bus and prints all available I2C addresses in the following form:

i2cscan.png

In the example above only the SHT30 with its address B: 0x45 is connected to the I2C bus.

Exercise 2: Read out the SHT30

First of all let's have a look at the SHT30 documentation.

This time we are going to be lazy and just use a pure Python driver written by 'Roberto Sánchez which you can find on github at https://github.com/rsc1975/micropython-sht30/blob/master/sht30.py. The most interesting documents are

I will give no further explication on how to use the driver. Please read the source code and find out yourself which methods are implemented and how to use the driver. Does it work out of the box or do we have to make some modifications?

The driver is already hard-coded in the MicroPython binary and does not need to be uploaded to the ESP32 to be used.

-- Uli Raich - 2020-05-14

Comments

Topic attachments
I Attachment History Action Size Date Who Comment
PDFpdf SHT30Datasheet.pdf r1 manage 919.8 K 2020-05-14 - 15:18 UliRaich  
PNGpng i2cscan.png r1 manage 40.4 K 2020-05-14 - 15:01 UliRaich  
Texttxt sht30.py.txt r1 manage 6.5 K 2020-05-14 - 15:29 UliRaich  
Edit | Attach | Watch | Print version | History: r13 | r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r2 - 2020-05-17 - UliRaich
 
  • Edit
  • Attach
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