This is a Go port of pyDigiTemp.
Originally written in Python to replace digitemp utility in my pet project and get direct access to 1-wire devices. It was created for reading DS1820 temperature sensor connected to RS232 serial port through DS9097 adapter.
-
DS9097 - COM port adapter which performs RS-232C level conversion.
-
Custom 1-wire serial port interface (see below).
-
DS1820 / DS18S20 / DS1920 - High-Precision Temperature Sensor.
-
DS18B20 - Programmable Resolution Temperature Sensor.
-
DS1822 - Econo Temperature Sensor.
💡
|
See detailed examples in examples directory. |
import "github.com/mcsakoff/go-digitemp"
uart, _ := digitemp.NewUartAdapter("/dev/cu.usbserial-1410")
roms, _ := uart.GetConnectedROMs()
for n, rom := range roms {
log.Printf("%d: %s\n", n, rom)
}
import "github.com/mcsakoff/go-digitemp"
uart, _ := digitemp.NewUartAdapter("/dev/cu.usbserial-1410")
sensor, _ := digitemp.NewTemperatureSensor(uart, nil, true)
temp, _ := sensor.GetTemperatureFloat()
log.Printf("%.02fºC\n", temp)
import "github.com/mcsakoff/go-digitemp"
rom, _ := digitemp.NewROMFromString("10A75CA80208001A")
uart, _ := digitemp.NewUartAdapter("/dev/cu.usbserial-1410")
sensor, _ := digitemp.NewTemperatureSensor(uart, rom, true)
temp, _ := sensor.GetTemperatureFloat()
log.Printf("%.02fºC\n", temp)
|
IMPORTANT DISCLAIMER: All circuits presented here are collected from different sources on the Internet and thus are provided on an entirely "as-is and no guarantees" basis. I do not provide a warranty of any kind and cannot be held responsible in any manner. |
See Serial Port Temperature Sensors - Hardware Interface for details.
Not all schematics work in all cases, depending on an adapter and cable length.
-
Slavko for SVG schematics and testing python version.
Copyright © 2020 Alexey McSakoff
Free use of this software is granted under the terms of the MIT License.
See the LICENSE file for details.