Labs / Electronic modules

GraftSense - a digital temperature sensor module based on MY18E20 (open version)

Author: Li Zisheng · Source: FreakStudio open documentation, v1.1 · License: CC BY 4.0 · Driver code (sensors/my18e20_driver): MIT License

Contents
MY18E20
MY18E20 LED1 R2 C2 U2 C3 U1 R1 C1 C5

I. Module Introduction

Digital temperature sensor module based on MY18E20, which adopts the MY18E20 digital temperature sensor solution from Minsensor, can directly output ambient temperature data and is compatible with DS18B20; the module is equipped with an LDO voltage regulator circuit, power filter and indicator circuit, powered by 3.3V and communicates with the main controller via the 1-Wire protocol, supports multi-chip networking, achieves ±0.5℃ accuracy measurement in the range of -10℃ to + 85℃, features low power consumption, and is suitable for multi-point temperature measurement, temperature monitoring and low-power device scenarios.

II. Introduction to Main Chips

MY18E20 is a single-bus digital temperature sensor chip launched by Minya Sensing, TO‑92 packaged, powered by 1.8~5.5V, with a temperature measurement range of -55℃~+ 125℃, an accuracy of ±0.5℃ within -10℃~+ 85℃, a default 12-bit ADC (configurable to 14 bits), low power consumption, and a built-in unique 64-bit ID and 80-bit EEPROM.

2.1 Chip Overview

MY18E20 MY1820 MY18B20Z MY18B20L 0.5 0.25 12bit 14bit 1.8 5.5V

MY18E20 is a single-bus digital temperature sensor chip from Minsensor, featuring a temperature measurement range of -55℃ to + 125℃, an accuracy of ±0.5℃ within -10℃ to + 85℃, a default 12-bit ADC (configurable to 14 bits), low power consumption, multi-point networking support, and compatibility with TO-92 packages. It is widely used in scenarios such as industrial monitoring and smart homes.

2.2 Pin Definition

MY18E20 TO-92 1 2 3 2.2

MY18E20 (TO-92 package) is a 3-pin device: Pin 1 GND is connected to ground, Pin 2 DQ serves as a 1-Wire digital interface (bidirectional I / O), and Pin 3 VDD is connected to the power supply.

2.3 Functional Block Diagram

MY18E20 64 10 2 8

MY18E20 integrates built-in power management, a 1-Wire interface, digital control logic, a temperature sensor and an analog-to-digital conversion module; it is equipped with an EEPROM containing a unique 64-bit ROM ID, and a scratchpad, communicates via the 1-Wire DQ pin with external pull-up, and supports multi-node networking, user data storage and temperature alarm configuration.

2.4 Performance Parameters

11.1 11.2 11.3 MY18E20
MY18E20 55 125 1.8V 5.5V 40ms

MY18E20 has the following electrical parameters: its power supply voltage ranges from 1.8V to 5.5V, the temperature measurement range is -55°C to + 125°C, the typical accuracy is ±0.5°C, and the limit voltage and temperature range of its pins are also specified; the maximum write cycle of the non-volatile memory is 40ms.

MY18E20 15ms 100ms 500ms 1

MY18E20 features an E²PROM with a erase/write endurance of no less than 50,000 cycles and a data retention period of at least 10 years; in terms of AC characteristics, its temperature conversion time ranges from 15ms to 500ms (configurable), and the key timing parameters required for 1-Wire communication such as reset, read and write are also specified.

2.5 Reference Circuit

MY18E20 1.8V 5.5V 10k
MY18E20 1 3.3V 2 1K 3 5V 100 500

MY18E20 a typical application circuit of the digital temperature sensor. The MCU shares the 1.8V~5.5V power supply and ground with the sensor, and communicates via the single-bus DQ pin;the DQ line is pulled up by a 10kΩ pull-up resistor to implement the standard single-bus protocol, and the MCU sends commands and reads temperature data through this pin.

2.6 Chip Configuration

None.

MY18E20 4.7k 480 100

MY18E20 in terms of its 1-Wire hardware configuration, the DQ pin features an internal open-drain structure, which requires an external pull-up resistor of approximately 4.7kΩ to maintain a high level when the bus is idle; the host connects to the bus via an open-drain / tri-state port to enable multi-device shared communication. If the bus is pulled low for more than 480μs, all devices will be reset.

MY18E20 1

MY18E20 follows the "Initialization → ROM Command → Function Command" sequence for 1-Wire access. The initialization process consists of a master reset pulse and a slave presence pulse;ROM commands (such as Read ROM, Match ROM) implement addressing based on the device's unique 64-bit ID, supporting single-point/multi-point networking and alarm device query.

MY18E20

MY18E20 single-bus instructions include:

  1. ROM Command: Skip ROM (CCh) can address all devices on the bus simultaneously, while Alarm Search (ECh) only responds to devices that meet the alarm conditions.
  2. Function Commands: Convert T (44h) starts temperature conversion;Write Scratchpad (4Eh) writes data to the TH/TL and configuration registers;Read Scratchpad (BEh) reads scratchpad data to implement core functions including temperature reading and alarm configuration.
MY18E20 44h B8h 4Eh 48h B4h

MY18E20 has a 1-Wire function instruction set, which includes instructions such as temperature conversion, scratchpad read/write, E²PROM backup and restore, and power supply mode query. Each instruction defines the specific function, opcode and bus interaction mode, and the host can implement temperature reading, configuration saving and status detection through these instructions.

MY18E20 1 15us 1us

MY18E20 has a 1-Wire bus timing that consists of three types of signals: initialization, write time slot and read time slot. For initialization, the host needs to pull down the bus for no less than 480μs to perform a reset, then release the bus and wait for 15-60μs; the device will subsequently pull down the bus for 60-240μs to send a presence pulse. A write time slot (writing 0 / writing 1) is initiated by the host pulling down the bus, which lasts for no less than 60μs with an interval of no less than 1μs, and the device samples within 15-60μs after the bus is pulled down;For a read time slot, the host pulls the bus low for ≥1 μs and then releases it; the device outputs data within 15 μs after the bus is pulled low, and the host must sample within this window. All time slots must strictly comply with the timing requirements to ensure reliable communication.

MY18E20 480 15 60 240 1
MY18E20 1 10.6-3 15 10.6-4 0
MY18E20 0 60 1 480 15
MY18E20 1 2 9

2.8 PCB Routing Notes

None.

III. Circuit Engineering

3.1 Circuit Source Engineering

To obtain the source code of the circuit, please follow the official account [Freak Embedded]

3.2 Module Usage Instructions

The schematic diagram of this module is shown below:

SCH_Schematic1_Digital Temperature Sensor Module Based on MY18E20_v1.0.0_2026-05-12.pdf 2.3 MB

MY18E20 LED1 R2 C2 U2 C3 U1 R1 C1 C5

This module provides a single-bus (1-Wire) communication interface DAT: compatible with the DS18B20 protocol, supports standard single-bus multi-point networking, and can stably transmit the digital temperature data collected by MY18E20, achieving ±0.5°C accuracy measurement in the range of -10°C to + 85°C. It is suitable for scenarios such as multi-point temperature measurement, temperature monitoring and low-power equipment, and provides the system with reliable single-bus temperature sensing data interaction capability.

3.3 Application Experiment

Here, we use the GraftPort-RP2040 development board for testing, and the MY18E20-based digital temperature sensor module uses the DIO interface to communicate with the main controller.

Here, we first use the HY2.0-4P connection cable to connect the module to the GraftPort-RP2040 development board's DIO0 interface:

MY18E20 GraftPort-RP2040 HY2.0-4P DIO0 6 7

The module connections are shown in the following table:

Development Board Pins

Module Pins

Description

Pin 6

DOUT

1-Wire communication pin

Pin 7

NC

-

Here, we need to search for the relevant driver packages on uPyPI: https://upypi.net/zh/

106 my18e20_driver

Enter my18e20_driver to search, and the following will be displayed:

my18e20_driver 1.2.0 MY18E20/DS18B20

Click to copy the local installation command:

my18e20_driver MY18E20/DS18B20 CRC-8 1.0.0 MY18E20

Import the module driver library code via the mip tool. Below are the usage commands for the mpremote tool:

mpremote mip install https://upypi.net/pkgs/my18e20_driver/1.0.0

Import the MicroPython driver code for the MY18E20-based digital temperature sensor module, then copy the following main.py code into our project:

# Python env   : MicroPython v1.23.0
# -*- coding: utf-8 -*-
# @Time    : 2024/7/22 15:01
# @Author  : Li Qingshui
# @File    : main.py
# @Description : Code for testing the MY18E20 temperature sensor driver class
# @License : MIT

# ======================================== Import Modules =========================================

# Import hardware-related modules
from machine import Pin

# Import time-related modules
import time

# Import modules for single-bus communication
from onewire import OneWire

# Import the temperature sensor class
from my18e20 import MY18E20

# ======================================== Global Variables ============================================

# Print interval (ms)
PRINT_INTERVAL_MS = 500

# ======================================== Functions ============================================

# ======================================== Custom Classes ============================================

# ======================================== Initialization ==========================================

# Wait for the device to power up and stabilize
time.sleep(3)
print("FreakStudio: Using MY18E20 OneWire temperature sensor ...")

# Initialize the 1-Wire pin and sensor object
ow_pin = OneWire(Pin(6))
sensor = MY18E20(ow_pin)

# Scan the bus for devices and get the list of ROM addresses
roms_list = sensor.scan()
# Print the ROM addresses of all devices
for rom in roms_list:
    print("Detected sensor ROM ID: %s" % str(rom))

# Start the first temperature conversion
sensor.convert_temp()

# ========================================  Main Program  ===========================================

try:
    while True:
        # Wait for the conversion to finish (up to 750 ms at 12-bit resolution)
        time.sleep_ms(PRINT_INTERVAL_MS)
        # Read and print the temperature of each sensor
        for rom in roms_list:
            temp = sensor.read_temp(rom)
            print("Sensor %s temperature: %s C" % (str(rom), str(temp)))
        # Start the next temperature conversion
        sensor.convert_temp()

except KeyboardInterrupt:
    print("Program interrupted by user")
except OSError as e:
    print("Hardware communication error: %s" % str(e))
except Exception as e:
    print("Unknown error: %s" % str(e))
finally:
    print("Cleaning up resources...")
    del sensor
    del ow_pin
    print("Program exited")

Burn the code, open the terminal, and the output is as follows:

MY18E20 26.625 26.875 x14 x86 x00 x03

The MY18E20 single-bus temperature sensor has completed normal initialization, the ROM ID has been successfully identified, and it can stably output temperature data with readings fluctuating slightly within the range of 26.625°C to 26.875°C, featuring a stable operating status.

IV. Drivers

my18e20_driver-1.0.0.zip 14 KB

None.

6. Revision History

Document Version

Date of Revision

Modifier

Modified Content

v1.0

2026-05-12

Ling Gaoxing

Initialize the document

v1.1

2026-06-05

Xin Ruili

Create an open version of the document, based on the internal document version v1.1.

VII. Relevant Materials

7.1 Chip Datasheet

MY18E20.pdf 1.8 MB

7.2 Unique Icons for PCB Silk Screen

7.2