Choosing a temperature module for a small device: follow the connector, bus and reading

You may already have a temperature number working on a development board and still be unsure which module belongs in the smaller device. A different connector, data bus or measurement sequence changes the integration work, even when both parts are called digital temperature sensors.

There is also the question of what temperature the device should report. A thermostat builder's write-up on r/PrintedCircuitBoard describes separating a sensor from heat generated elsewhere on the board. It is an example of a packaging problem, not evidence about either module below. For this decision, first choose the physical thing you want to measure: room air, a surface, or part of the device itself.

On our bench we connected two GraftSense temperature modules to a Raspberry Pi Pico (RP2040) on a GraftPort carrier: a T117B on I2C and an MY18E20 on OneWire. Both returned data. They were independent runs, not a head-to-head accuracy comparison.

T117B: follow two signal lines to an address

The T117B module's connector is labeled GND, VCC, SDA and SCL. SDA and SCL are the I2C data and clock lines. We assigned them to GPIO4 and GPIO5, configured a 400 kHz bus and scanned for devices before reading:

from machine import I2C, Pin

i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=400000)
print([hex(a) for a in i2c.scan()])

The scan found 0x40. We then used our T117B driver, whose package and module names differ (t117b_driver and t117b), to read temperature and status. Record both names in your notes; the next person will search for one and import the other.

The full program also exercised the configuration and alert settings, and deliberately passed invalid arguments to check that the driver raised errors. The ValueError lines in the log come from those intentional checks. They are useful software tests. They do not mean the sensor was exposed to the extreme temperatures used as threshold arguments.

The run reported roughly 29.91 to 30.58 °C. The alert bits stayed at zero throughout, including while the displayed temperature was above the high threshold shown in the log. So this record establishes returned temperatures and argument checks, and it leaves the alert behavior to investigate. If your product relies on the hardware alert, for example to wake the controller or cut a heater, test that path on its own before depending on it.

MY18E20: discover a device, then start a conversion

The MY18E20 module's connector is labeled GND, VCC, NC and DAT: DAT is the data line and NC means no connection. The board outline looks similar to the T117B's, but the modules are not pin-for-pin interchangeable. A connector that fits is not a connector that is wired the same way.

We created a OneWire bus on GPIO6. A OneWire scan returns device identifiers, and the following reads use an identifier to select the sensor that was found:

from machine import Pin
from onewire import OneWire

bus = OneWire(Pin(6))
print(bus.scan())

With our MY18E20 driver, the program then requests a temperature conversion and reads the result after a wait. The conversion has to finish before the read. Our example waited 500 ms; check the conversion time for the resolution you use against the device's specification before you pick a delay for another build. Too short a wait can return a stale or default value that looks plausible.

The run reported the sensor's identifier and temperatures around 26.6 to 26.9 °C. The difference from the T117B run says nothing about which sensor is more accurate: the two runs did not share conditions or a calibrated reference.

Choose the module together with its place in the device

The two runs show what should accompany a component choice: labeled connections, the matching driver, device discovery and the measurement sequence. Keep those details when moving from development-board wiring to a smaller assembly. The bus choice also affects the board: I2C needs two lines and an address that does not clash with other parts, while OneWire needs one line and the identifier handling and conversion timing shown above.

Then return to the measurement target. For room air, consider the sensor's access to outside air and its distance from internal heat sources such as the regulator, processor or display. For a component or a surface, the physical contact and the mounting become part of the experiment.

Before committing to more units, resolve the behavior the product actually uses. In these runs that means the T117B alert path, if the product needs it, and the MY18E20 conversion timing. The choice is clearer when it rests on a demonstrated connection and an intended measurement location rather than on a temperature value alone.