Example Code for micro:bit-Ambient Temperature and Humidity Sensor

Last revision 2026/01/14

This article offers comprehensive guidance on utilizing the micro:bit to measure ambient temperature and humidity, complete with hardware setup, software instructions via MakeCode, and a sample code link to support hobbyists and educators in climate data monitoring projects.

Software Preparation

  1. Enter the MakeCode programming platform in browser: https://makecode.microbit.org/
  2. Create a new project and name it.
  3. Load in the program library of xia_mi board: click “setting”, and “expansion” in turn, then paste this link in the search box: https://github.com/DFRobot/pxt-DFRobot_xia_mi_Board.

Sample Code

MakeCode Program Link: https://makecode.microbit.org/_K7y2TtVvMio7

Read temperature and humidity

Was this article helpful?

TOP