Let's talk to an I2C sensor.
We'll use the BME280 sensor which can read temperature, humidity, and pressure. Here's the wiring diagram:
For the older version of the board, you'll need to jumper D1 and D2 together:
sudo pip3 install adafruit-circuitpython-bme280
Note that this step is the same as shown in the main BME280 guide. You would do the same thing for any other sensor.
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries # SPDX-License-Identifier: MIT import time import board import busio import adafruit_bme280 # Create library object using our Bus I2C port i2c = busio.I2C(board.SCL, board.SDA) bme280 = adafruit_bme280.Adafruit_BME280_I2C(i2c) # OR create library object using our Bus SPI port # spi = busio.SPI(board.SCK, board.MOSI, board.MISO) # bme_cs = digitalio.DigitalInOut(board.D10) # bme280 = adafruit_bme280.Adafruit_BME280_SPI(spi, bme_cs) # change this to match the location's pressure (hPa) at sea level bme280.sea_level_pressure = 1013.25 while True: print("\nTemperature: %0.1f C" % bme280.temperature) print("Humidity: %0.1f %%" % bme280.relative_humidity) print("Pressure: %0.1f hPa" % bme280.pressure) print("Altitude = %0.2f meters" % bme280.altitude) time.sleep(2)
Copy and save the above code and then run it with:
python3 bme280_simpletest.py
and you should see it print out sensor readings over and over:
Using STEMMA QT
The new version of the FT232H features a STEMMA QT connector. This makes connecting to newer breakouts that also have a STEMMA QT connector super easy. Just use a STEMMA QT cable:
And then you can just wire the FT232H and the STEMMA QT breakout directly together. You don't even need a breadboard or soldering.
For breakout boards without a STEMMA QT connector, you can either use the header pins on both boards, that is, don't even use the STEMMA QT connector:
Or use the STEMMA QT connector on the FT232H breakout along with a STEMMA QT cable with one end of the cable cut off. You can then terminate the cut off end to the breakout in whatever way works best for your application.
There are also some STEMMA QT cables with header connectors which might be useful: