嵌入式设备与 1-Wire 总线通信:TINI 应用指南
1. 1-Wire 设备通信示例
首先,来看一个读取温度传感器的示例代码:
// Read the temp sensor
myTherm.measureT();
// Display what we know (temoerature) in C and F
System.out.println(“The device ROM ID: “ + myTherm.ROM_ID);
System.out.println(“The measured temperature: “ + myTherm.degC
+ “ Deg C”+ “, or “ + myTherm.degF + “ Deg F”);
这个示例程序虽然没有利用 DS1920 温度 iButton 的所有功能,但展示了如何使用 OneWireContainer10 类与设备进行通信。以下是不同环境下的运行示例:
- Windows 系统 :
- C:\> java Thermometer
- 输出:
The device ROM ID: D40000004B996410
The measured temperature: 24.0 Deg C, or 75.2 Deg F
The device ROM ID: 700000004B8F1010
The measured temperature: 24.5 Deg C, or 76.1 Deg F
超级会员免费看
订阅专栏 解锁全文
763

被折叠的 条评论
为什么被折叠?



