Embedded Rust - Collecting Temperature and Humidity Data using the SHT31 Sensor

February 2, 2024

Description

This project demonstrates how to collect Temperature and Humidity Data using the micro:bit V2 and an SHT31 Temperature and Humidity Sensor.

Project's Hardware:

  • 1 Micro:bit V2 microcontroler
  • 1 Kitronik Breakout Board Edge Connector - Note: If you don't have pin headers on the 19 or 20 through-hole, you need to solder pin headers to those through-holes.
  • 1 SHT31 Groove Temperature and Humidity Sensor
  • 1 830 hole breadboard
  • 2 4.7k Ohm Resistors
  • 1 micro-USB to USB-A Cable
  • 1 M/M 6" Premium Jumper Cables (Green) - Note: If you can find a White Premium Jumper Cable, it will color match with the sensor's cable. If that's the case, substitue the Green for your White Cable for this project.
  • 1 M/F 6" Premium Jumper Cables (Green) - Note: If you can find a White Premium Jumper Cable, it will color match with the sensor's cable. If that's the case, substitue the Green for your White Cable for this project.
  • 1 M/M 6" Premium Jumper Cables (Yellow)
  • 1 M/F 6" Premium Jumper Cables (Yellow)
  • 1 M/M 6" Premium Jumper Cable (Red)
  • 1 M/F 6" Premium Jumper Cable (Red)
  • 1 M/M 6" Premium Jumper Cable (Black)
  • 1 M/F 6" Premmium Jumper Cable (Black)

Hardware

SHT31 Temperature and Humidity Sensor

Note: For this project I spliced the cables of the SHT31 sensor with the female ends of the 4 Premium Jumper Cables (Red, Black, Green, and Yellow). I could not find a White Jumper Cable, so please notice that the female end of the Green Cable is spliced with the White Cable of the SHT31.

SHT31 Cable Splicing

Instructions:

Clone this repository and change/move into the cloned directory in your terminal window.

git clone https://github.com/CodingInGreen/microbit_v2_temp_humidity

Prepare the micro:bit V2 and Kitronik Edge Connector Breakout Board: Attach the Kitronik Edge Connector Breakout Board to the micro:bit V2.

Micro:bit V2 connected to Kitronik Breakout Board Edge Connector

Take out the 830 point breadboard and lay it on the worktable.

Take one M/F 6" Premium Jumper Cable (Yellow) and connect the female end to pin 19 on the Kitronik Breakout Board Edge Connector.
You now have the male end of the Yellow M/F 6" Premium Jumper Cable available. Plug the male end into hole a27 on the breadboard.

Take one 4.7k Ohm resistor, and plug it into hole c27 on the breadboard, which is just after the Yellow cable you plugged into breadboard.

Yellow Cable and Resistor in Breadboard

Take the other end of the 4.7k Ohm resistor, and plug it into the positive rail of the breadboard that is denoted by (+) on the board with a red line that runs along the entire board. Plug it into the rail to the left of the Yellow wire, for example in (+) on row 23.

Resistor Connected to both c27 and the positive (+) rail.

Take one M/F 6" Premium Jumper Cable (Green) and connect the female end to pin 20 on the Kitronik Breakout Board Edge Connector. Pins 19 and 20 on the Kitronik Breakout Board Edge Connector are now connected to the Yellow and Green Cables.

Pins 19 and 20 Connected

You now have the male end of the Green M/F 6" Premium Jumper Cable available. Plug the male end into hole a29 on the breadboard.

Take one 4.7k Ohm resistor, and plug it into hole c29 on the breadboard, which is just after the Yellow cable you plugged into breadboard.
Take the other end of the 4.7k Ohm resistor, and plug it into the positive rail of the breadboard that is denoted by (+) on the board with a red line that runs along the entire board. Plug it into the rail to the right of the White wire, for example in (+) on row 34.

Yellow and Green Cables and Resistors in Breadboard

Take one M/M 6" Premium Jumper Cable (Yellow) and connect one male end to hole d27 on the breadboard.

Take the other end of the M/M 6" Premium Jumper Cable (Yellow) and connect it to the SCL wire (Yellow) of the SHT31 temperature and humidity sensor.

Jumper Cable from Breadboard connected to SHT31 Cable

Take one M/M 6" Premium Jumper Cable (Green) and connect one male end to hole d27 on the breadboard. Your Yellow Jumper Cables, Green Jumper Cables, and Resistors have now all been used and they are plugged int the breadboard.

Yellow Cables, Green Cables, and Resistors in Breadboard
Take the other end of the M/M 6" Premium Jumper Cable (Green) and connect it to the Green Wire spliced with the SDA wire (White) of the SHT31 temperature and humidity sensor. In this project, I could not source a White Jumper Cable. The White Cable on the SHT31 sensor is for the SDA line. That has been spliced with a female end of a Green Jumper Cable (see image "SHT31 Cable Splicing" above).

Take one M/F 6" Premium Jumper Cable (Red) and connect the female end to the 3V pin on the Kitronik Breakout Board Edge Connector.

Take the male end of the same M/F 6" Premium Jumper Cable (Red) and connect it to the positive rail (+) at row 3.

Red Cable in 3V Rail (+)

Take one M/F 6" Premium Jumper Cable (Black) and connect the female end to the 0V pin on the Kitronik Breakout Board Edge Connector.

Take the male end of the same M/F 6" Premium Jumper Cable (Black) and connect it to the negative rail (-) at row 7.

Black Cable in 0V Rail (-)

Take one M/M 6" Premium Jumper Cable (Red) and connect one male end to the positive (+) rail of the breadboard at row 15.

Take the other male end of the M/M 6" Premium Jumper Cable (Red) and connect it to the VCC (Red Cable) of the SHT31 temperature and humidity sensor.

Take a M/M 6" Premium Jumper Cable (Black) and connect one male end to the negative (-) rail off the breadboard at row 40.

Take the other end of the M/M 6" Premium Jumper Cable (Black) and connect it to the GND (Black Cable) of the SHT31 temperature and humidity sensor.

Connect your micro:bit V2 to your computer using the micro-USB to USB-A cable.

Build and Flash your micro:bit V2:

Run this command from the root cloned directory:
 
cargo build --features v2 --target thumbv7em-none-eabihf

If you have problems with this, check out the Rust Discovery Book:
    https://docs.rust-embedded.org/discovery/microbit/index.html

Then run this command from the root cloned directory:
 
cargo embed --features v2 --target thumbv7em-none-eabihf

If you have problems with this, check out the Rust Discovery Book:
    https://docs.rust-embedded.org/discovery/microbit/index.html

The terminal should display the initilization messages and you should see periodic updates of the temperature and humidity data.

Do you see the temperature and humidity data being collected periodically?

Terminal Display - Temperature and Humidity Data Collection Cycle