Part 1
요약·해설
Built-in node, board overlay, Arduino Serial 연결과 driver log를 모두 설명합니다.
1-Wire
Polling
Arduino Serial
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
A28CE929BCFD6ABBBF6FE395313FE8E260B2C52EB6291C3311E9F01339FEA90B
.. _ds18b20_sample:
DS18B20 1-Wire Temperature Sensor
#################################
Overview
********
This sample shows how to use the Zephyr :ref:`sensor` API driver for the
`Maxim DS18B20`_ temperature sensor.
.. _Maxim DS18B20:
https://www.maximintegrated.com/en/products/sensors/DS18B20.html
The sample periodically reads temperature data from the
first available DS18B20 device discovered in the system. The sample checks the
sensor in polling mode (without interrupt trigger).
Building and Running
********************
The devicetree must have an enabled node with ``compatible = "maxim,ds18b20";``.
See below for examples and common configurations.
If the sensor is not built into your board, start by wiring the sensor pins
as shown in the Figure Hardware Configuration of the `DS18B20 datasheet`_ at
page 10.
.. _DS18B20 datasheet:
https://datasheets.maximintegrated.com/en/ds/DS18B20.pdf
Boards with a built-in DS18B20 or a board-specific overlay
==========================================================
Your board may have a DS18B20 node configured in its devicetree by default,
or a board specific overlay file with an DS18B20 node is available.
Make sure this node has ``status = "okay";``, then build and run with:
.. zephyr-app-commands::
:zephyr-app: samples/sensor/ds18b20
:goals: build flash
:board: nucleo_g0b1re
DS18B20 via Arduino Serial pins
===============================
Make sure that you have an external circuit to provide an open-drain interface
for the 1-Wire bus.
Once you have wired the sensor and the serial peripheral on the Arduino header
to the 1-Wire bus, build and flash with:
.. zephyr-app-commands::
:zephyr-app: samples/sensor/ds18b20
:goals: build flash
:gen-args: -DDTC_OVERLAY_FILE=arduino_serial.overlay
The devicetree overlay :zephyr_file:`samples/sensor/ds18b20/arduino_serial.overlay`
should work on any board with a properly configured Arduino pin-compatible Serial
peripheral.
Sample Output
=============
The sample prints output to the serial console. DS18B20 device driver messages
are also logged. Refer to your board's documentation for information on
connecting to its serial console.
Here is example output for the default application settings, assuming that only
one DS18B20 sensor is connected to the standard Arduino Serial pins:
.. code-block:: none
*** Booting Zephyr OS build zephyr-v2.6.0-1929-gf7abe4a6689e ***
Found device "DS18B20", getting sensor data
[00:00:00.000,039] <dbg> w1_serial: w1_serial_init: w1-serial initialized, with 1 devices
[00:00:00.015,140] <dbg> DS18B20: ds18b20_init: Using external power supply: 1
[00:00:00.021,213] <dbg> DS18B20: ds18b20_init: Init DS18B20: ROM=28b1bb3f070000b9
Temp: 25.040000
Temp: 25.030000
Part 3
한국어 전문 번역
개요
이 sample은 Zephyr sensor API driver로 Maxim DS18B20 temperature sensor를 사용하는 방법을 보여 줍니다.
System에서 발견한 첫 번째 available DS18B20 device의 temperature data를 주기적으로 읽습니다. Interrupt trigger가 없는 polling mode로 sensor를 확인합니다.
빌드 및 실행
Devicetree에는 compatible = "maxim,ds18b20";인 활성 node가 있어야 합니다. Sensor가 board에 내장되어 있지 않다면 DS18B20 datasheet 10쪽의 Hardware Configuration figure에 따라 pin을 배선합니다.
DS18B20 내장 board 또는 board 전용 overlay
Board Devicetree에 DS18B20 node가 기본 구성되어 있거나 DS18B20 node를 포함한 board 전용 overlay가 제공될 수 있습니다. Node의 status = "okay";를 확인하고 다음처럼 build하고 실행합니다.
# From the root of the zephyr repository
west build -b nucleo_g0b1re samples/sensor/ds18b20
west flash
Arduino Serial pin을 통한 DS18B20
1-Wire bus에 open-drain interface를 제공하는 외부 circuit이 있는지 확인합니다. Sensor와 Arduino header의 serial peripheral을 1-Wire bus에 배선한 뒤 build하고 flash합니다. 아래 공식 렌더링의 -b None 자리에는 실제 board 이름을 지정해야 합니다.
# From the root of the zephyr repository
west build -b None samples/sensor/ds18b20 -- -DDTC_OVERLAY_FILE=arduino_serial.overlay
west flash
samples/sensor/ds18b20/arduino_serial.overlay Devicetree overlay는 Arduino pin과 호환되는 Serial peripheral이 올바르게 구성된 모든 board에서 동작해야 합니다.
출력 예
Sample은 serial console에 출력하며 DS18B20 driver message도 log로 남깁니다. 아래는 standard Arduino Serial pin에 DS18B20 sensor 하나만 연결한 default application 출력입니다.
*** Booting Zephyr OS build zephyr-v2.6.0-1929-gf7abe4a6689e ***
Found device "DS18B20", getting sensor data
[00:00:00.000,039] <dbg> w1_serial: w1_serial_init: w1-serial initialized, with 1 devices
[00:00:00.015,140] <dbg> DS18B20: ds18b20_init: Using external power supply: 1
[00:00:00.021,213] <dbg> DS18B20: ds18b20_init: Init DS18B20: ROM=28b1bb3f070000b9
Temp: 25.040000
Temp: 25.030000
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.