Skip to main content

A package to read/write registers on a temperature sensor with python.

Project description

temperature_sensor_reader

This is a temperature sensor package designed for modbus. Implemented in pymodbus only. PyPI website: https://pypi.org/project/temperature-sensor-reader-xzf8971/

Install

from pypi:

pip install temperature-sensor-reader-xzf8971  

from github:

pip install git+https://github.com/xzf89718/temperature_sensor_reader

Jiandarenke modbus RS485 as example

Before run scripts

Check the COM and chmod

chmod 666 \dev\ttyUSBx

Import modules

from modbus_configuretools import temperature_sensor.RS485_Jiandarenke as RS485_JDRK  
from modbus_configuretools import temperature_sensor.JDRKAddressConfig as Config

Configure parameters for Jiandarenke RS485 sensor

It's OK to set None for unkown value

# Modify these config values 
# Please configure these value in temperature_sensor before read or write values  
# SLAVEID must be specified. If SLAVEID is none, set to 1  
# ADDRESS_HUMIDITY = 0x0000  
# ADDRESS_TEMPERATURE_DEW_POINT = 0x0001  
# ADDRESS_TEMPERATURE = 0x0002  
# ADDRESS_TEMPERATURE_CALI = 0x0050  
# ADDRESS_HUMUDITY_CALI = 0x0051  
# ADDRESS_SLAVEID = 0x07D0  
# ADDRESS_BAUDRATE = 0x07D1  
# TEMPERATURE_CALI = 164  
# HUMIDITY_CALI = 7  
# SLAVEID = 1
# BAUDRATE = 1
myconfig = Config(ADDRESS_HUMIDITY, ADDRESS_TEMPERATURE_DEW_POINT, ADDRESS_TEMPERATURE, ADDRESS_SLAVEID, ADDRESS_BAUDRATE, ADDRESS_TEMPERATURE_CALI, ADDRESS_HUMUDITY_CALI, TEMPERATURE_CALI, HUMIDITY_CALI, SLAVEID, BAUDRATE)

Calibration of sensor. Not necessary calibration every time

sensor.CalibrationJiandarenke(myconfig)  

Set slaveID and baudrate

Please make sure only 1 sensor connect to the modbus bus

sensor.WriteSlaveIDAndBaudrate(myconfig)

Init and read measured values from sensor

# Create a wrapper for JDRK sensor  
sensor = RS485_JDRK(port="/dev/ttyUSB0")  
# Init and connect client
sensor.InitClient()  
# Read slaveID and baudrate  
slaveID, baudrate = sensor.ReadSalveIDAndBaudrate(myconfig)  
# Read temperature, dew point, humidity in one request  
# Only correct for specified sensor
temperature, dew_point_temperature, humidity = sensor.ReadTemperatureAndHumidity(myconfig)  
# Read temperature only  
temperature = sensor.ReadTemperature(myconfig)  
# Read dew point temperature  
dew_point_temperature = sensor.ReadTemperatureDewPoint(myconfig)  
# Read humidity only  
humidity = sensor.ReadTemperature(myconfig)  

Close the sensor

sensor.close()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

temperature_sensor_reader_xzf8971-1.5.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file temperature_sensor_reader_xzf8971-1.5.0.tar.gz.

File metadata

File hashes

Hashes for temperature_sensor_reader_xzf8971-1.5.0.tar.gz
Algorithm Hash digest
SHA256 6b2d9cfa1bd3492fb172297d18d7d93703c08b973544b36d44558bf5b3de999b
MD5 d984b4aa8358f91789a1b8cf10ad9894
BLAKE2b-256 631e26a3c7aca551736678fd0e00d99013aa3cfa8fc7195f5ff3197c7e6baa81

See more details on using hashes here.

File details

Details for the file temperature_sensor_reader_xzf8971-1.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for temperature_sensor_reader_xzf8971-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eaf56fa2c757257a188a6d9babd6a53e728df8c6b84851fbfe17380cc17f0198
MD5 acf24885855797dae422f66ddb102c8d
BLAKE2b-256 18bd3072869201c99137d466d43c0322a033c894b1e268dfcf6adf8d17f3ebfd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page