Tiny 1-wire utility. 100% pure python, USB9097 specific.
Project description
porvides
Minimal 1-wire protocols for USB9097.
Basic rom search algorithm (use recursion).
has dependencies and limitations
100% pure python, requires pyserial to control UART.
support external power mode only. parasite power mode is not supported.
tested on Windows10 PC + USB9097 (1-wire adapter).
Adapters/Sensors/Devices
USB9097 (1-wire adater with Vcc supply, PCsensor.com ShenZhen/China)
DS18B20, DS2438 (Dallas/Maxim)
Humidity Sensor HIH-5030 + DS2438Z+ (TaaraLabs Estonia)
Usage
Check examples/ folder which contains some tests. pip tpow will install it under Lib/site-packages/tpow. If you can not find examples/, download source package *.tar.gz and check it.
Get a ROMID (one 1-wire device on the bus)
import tpow.usb9097
bus = tpow.usb9097.USB9097('COM3')
bus.cmd_reset() # 0xE3, 0xC1
bus.dat_write([0x33]) # read-rom
ans = bus.dat_read(8) # little-endian (family + SN[6] + CRC)
print(['%02X'%ord(a) for a in reversed(ans)]) # big-endian
Get all ROMID’s (search all ROM’s on the bus)
import tpow.usb9097
bus = tpow.usb9097.USB9097('COM3')
xx = tpow.usb9097.search_roms(bus)
for x in xx:
print(x)
Get temperature / ds18b20
import tpow.usb9097
import tpow.device
import tpow.sensor
bus = tpow.usb9097.USB9097('COM3')
# do temperature conversion and get scratch-pad
spad = tpow.device.ds18b20_skip_rom(bus)
# decode temperature
t = tpow.sensor.ds18b20_temp(spad)
print("SPAD : " + " ".join(['%02X' % ord(a) for a in spad]))
print("%8.3f [degC]" % t)
Todo
check temperature conversion completed status. (currently, wait 1 sec for each temperature conversion)
check operation finished status bit.
check CRC.
refine data type of parameters (bytes, string, list of single bytes…)
License
Copyright (c) 2018 Kenich SHIRAKAWA This is licensed under MIT license. See Licence.txt for more information.
Links
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file tpow-0.2.0.tar.gz.
File metadata
- Download URL: tpow-0.2.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc0a835cdf0c3cd9ca52de2966734ddb84ea3f6b452f0a0b25360226bbcdda2a
|
|
| MD5 |
6b218d0db8151b84b3da4ae932d2440a
|
|
| BLAKE2b-256 |
bf8fdc63b5476fc2a6e1d48aa1db01bd5a91f1c36791f43c6978675be532151e
|