drohm / pi-sht1x Goto Github PK
View Code? Open in Web Editor NEWPython library for the Sensirion SHT1x series of temperature and humidity sensors to work on the Raspberry Pi. This includes the SHT10, SHT11, and SHT15 sensors.
License: MIT License
Python library for the Sensirion SHT1x series of temperature and humidity sensors to work on the Raspberry Pi. This includes the SHT10, SHT11, and SHT15 sensors.
License: MIT License
Hi,
I'm using the SHT1x module in a weather station program. Unfortunately it appears to reset GPIO's and GPIO.setmode which is effecting the main program. I've deleted the GPIO.cleanup() but I still get same problem.
can you help?
Thanks
Donall
Hello,
I've been writing my own minidriver for SHT11, and noticed dew point calculation is wrong here.
This line:
Line 232 in ea8b5bc
Instead of ... / m - (log_humidity + ew)
, it should be ... / (m - log_humidity - ew)
in the denominator.
(Alternatively, ... / (m - (log_humidity + ew))
is also okay.)
TypeError: init() got an unexpected keyword argument 'logger'
I tried to run the example.py, it worked well at the beginning, but suddenly facing the error SHT1X failed to properly receive command [['WriteStatusRegister'] - 00000110]
, and stopped working.
the log file shows
Data Pin: 18
Clock Pin: 23
GPIO mode: GPIO.BCM
Vdd: 3.5
Resolution: High
Heater: False
OTP no reload: False
CRC check: True
[2021-05-28 12:21:50,507] sht1x: _get_ack:393 INFO Command ['Temperature'] [00000011] acknowledged: 3
[2021-05-28 12:21:50,508] sht1x:_send_command:258 INFO SHT1x is taking measurement.
[2021-05-28 12:21:50,509] sht1x:_send_command:261 ERROR SHT1x is not in the proper measurement state: DATA line is LOW.
[2021-05-28 12:21:50,509] sht1x: __exit__:91 INFO GPIO channel function status:
Data pin [18]: GPIO.IN
Clock pin [23]: GPIO.OUT
[2021-05-28 12:21:50,510] sht1x: __exit__:94 ERROR Exception in with block: <class 'pi_sht1x.sht1x.SHT1xError'>
SHT1x is not in the proper measurement state: DATA line is LOW.
<traceback object at 0x75ab71e8>
[2021-05-28 12:24:18,809] sht1x:initialize_sensor:156 INFO Initializing sensor using bit mask: 00000000
[2021-05-28 12:24:18,811] sht1x: _get_ack:393 INFO Command ['WriteStatusRegister'] [00000110] acknowledged: 6
[2021-05-28 12:24:18,812] sht1x: _get_ack:396 ERROR SHT1x failed to properly receive command [['WriteStatusRegister'] - 00000110]
[2021-05-28 12:24:24,530] sht1x:initialize_sensor:156 INFO Initializing sensor using bit mask: 00000000
[2021-05-28 12:24:24,532] sht1x: _get_ack:393 INFO Command ['WriteStatusRegister'] [00000110] acknowledged: 6
[2021-05-28 12:24:24,533] sht1x: _get_ack:396 ERROR SHT1x failed to properly receive command [['WriteStatusRegister'] - 00000110]
[2021-05-28 12:27:37,874] sht1x:initialize_sensor:156 INFO Initializing sensor using bit mask: 00000000
[2021-05-28 12:27:37,877] sht1x: _get_ack:393 INFO Command ['WriteStatusRegister'] [00000110] acknowledged: 6
[2021-05-28 12:27:37,878] sht1x: _get_ack:396 ERROR SHT1x failed to properly receive command [['WriteStatusRegister'] - 00000110]
[2021-05-28 12:28:29,742] sht1x:initialize_sensor:156 INFO Initializing sensor using bit mask: 00000000
[2021-05-28 12:28:29,744] sht1x: _get_ack:393 INFO Command ['WriteStatusRegister'] [00000110] acknowledged: 6
[2021-05-28 12:28:29,745] sht1x: _get_ack:396 ERROR SHT1x failed to properly receive command [['WriteStatusRegister'] - 00000110]
[2021-05-28 12:37:16,251] sht1x:initialize_sensor:156 INFO Initializing sensor using bit mask: 00000000
[2021-05-28 12:37:16,258] sht1x: _get_ack:393 INFO Command ['WriteStatusRegister'] [00000110] acknowledged: 6
[2021-05-28 12:37:16,259] sht1x: _get_ack:396 ERROR SHT1x failed to properly receive command [['WriteStatusRegister'] - 00000110]
[2021-05-28 12:37:56,645] sht1x:initialize_sensor:156 INFO Initializing sensor using bit mask: 00000000
[2021-05-28 12:37:56,648] sht1x: _get_ack:393 INFO Command ['WriteStatusRegister'] [00000110] acknowledged: 6
[2021-05-28 12:37:56,649] sht1x: _get_ack:396 ERROR SHT1x failed to properly receive command [['WriteStatusRegister'] - 00000110]
I'd like to know how to fix this issue.
Look into finding out what changes are required to add SHT7x support.
Data sheet is located here.
I have ordered one soil moisture sensor, by using this code getting values as 103% and above for moistured soil. Please help to get the calibration of the sensor. or is there any other way to get correct values
Hi, im having trouble importing the sht1x it said can’t read. Im new with raspberry pi. Please help me
Hello,
I have a SHT11 breakout sensor and I have tried everywhich way to connect to it with little success. The error I am getting:
Traceback (most recent call last):
File "examples/sensor.py", line 45, in <module>
main()
File "examples/sensor.py", line 37, in main
temp = sensor.read_temperature()
File "/usr/local/lib/python3.4/dist-packages/pi_sht1x/sht1x.py", line 166, in read_temperature
self._send_command()
File "/usr/local/lib/python3.4/dist-packages/pi_sht1x/sht1x.py", line 254, in _send_command
self._get_ack(command_name)
File "/usr/local/lib/python3.4/dist-packages/pi_sht1x/sht1x.py", line 397, in _get_ack
raise SHT1xError(message)
pi_sht1x.sht1x.SHT1xError: SHT1x failed to properly receive command [['Temperature'] - 00000011]
As a short summary:
I have attached an image with the pi wiring below.
I can see that I receive a voltage on pin 18 (I use wiringPi for it) but on the clock pin it's still set for in.
Can you please provide some info on what I am doing wrong?
+-----+-----+---------+------+---+--B Plus--+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | IN | 1 | 3 || 4 | | | 5V | | |
| 3 | 9 | SCL.1 | IN | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 1 | ALT0 | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | ALT0 | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 1 | IN | GPIO. 5 | 5 | 24 | <---- voltage present on pin 18
| 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 | <---- clock should be out I guess
| | | 0v | | | 25 || 26 | 1 | IN | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | IN | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+--B Plus--+---+------+---------+-----+-----+
Please tell me what am I doing wrong.
Thank you.
Hi,
I'm very new to all this so please forgive me.
I'm trying to use a SHT71 humidity sensor with a R.Pi 2 b
The R.Pi is new so may not have everything needed to support the setup.
I copied the pi-sht1x-1.0.6 to my R.Pi and now wish to install it.
Up until now when i'm installing things on the R.Pi i have done the following:
pi@raspberrypi~/pi-sht1x-1.0.6 $ sudo python setup.py install
Howerver when i do this i get:
Traceback (most recent call last):
File "setup.py", line 9, in
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
TypeError: 'encoding' is an invalid keyword argument for this function
Or if i try:
pi@raspberrypi~ $ pip3 install pi-sht1x even with sudo i get:
bash: pip3:command not found
i would greatly appreciate your help.
$ sudo python setup.py install
running install
running bdist_egg
running egg_info
writing requirements to pi_sht1x.egg-info/requires.txt
writing dependency_links to pi_sht1x.egg-info/dependency_links.txt
writing pi_sht1x.egg-info/PKG-INFO
writing top-level names to pi_sht1x.egg-info/top_level.txt
reading manifest file 'pi_sht1x.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
Traceback (most recent call last):
File "setup.py", line 57, in
'hardware', 'driver', 'ic'
File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/site-packages/setuptools/command/install.py", line 67, in run
self.do_egg_install()
File "/usr/lib/python3.5/site-packages/setuptools/command/install.py", line 109, in do_egg_install
self.run_command('bdist_egg')
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/site-packages/setuptools/command/bdist_egg.py", line 152, in run
self.run_command("egg_info")
File "/usr/lib/python3.5/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/lib/python3.5/site-packages/setuptools/command/egg_info.py", line 195, in run
self.find_sources()
File "/usr/lib/python3.5/site-packages/setuptools/command/egg_info.py", line 222, in find_sources
mm.run()
File "/usr/lib/python3.5/site-packages/setuptools/command/egg_info.py", line 308, in run
self.read_template()
File "/usr/lib/python3.5/distutils/command/sdist.py", line 309, in read_template
line = template.readline()
File "/usr/lib/python3.5/distutils/text_file.py", line 175, in readline
line = self.file.readline()
File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)
I got the following error when running examples.py
pi@raspidoko:~/pysuhu/pi-sht1x $ sudo python3 examples/examples.py Test: using default values: 3.5V, High resolution, no heater, otp_no_reload off, CRC checking enabled... Traceback (most recent call last): File "examples/examples.py", line 140, in <module> main() File "examples/examples.py", line 13, in main temp = sensor.read_temperature() File "/usr/local/lib/python3.5/dist-packages/pi_sht1x/sht1x.py", line 166, in read_temperature self._send_command() File "/usr/local/lib/python3.5/dist-packages/pi_sht1x/sht1x.py", line 254, in _send_command self._get_ack(command_name) File "/usr/local/lib/python3.5/dist-packages/pi_sht1x/sht1x.py", line 397, in _get_ack raise SHT1xError(message) pi_sht1x.sht1x.SHT1xError: SHT1x failed to properly receive command [['Temperature'] - 00000011]
I buy the sensor from my local store as following.
https://www.bukalapak.com/p/elektronik/elektronik-lainnya/9pm7s-jual-sensirion-temperature-humidity-sensor-sht11?product_sku=24100907
this is my board
https://cloud.githubusercontent.com/assets/184959/7376782/26e48554-edb0-11e4-9cd9-d0196abe4c00.png
I've check my cable and seem nothing wrong. I connect the sensor directly to the Pi board
is there anything wrong?
Dear Doug,
thanks for pi-sht1x. I'm using version 1.09 and it works really well except for the default logging as it is defined in the code.
I'm using the library to read the data from several sensors every couple of minutes. This means with logging level INFO a lot of data is produced. In fact, the log runs over about every 6 hours. I changed this by setting the logging level to WARNING. Now, I get much smaller logs. I gues that most users do not need such extensive logs and would therefore propose that you change the default logging level to something higher than INFO when you make an update to the library.
Moreover, GPIO access does not require root privileges any more. In a central installation, pi-sht1x still requires root privileges because of the location of the log. Moving the log elsewhere would make root priviledges not necessary anymore. It works well for me with ordinary user priviledges after I changed the write permissions to the pi-sht1x directory. In my case this is no problem because it is a quasi single user system. But this is not an ideal solution. Maybe you want to consider this point, too.
Regards,
Matt.
Hi! I am using a raspberry pi which its Tx and Rx are being used for another sensor and I want to add this temperature sensor and use it with this library. The error that I get says "this channel is already in use...:"
I will attach a picture of the error and a picture of my script
I guess it may get fixed if I change this argument ("gpio_mode=GPIO.BCM") to something else but I don't know to change to what. And if that is the case, then I might as well have to change the pin numbers as well.
https://drive.google.com/file/d/1bNgqmvH1ro7rdcnOTrKLd6knk3u21dWH/view?usp=sharing
https://drive.google.com/file/d/1ToFc7oAD3yxwXuOGXXbLSsVhfevgHqoZ/view?usp=sharing
I tried your library but it seems it is not working.
Raspbian Jessie
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.