Giter Site home page Giter Site logo

tpow's Introduction

Tiny 1-wire utility. 100% pure python, USB9097 specific.

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

1-wire adapter USB9097 (PCsensor)

Humidity Senosr (TaaraLabs)

tpow's People

Contributors

sken10 avatar bauergeorg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.