HTU21D example shows how to read humidity and temperature samples using theCore. See theCore documentation for HTU21D example for more information.
Target name | Configuration file | Description |
---|---|---|
stm32f4_disc | stm32f4_discovery.json | STM32F4 discovery board |
Connect HTU21D to I2C1 on the Discovery board using following pins:
PB6 (I2C1 SCL)
sensor's SCL
PB9 (I2C1 SDA)
sensor's SDA
+3.3V
sensor's VDD
GND
sensor's GND
Attach any preferable UART-to-USB converter such as this module according to following pinout:
PD8 (USART3 TX)
module's RX
PD9 (USART3 RX)
module's TX
GND
module's GND
Install and initialize theCore (if not done previously):
pip3 install tcore # Or if python3-pip is default: pip install tcore tcore bootstrap
Download the example:
tcore init --remote https://github.com/theCore-embedded/example_sensor_htu21d cd example_sensor_htu21d
Run compile
command using theCore CLI:
tcore compile --target stm32f4_disc
Firmware will be flashed via openocd
debugger and flash
command.
Connect stm32f4 Discovery board to USB cable and connect USB <-> UART converter to the PC.
Launch
minicom
with device associated with USB <-> UART converter. (/dev/ttyUSB0
here used as an example):# From new terminal tcore runenv "minicom -D /dev/ttyUSB0"
Or the same, but with superuser permissions:
# From new terminal tcore runenv --sudo "minicom -D /dev/ttyUSB0"
Determine stm32f4discovery board revision.
If you don't remember your board revision, check FAQ section https://forgge.github.io/theCore/faq.html#how-to-check-stm32f4-discovery-board-revision.html
Launch
flash
command in separate terminal, as shown below.For old STM32F407G-DISC boards, with STLINK/V2:
tcore flash --sudo
For new STM32F407G-DISC1 boards, with STLINK/V2.1:
tcore flash --sudo --debugger-config stlink-v2.1
Observe console output in the minicom:
Welcome to theCore the_core v0.3.0.321 90f4894-dirty Starting HTU21D sensor... Reset done Temperature: 25.362 Celsius Humidity: 45.162% Temperature: 25.362 Celsius Humidity: 45.170% Temperature: 25.362 Celsius Humidity: 45.155% Temperature: 25.362 Celsius Humidity: 45.147% Temperature: 25.351 Celsius Humidity: 45.155%