Communica

How to Connect Temperature Sensors to Microcontrollers: A Practical South African Guide

A practical guide to wiring and interfacing temperature sensors (analog, digital, 1-wire, I2C) with microcontrollers. SA buying tips, wiring diagrams, and troubleshooting included.

sensors and semiconductors
March 15, 2026
4 min read

Sensor Types & Compatibility

See which sensors work with Arduino, ESP32, Raspberry Pi, and more.

Wiring & Reading Data

Understand typical connections and code examples for digital and analog sensors.

Local Stock & Application Tips

Check sensor availability, brands, and local use cases at Communica branches.

Overview: Temperature Sensors for Microcontrollers

Temperature measurement is a core task in electronics labs, smart homes, and industrial automation. Whether monitoring ambient conditions in a greenhouse with Arduino, automating HVAC controls with ESP32, or logging fridge performance on a Raspberry Pi, connecting the right temperature sensor to your microcontroller is crucial for reliable results.

Did you know? Local labs and makers in South Africa regularly choose sensors like the DS18B20, LM35, and DHT22 for education and prototyping due to their robust documentation, easy code libraries, and readily available stock at distributors like Communica.

Types of Temperature Sensors & Microcontroller Compatibility

Popular sensor families differ by output type, accuracy, and interface. Here's a summary of the most common choices in South Africa, with reference models widely supported by Arduino and other boards:

Sensor Type Example Models Signal/Interface Typical Accuracy Common Use Cases
Analog IC LM35, TMP36 Analog voltage (mV/ degreesC) 0.5 degreesC Arduino basics, education
Digital 1-Wire DS18B20 1-Wire digital 0.5 degreesC Industrial, waterproof probes
Digital (I2C/SPI) MCP9808, TMP102 I2C/SPI digital 0.25 degreesC Precision logging, dataloggers
Thermistors (NTC/PTC) 10k NTC, 100k NTC Analog voltage divider Varies (calibration needed) 3D printers, basic temp sensing
Digital (Humidity Combo) DHT22, DHT11 Single-wire digital 0.5 degreesC to 2 degreesC Home automation, classrooms

Most Arduino-compatible, ESP32 and Raspberry Pi boards in South Africa's hobby, education, and process sectors support all of the above via analog or digital pins and standard libraries.

Typical Wiring Diagrams

Analog Sensor (LM35/TMP36 -> Arduino)

[Vcc] ----[LM35]---- [GND]
          |
        [Vout]----[A0]
  • Vcc (5V or 3.3V, as per IC spec)
  • GND to common ground
  • Output (Vout) to analog pin (A0/A1, etc.)

Reading the output is as simple as calling Arduino's analogRead(). For TMP36, you need to subtract a voltage offset for accurate Celsius readings:

Formula (TMP36): Temperature ( degreesC) = [(Vout in mV) - 500] / 10

1-Wire Digital Sensor (DS18B20)

[3.3V/5V]---[DS18B20]---[GND]
              |
           [DQ]---------[Digital pin]
                     |
               [4.7kOhm pull-up to Vcc]

The 1-Wire interface requires a pull-up resistor (4.7kOhm, available in resistor kits at Communica) between the data line (DQ) and Vcc. Libraries like DallasTemperature (Arduino) simplify code setup.

South African Availability & Popular Brands

At Communica branches and online, you'll find:

  • DS18B20 (Maxim Integrated) - waterproof, TO-92, and cable styles
  • Analog ICs (TI, STMicro, Microchip LM35/TMP36)
  • DHT11/DHT22 modules (Aosong, generic brands)
  • Thermistors - 10k/100k NTC types for 3D printers, incubators, appliances
  • MCP9808, TMP102 (I2C digital sensors) for Raspberry Pi/ESP32

Check category stock and pick up at Samrand, Cape Town, or Pretoria. VAT invoices and local support help with project rollouts in educational labs and engineering teams.

Related Sensors & Semiconductors Products

Discover quality sensors & semiconductors products related to How to Connect Temperature Sensors to Microcontrollers: A Practical South African Guide

Raspberry Pi 3b+ - Development Board 1.4ghz 1gb Ram, Hdmi, Bluetooth 4.2, Usb 2.0

Raspberry Pi 3b+ - Development Board 1.4ghz 1gb Ram, Hdmi, Bluetooth 4.2, Usb 2.0

RaspberryDevelopment / Microcontroller Boards
ZAR977.50

Raspberry Pi 3b+ - Development Board 1.4ghz 1gb Ram, Hdmi, Bluetooth 4.2, Usb 2.0

Communica South Africa Bdd Nano Ch340 Usb Type-c

Communica South Africa Bdd Nano Ch340 Usb Type-c

CommunicaDevelopment / Microcontroller Boards
ZAR94.00

Communica South Africa Bdd Nano Ch340 Usb Type-c

Communica South Africa Bdd Uno Rev3 Ch340

Communica South Africa Bdd Uno Rev3 Ch340

CommunicaDevelopment / Microcontroller Boards
ZAR125.01

Communica South Africa Bdd Uno Rev3 Ch340

Raspberry Raspberry Pi Pico Development / Microcontroller Boards

Raspberry Raspberry Pi Pico Development / Microcontroller Boards

RaspberryDevelopment / Microcontroller Boards
ZAR120.75

Raspberry Raspberry Pi Pico Development / Microcontroller Boards

Raspberry Raspberry Pi 4b 4gb Kit Development / Microcontroller Boards

Raspberry Raspberry Pi 4b 4gb Kit Development / Microcontroller Boards

RaspberryDevelopment / Microcontroller Boards
ZAR1920.50

Raspberry Raspberry Pi 4b 4gb Kit Development / Microcontroller Boards

Waveshare R7fa4 Plus A Development Board, Based On R7fa4m1ab3cfm, Compatible With Arduino Uno R4 Minima

Waveshare R7fa4 Plus A Development Board, Based On R7fa4m1ab3cfm, Compatible With Arduino Uno R4 Minima

WaveshareDevelopment / Microcontroller Boards
ZAR333.99

Waveshare R7fa4 Plus A Development Board, Based On R7fa4m1ab3cfm, Compatible With Arduino Uno R4 Minima

Waveshare Wvs Luckfox Pico Linux Dev Board Development / Microcontroller Boards

Waveshare Wvs Luckfox Pico Linux Dev Board Development / Microcontroller Boards

WaveshareDevelopment / Microcontroller Boards
ZAR194.01

Waveshare Wvs Luckfox Pico Linux Dev Board Development / Microcontroller Boards

Waveshare Luckfox Pico Max Rv1106 Linux Micro Development Board, Integrates Arm Cortex-a7/risc-v Mcu/npu/isp Processors

Waveshare Luckfox Pico Max Rv1106 Linux Micro Development Board, Integrates Arm Cortex-a7/risc-v Mcu/npu/isp Processors

WaveshareDevelopment / Microcontroller Boards
ZAR430.00

Waveshare Luckfox Pico Max Rv1106 Linux Micro Development Board, Integrates Arm Cortex-a7/risc-v Mcu/npu/isp Processors

Raspberry Pi 5b 8gb Sp-kit Development Board 2.4ghz 8gb Ram Sp Kit- Includes: Psu 5.1a 5a 27w Usb-c - 1m Micro Hdmi Cable - 32gb Preloaded Micro Sd Ca

Raspberry Pi 5b 8gb Sp-kit Development Board 2.4ghz 8gb Ram Sp Kit- Includes: Psu 5.1a 5a 27w Usb-c - 1m Micro Hdmi Cable - 32gb Preloaded Micro Sd Ca

RaspberryDevelopment / Microcontroller Boards
ZAR2869.25

Raspberry Pi 5b 8gb Sp-kit Development Board 2.4ghz 8gb Ram Sp Kit- Includes: Psu 5.1a 5a 27w Usb-c - 1m Micro Hdmi Cable - 32gb Preloaded Micro Sd Ca

Raspberry Pi 5b 16gb Development Board 2.4ghz 16gb Ram, Sd Card Socket, 2×micro Hdmi Ports(up To 4kp60 Supported), 2×usb3.0 Ports, 2×usb2.0 Ports

Raspberry Pi 5b 16gb Development Board 2.4ghz 16gb Ram, Sd Card Socket, 2×micro Hdmi Ports(up To 4kp60 Supported), 2×usb3.0 Ports, 2×usb2.0 Ports

RaspberryDevelopment / Microcontroller Boards
ZAR3180.00

Raspberry Pi 5b 16gb Development Board 2.4ghz 16gb Ram, Sd Card Socket, 2×micro Hdmi Ports(up To 4kp60 Supported), 2×usb3.0 Ports, 2×usb2.0 Ports

Arduino Arduino Mkr Wan 1310 Board Development / Microcontroller Boards

Arduino Arduino Mkr Wan 1310 Board Development / Microcontroller Boards

ArduinoDevelopment / Microcontroller Boards
ZAR1075.00

Arduino Arduino Mkr Wan 1310 Board Development / Microcontroller Boards

Communica Bbc Micro:bit V2.2 Go Development / Microcontroller Boards

Communica Bbc Micro:bit V2.2 Go Development / Microcontroller Boards

CommunicaDevelopment / Microcontroller Boards
ZAR437.00

Communica Bbc Micro:bit V2.2 Go Development / Microcontroller Boards

How to Choose the Right Sensor

  • For basic room/ambient monitoring or student demos: DHT22 or DS18B20 (digital, easy-code, available as modules).
  • For precision: MCP9808, TMP102 (I2C interface, sensor breakout boards available).
  • For budget builds: LM35 or thermistor (requires calibration, analog pin input).
  • For outdoor or high-moisture use: Waterproof-cable style DS18B20 or dedicated IP-rated enclosures.

Lead times are typically 1-3 days if in branch stock; allow 7-10 days for larger education or industrial orders. Always confirm local availability if you're sourcing for time-sensitive builds.

Reading Sensor Values: Example Code (Arduino)

LM35 Analog Example

int sensorPin = A0;
int sensorValue = analogRead(sensorPin);
float voltage = sensorValue * (5.0 / 1023.0);
float tempC = voltage * 100;  // For LM35: 10mV/ degreesC

DS18B20 1-Wire Example (with DallasTemperature.h)

#include 
#include 

#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
  sensors.begin();
}

void loop() {
  sensors.requestTemperatures();
  float tempC = sensors.getTempCByIndex(0);
}

Raspberry Pi, ESP32, and STM32 code examples are available via Python (Adafruit_CircuitPython libraries) and ESP-IDF. South African user groups often share example repositories adapted for local projects-search for ready-made code using sensor part numbers.

Troubleshooting & Common Issues

  • No reading? Double-check wiring and power supply voltages.
  • Fluctuations or 'nan' value: Missing pull-up resistor (digital types) or excessive cable length. Try shielded cables or lower baud rates for reliability.
  • Incorrect temperature: Revisit math, calibration constants, and code decimal conversions. Use a reference thermometer for spot checks in South African lab environments.
  • Intermittent results: Check breadboard/connector quality. Consider soldered headers and clean contact surfaces if deploying in SA schools or industrial plants.

Application Examples in South Africa

  • IoT weather stations at schools using DS18B20 for outdoor temperature logging
  • Home automation with DHT22 on NodeMCU or ESP32 for thermostat control
  • Incubator projects with NTC thermistors and microcontrollers in biology and agricultural colleges
  • Process control test rigs using MCP9808/TMP102 sensors on industrial microcontroller boards

Explore sensor, microcontroller, and accessory categories at Communica to complete your build-refer to branch collection and stock availability to avoid project delays.

Sources

Communica Samrand — Electronic Component Experts

Communica supplies semiconductors and electronic components to industries such as automotive, electrical, automation, mining, and education.

Last updated: March 15, 2026

Disclaimer: This content is for educational purposes only. Product availability, pricing, and specifications are subject to change. Always verify current details on the retailer's website before making a purchase. We may earn affiliate commissions from qualifying purchases.

Frequently Asked Questions

Get answers to common questions about Sensors And Semiconductors

Why Choose Communica?

*Free Shipping

Free shipping for orders over ZAR 1,000.00.

7-Day Returns

Get a full refund if you had the product for less than 7 days.

Quick Delivery

Nationwide delivery within 2 - 4 working days.