Pico precision NTC thermometer
Build it step by step
0 of 7 doneWire the converter
VDD to 3V3(OUT), GND to GND, SDA to GP0, SCL to GP1, ADDR to GND.
Build the divider
10 kilo-ohm from 3V3(OUT) to A0, thermistor from A0 to GND.
Reference the supply
A1 to the 3V3(OUT) rail.
Wire the OLED
3V3(OUT), GND, SDA, SCL on the same bus.
Install the ssd1306 module
Using Thonny packages.
Run the program
The temperature appears.
Pinch the thermistor
The temperature rises.
How do you build a pico precision NTC thermometer?
A Pico reads a 10 kilo-ohm NTC thermistor through an ADS1115 16-bit converter and shows a temperature to one decimal place on an OLED. You need Raspberry Pi Pico H, ADS1115 16-bit ADC module, NTC thermistor 10 kΩ (B3950), Resistor 10 kΩ, SSD1306 OLED Display and Breadboard 830 Tie Points. It takes 7 steps and about 160 minutes.
- Level
- Intermediate
- Time
- About 160 min
- Parts
- 6
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| ADS1115 VDD and OLED VCC | Pico 3V3(OUT) pin 36 | Power at 3.3 V |
| ADS1115 GND and OLED GND | Pico GND pin 38 | Common ground |
| ADS1115 SDA and OLED SDA | Pico GP0 pin 1 | Shared I2C data |
| ADS1115 SCL and OLED SCL | Pico GP1 pin 2 | Shared I2C clock |
| ADS1115 ADDR | Pico GND | Sets the address 0x48 |
| 10 kilo-ohm resistor | 3V3(OUT) rail to ADS1115 A0 | Top of the divider |
| NTC thermistor | ADS1115 A0 to GND | Bottom of the divider |
| ADS1115 A1 | 3V3(OUT) rail | Reference of the actual supply voltage |
Code
A thermistor is a resistor whose resistance falls as it warms. A 10 kilo-ohm NTC has exactly that resistance at 25 degrees and about 3.5 kilo-ohms at 45. To measure it you put it in a voltage divider with a fixed resistor and measure the voltage in the middle. The ADS1115 is a 16-bit converter, much finer than the Pico's own, and it has a built-in amplifier. A neat trick here is to read two channels: A0 gives the divider voltage and A1 reads the supply rail itself, so the ratio of the two gives the divider ratio without depending on the exact supply voltage. From the ratio the program works out the thermistor's resistance, and the beta equation turns resistance into temperature. Beta is a number from the data sheet, 3950 for this part, and the equation is accurate to about half a degree around room temperature. The averaging of eight readings steadies the last digit. The fixed resistor's tolerance is the main remaining error.
import time
import math
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
oled = SSD1306_I2C(128, 64, i2c)
ADS = 0x48
R_FIXED = 10000.0
R0 = 10000.0 # thermistor resistance at 25 C
BETA = 3950.0
T0 = 298.15 # 25 C in kelvin
def read_channel(config_high):
i2c.writeto(ADS, bytes([0x01, config_high, 0x83])) # single shot, 128 samples a second, +-4.096 V
time.sleep_ms(10)
data = i2c.readfrom_mem(ADS, 0x00, 2)
raw = (data[0] << 8) | data[1]
if raw & 0x8000:
raw -= 65536
return raw * 4.096 / 32768
def temperature():
v0 = 0.0
v1 = 0.0
for _ in range(8):
v0 += read_channel(0xC3) # A0 against ground
v1 += read_channel(0xD3) # A1 against ground, the supply voltage
ratio = v0 / v1 # the ratio does not depend on the exact 3.3 V
r_ntc = R_FIXED * ratio / (1 - ratio)
inv_t = 1 / T0 + math.log(r_ntc / R0) / BETA
return 1 / inv_t - 273.15
while True:
t = temperature()
oled.fill(0)
oled.text("NTC thermometer", 0, 0)
oled.text("%.1f C" % t, 0, 24)
oled.show()
time.sleep_ms(500)Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Room air | About room temperature |
| Pinch the thermistor | Rises by several degrees |
| Blow on it | Falls a little |
| Warm water, in a plastic bag | Reads the water temperature |
| Ice water, in a bag | Close to 0 degrees |
If it does not work
Reads nonsense
Check the divider is wired with the thermistor on the ground side.
OSError on the converter
Check the address 0x48 and the I2C wires.
Reads high or low by a few degrees
Check the fixed resistor value, and the thermistor's beta number.
Reading jumps
Keep the wires short and the thermistor still.
Display blank
Check the OLED address 0x3C.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the pico precision NTC thermometer?
Raspberry Pi Pico H, ADS1115 16-bit ADC module, NTC thermistor 10 kΩ (B3950), Resistor 10 kΩ, SSD1306 OLED Display and Breadboard 830 Tie Points.
How long does the pico precision NTC thermometer take to build?
About 160 minutes for a intermediate maker, in 7 steps.
How do I know the pico precision NTC thermometer works?
Room air: About room temperature. Pinch the thermistor: Rises by several degrees. Blow on it: Falls a little.
Reads nonsense: what should I check?
Check the divider is wired with the thermistor on the ground side.
OSError on the converter: what should I check?
Check the address 0x48 and the I2C wires.
Reads high or low by a few degrees: what should I check?
Check the fixed resistor value, and the thermistor's beta number.
Reading jumps: what should I check?
Keep the wires short and the thermistor still.
