temperature_sensor

Temperature sensor

The temperature sensor is a smart solution for projects that work with measuring ambient temperature. It allows for easy connection via dupont wires and immediate reading of temperature values using the micro:bit in the MakeCode environment. Try out temperature alarms, monitoring changes during the day or measuring in different conditions while learning the basics of programming, electronics and working with sensors in a fun way.

Description

The temperature sensor is a simple input module that allows for accurate measurement of ambient temperature over a wide range. It is ideal for weather experiments, measuring environmental changes, or demonstrating physical phenomena. Thanks to the Dupont wires, it is easy to connect to the micro:bit via the expansion board.

Specifications

  • Converter manufacturer: OMG Robotics
  • Probe type: DS18B20
  • Working voltage: 3V - 5,5V
  • Measuring range: -55°C to +125°C
  • Measurement accuracy: ± 0,5°C
  • Connection: Dupont

Connection

Thermometer – Module Connection

  • Yellow cable: signal wire – connect to terminal Y (yellow)
  • Red cable: power wire – connect to terminal R (red)
  • Black cable: ground wire – connect to terminal B

Connection Module – MB2 (micro:bit)

  • SIG: signal pin – connect to pin P0 (yellow signal bar)
  • VCC: power pin – connect to 3V3 (white positive power rail)
  • GND: ground pin – connect to GND (black negative power rail)

The connection can be done in another way, but it is necessary to set the correct signal pin in the program. If you use the program below, connect the wire to the yellow pin 2 or adjust the signal pin setting in the program.

LCD-MB2 connection

  • VCC: power pin – connect to 3V3 (white power strip)
  • GND: ground pin – connect to GND (black ground bar)
  • SCL: I2C clock signal – connect to SCL pin
  • SDA: I2C data signal – connect to SDA pin
temperature_sensor_mb2

Program

Basic program

If you don't have a display at hand, you can display the temperature on the micro:bit display. Once connected correctly, the measured temperature will start to appear on the display.

Basic program - LCD display

When starting the program, we first initialize the LCD display using the “connect LCD at I2C” block with a fixed address of 39, which is standard for the LCD1602 display. We then display the name “OMG Robotics” or any custom text, such as the name of the school, on the display. After a short pause, we clear the display and set static text on the first line – ideally a description of the measured quantity including the unit, such as “Temperature (°C)”. This text will be displayed from the first position of the line, we can leave the length as default and set the alignment as needed.

In the infinite loop of the program, we will continuously display the current measured value from pin P0, to which the thermometer is connected, on the second line of the display. This value is first rounded to one decimal place to make the display clearer. The program created in this way serves as a simple thermometer with output to the LCD display.

Tasks

Task 1: Measuring the temperature in different parts of the room

Connect the temperature sensor according to the diagram and observe the measured values on the display. Place the sensor in different parts of the room - for example, by the door, by the window, in the shade or near the heater. Record the temperatures and compare where it is warmer and where it is colder. What differences did you measure?

Task 2: Recording temperature change over time

Place the sensor in a quiet place and record the temperature every 10 minutes for an hour. Watch how the temperature changes over time.

  • Have there been any changes? If so, what could have caused them?
  • How quickly does the environment heat up or cool down?
  • Try to graphically represent the course of temperature changes.

Task 3: Comparing the temperature of different objects

Use the sensor to measure the surface temperature of various materials – e.g. a metal spoon, a plastic cup, a wooden cutting board or your hand.

  • Which material is the warmest and which is the coldest?
  • Measure items after warming in the sun or cooling in the refrigerator.
  • How long does it take for an object to warm back to room temperature?