Hobby Lab 趣味のモノ作り実験のサイトです。
Software 開発環境 Arduino Library 使い方OneWire
1.OneWire myWire(pin);
2.myWire.search(addrArray);
3.myWire.reset_search();
4.myWire.reset();
5.myWire.select(addrArray);
6.myWire.skip();
7.myWire.write(num);
8.myWire.write(num, 1);
9.myWire.read();
10.myWire.crc8(dataArray,length);

Pr:Prプロセッサ関係
PrP:プロセッサ
動作比較
 STM32F動作比較
 CH32V203&STM32F 動作比較
 arduino動作比較
raspberrypi関係
 RaspberryPiハード
CH32V関係
 -CH32V開始
 -203K8T6(32Pin)開始
 -203C8T6(48P)開始
 -003J4M6(8Pin)開始
 -003F4P6(20Pin)開始
 -Moun River StudioⅡ
 プログラミング!
  203_GPIO関係
  203_TIME関係
  203_TIME Encoder
  203_I2C関係
  203_1-Wire関係
  003_DS18B20テスター
  USART(UART)関係
  DS18B20をModBus制御
 -マニュアル
 203データシート
 203取説
  MBA メモリとバス方式
  PWR 電力制御
  RCC リセット・拡張・クロック
  BKP バックアップレジスタ
  CRC 巡回冗長検査
  RTC リアルタイムクロック
  GPIO GPIOと代替機能
  DMA ダイレクトメモリアクセス制御
  ADTM 高度な制御タイマー
  GPTM 汎用タイマー
  BCTM 基本タイマー
  USART 同期非同期通信
arduino関係
 ESP12関係
 (a)ESP-8266D1mini注意
PrP:その他  RS485ドライバー
 CP2102 BRIDGE
 WCH-LinkEエミュレーター

Sf:IDE 開発環境
SfI:STM32
 STM32CubeIDEでプログラム
 HALと直接レジスター操作の速度
SfI:CH32
 MounRiver Studioでプログラム
SfI:Arduino
各ボード毎の設定
 Uno 設定
 Mega2560 設定
 DUE_CH340 設定
 ESP_WROOM02 設定
 ESP12F_D1mini 設定
 ESP32 設定
 CH32V 設定
ライブラリー
 OneWire使い方
その他
 日本語リファレンス(外部リンク)
 WiFi Macアドレスを調査
Sf:OS関係
SfO:Mint 関係
 PCへMint導入
 アプリ導入
 その他1
 アイコンを作る
SfO:Ubuntu 関係
 PCへUbuntu導入
 アプリ導入
SfO:RaspberryPi 関係
はじめに
 RaspberryPiへOS導入
 アプリ導入
 Programming
シェル・コマンド関係
 LXTerminal
 sed
 i2ctools
I/O・アプリ関係
 RealVNCとViewer
 IO動作確認
 MySQL
 Python
 raspberrypiハード
Sf:Server 関係
SfS:レンタルサーバー
 CORE-X
SfS:Windowsサーバー
 XAMPPの概要と導入
 Note XAMPP
 Note XAMPP Err
 Note Apache
 Note PHP
 Note MyQSL
Sf:Programming関係
C 関係
 C言語でプログラムミング
Python 関係
はじめに
 RaspberryPi開始
 Windows開始
共通事項
 プログラミングNote
 パッケージ導入 pip
 標準ライブラリ
 Serialライブラリ
 SMBusライブラリ
HTML関係
 開始とNote
Sf:AP アプリ関係
SfA:エディタ
SfA:回路図CAD
SfA:回路シミュレータ
 シミュレーションの設定
 色の設定
 電源設定設定
SfA:リモートソフト
Sf:Pt プロトコル関係
SfPt:MODBUS
Sf:Otgers その他
OneWire.hはマキシム独自の1-Wireバスプロトコルインターフェースのライブラリーです。

詳細は https://www.arduino.cc/reference/en/libraries/onewire/ に掲載されている。

説明

1.OneWire myWire(pin);

Create the OneWire object, using a specific pin.
Even though you can connect many 1 wire devices to the same pin, if you have a large number, smaller groups each on their own pin can help isolate wiring problems.
You can create multiple OneWire objects, one for each pin.
特定のピンを使用して OneWire オブジェクトを作成します。
接続できるのに 多数の1 Wireデバイスを同じピンに接続(多数の場合は、より小さなグループ) それぞれが独自のピンにあるため、配線の問題を切り分けるのに役立ちます。
作成できます 複数の OneWire オブジェクト (各ピンに 1 つ)。


2.myWire.search(addrArray); (addr配列)

Search for the next device.
The addrArray is an 8 byte array.
If a device is found, addrArray is filled with the device's address and true is returned.
If no more devices are found, false is returned.
次のデバイスを検索します。
addrArray は 8 バイトの配列です。
デバイスが 見つかった場合、addrArray にデバイスのアドレスが入力され、true が返されます。
もし これ以上デバイスが見つからない場合は、false が返されます。

3.myWire.reset_search();

Begin a new search.
The next use of search will begin at the first device.
新しい検索を開始します。
次の検索の使用は、最初のデバイスから開始されます。

4.myWire.reset();


Reset the 1-wire bus. Usually this is needed before communicating with any device.
1-Wireバスをリセットします。通常、これはデバイスと通信する前に必要です。

5.myWire.select(addrArray); (addr配列)

Select a device based on its address.
After a reset, this is needed to choose which device you will use, and then all communication will be with that device, until another reset.
アドレスに基づいてデバイスを選択します。
リセット後、これは次の目的で必要です。 使用するデバイスを選択すると、すべての通信相手が そのデバイスは、別のリセットまで。

6.myWire.skip();

Skip the device selection.
This only works if you have a single device, but you can avoid searching and use this to immediatly access your device.
デバイスの選択をスキップします。
これは、デバイスが 1 つの場合にのみ機能しますが、 検索を回避し、これを使用してデバイスにすぐにアクセスできます。

7.myWire.write(num);


Write a byte.
バイトを書き込みます。

8.myWire.write(num, 1);

Write a byte, and leave power applied to the 1 wire bus.
バイトを書き込み、1線式バスに電源を印加したままにします。

9.myWire.read();

Read a byte.
バイトを読み取ります。

10.myWire.crc8(dataArray, length); (データ配列, 長さ)

Compute a CRC check on an array of data.
データの配列に対して CRC チェックを計算します。






































更新日 2025/11/25 19:39  管理者 平林 剛Hirabayashi Takeshi