I purchased some Adafruit SHT-30 / SHT30 / ADA4099 Mesh-protected Weather-proof Temperature/Humidity Sensor with 1M Cable from Core Electronics a short time ago. Today I went to use them but neither would work. I have a Raspberry Pi 4 with I2C enabled and a Python script to use the sensor and I know about the “sudo i2cdetect -y 1” command to get the bus address. I do have another SHT-31 sensor (much cheaper and lower quality version of the same thing) which works perfectly. I have tried 3.3v and 5v to power these sensors, I have tried reversing the clock and data pins (per SHT-30 Mesh-protected Weather-proof Temperature/Humidity Sensor [1M Cable] : ID 4099 : $24.95 : Adafruit Industries, Unique & fun DIY electronics and kits) and I have changed the connectors but still no joy.
Hopefully someone can help me. Thanks in advance!
Some testing with a meter reveals 10k ohms resistance across red and yellow wires on one of these sensors and 2.2k ohms resistance across the same wires on the other sensor. My cheap one has 10k ohms resistance across the same wires.
Some more testing with the 10k ohm sensor and my cheap 10k ohm sensor using the same wires with both sensors attached revealed the cheap one working but not the Adafruit one. Then I removed the cheap one and swapped the yellow (SDA) and green (SCL) wires and hey presto… it is now working! What a punish! Not sure why it now decides to work but I’ll take it. Lets see if the Adafruit one with 2.2k ohm resistance will play nicely.
Hi Jason, Welcome to the forum
What was being returned when you ran the command?
sudo i2cdetect -y 1
EDIT: Oh good to hear it’s decided to cooperate for now.
Thanks for the reply mate.
This i what I was getting.
Testing the 2.2k ohm sensor now to see if I can get that going.
No luck with the Adafruit sensor with 2.2k ohms resistance across red and green/yellow wires. I tried it with the exact same working connections in both wiring configurations (i.e. SDA/SCL straight through and reversed) but just cant get an address and no temp/humidity. Seems faulty.
It’s certainly possible that you got unlucky with a faulty unit, can you send through a photo of your wiring setup? Just in case we can help spot something that could trip the Adafruit sensor up.
Hi Trent (and Bryce)
In addition to this issue I was also trying to work out in my head how I was going to get the Pi to read 2 sensors given they probably have the same I2C address (i.e. 0x44). Whilst thinking I decided to setup another I2C bus on the Pi (pins 23 and 24). I then connected the 2.2k ohm sensor to the new I2C bus and the old one to the existing I2C bus (pins 2 and 3). I reversed the yellow/green colours because these Adafruit sensors seem to be wired in reverse. Quite unexpectedly both sensors worked and I have no explanation for this! Maybe it was the different bus or maybe it was something I did differently this time? I don’t know, but I am going to take this as a win. Thank you both for your help.
PS Bryce, if you would still post here with what you have learnt about the 2.2k ohm vs 10k ohm resistance in these sensors, that would be much appreciated as I would like to understand why Adafruit have such variations. Quality?
Screenshot showing both Adafruit sensors with the running of my script underneath. First run was without me touching the sensors. Second was holding onto the 10k ohm sensor on pins 2/3. Third and final run was me holding onto the 2.2k ohm sensor on pins 23/24.
We got both of ours up and running here too, doesn’t seem like there’s any issues with the sensors themselves. I have a feeling that they’ve just changed the design on their sensors over time. It was common originally for these I2C sensors to have a resistance of 10k rather than 2.2k but I’m quite sure it’s not a QC issue as generally when that is the case there’s much more variation between sensors than this bimodal distribution of 10k sensors and 2.2k sensors.
Glad to hear/see that it’s all running normally for you now. If there’s anything else that we can help you with please let us know. Also, thanks for sharing your outcome here! Hopefully this resource will be useful for someone else in future when running into similar issues
Thanks for coming back to me Bryce. I hope this helps someone else out too. Cheers!
The resistors used in I2C will affect the rise and fall time of the bus. Colin’s lab notes has a great video here: I2C Pull-up Resistors - Collin’s Lab Notes #adafruit #collinslabnotes - YouTube
It isnt an issue with quality control or anything. Just Adafruit making sure you can get the most out of each module (you can add a higher value resistor later)
I have hit the same issue and appear to be a few steps behind you.
Can you share that script pls.
Also are you using an analogue capture device like MCP3008 - 8-Channel 10-Bit ADC With SPI Interface | Adafruit ADA856 | Core Electronics Australia (core-electronics.com.au)
I’m not using an analog capture device.
Here are my notes I made for myself from the build I did which I hope are helpful to you.
SHT-3x T&H Sensors
- sudo raspi-config
- Interface Options —> I2C —> Yes (Enable) —> Ok —> Finish
- sudo apt-get install -y python3-pip
- sudo apt-get install -y python3-smbus
- sudo apt-get install -y python3-dev
- sudo pip3 install paho-mqtt
- sudo pip3 install smbus
- sudo nano /boot/config.txt
a. Add following in hardware interfaces section
- If the SHTxx hardware is NOT connected:
a. sudo shutdown now
b. Connect SHT3x sensors as follows:
GPIO 2 & GPIO 3 (+3.3v & GND)
GPIO 23 & GPIO 24 (+3.3v & GND)
c. Boot Pi
- If the SHTxx hardware IS connected:
- sudo i2cdetect -l && sudo i2cdetect -y 1 && sudo i2cdetect -y 4
import paho.mqtt.client as paho
mqtt_broker= “” mqtt_port=1883
# Read bus 1 and convert data
bus1 = smbus.SMBus(1)
bus1.write_i2c_block_data(0x44, 0x2C, [0x06])
data1 = bus1.read_i2c_block_data(0x44, 0x00, 6)
temp1 = data1 * 256 + data1
cTemp1 = -45 + (175 * temp1 / 65535.0)
humidity1 = 100 * (data1 * 256 + data1) / 65535.0
# Read bus 4 and convert data
bus4 = smbus.SMBus(4)
bus4.write_i2c_block_data(0x44, 0x2C, [0x06])
data4 = bus4.read_i2c_block_data(0x44, 0x00, 6)
temp4 = data4 * 256 + data4
cTemp4 = -45 + (175 * temp4 / 65535.0)
humidity4 = 100 * (data4 * 256 + data4) / 65535.0
# Output data to the terminal
print ( “Bus 1 Temperature in Celsius is : %.2f C” %cTemp1)
print ( “Bus 1 Relative Humidity is : %.2f %%RH” %humidity1)
print ( “Bus 4 Temperature in Celsius is : %.2f C” %cTemp4)
print ( “Bus 4 Relative Humidity is : %.2f %%RH” %humidity4)
# MQTT function for callback
def on_publish (client,userdata,result):
print( “data published \n” )
# MQTT connect
client.on_publish = on_publish
# Publish data to mqtt
client.publish( “sensors/bus1/temp" ,cTemp1,0, True )
client.publish( “sensors/bus1/humid” ,humidity1,0, True )
client.publish( “sensors/bus4/temp” ,cTemp4,0, True )
client.publish( “sensors/bus4/humid” ,humidity4,0, True )
# MQTT disconnect
When tested output, setup crontab to execute script.
This is very VERY helpful and aimed at my level of programming. Cheers.
I am looking to have a master script that fires off sub-processes and then gets readings from the sub-process to feed back into the master to then use that information as a value to trigger other processes.
If I can run some logic by you …
My thoughts thus far are to have a loop with a timed reboot ( say 0600 ). This is to scavenge memory leaks and reset all sensors to a know state using snap action switchs as a home confirmation indicator.
On reboot all objects go to a know state: close all vents, watering system valves, & get an initial reading from all environmental sensors & log all actions ( got the logging working nicely too )
Then in no specific order:
if time > 0859 & < 0930) open the return valve on the 240v pressure pump to mix the water reservoir for 30 minutes
then close the return solenoid (valve)
if ( ( time > 0930 & < 0940 ) & ( daylight > 800 lumins) & ( temp > 20 degrees ) fire off the timed watering system on 7 zones sequentially for 5 minutes each ( got this bit working nicely ).
monitor humidity and if < 51% fire run only the top zones of the watering system in sequence
if humidity > 79% stop all the top zones of the watering system
in the main script have a high temperature fail safe that augments the normal watering:
if internal temp > 38 degrees fire off the top watering system
& open top vents fully.
if ( lumens < 400 ) close all vents in sequence to fully closed ( using snap action switch in each of 3 or 4 positions. This can be replaced by a step motor & 1 snap switch (home) when I learn to use each individually before using both in tandem )
if ( lumens > 400 & < 599 ) close all vents in sequence to 1/3
if ( lumens > 600 & < 749 ) close all vents in sequence to 2/3
if ( lumens < 750 ) open all vents in sequence to full open
if external wind speed > 8 then close all vents
if external rain bucket > 4 then close all vents
log external temperature & humidity at 2 degree increments
log all internal values against a time value
The hope is to set this up to keep tropical orchids at an optimum environment, with add-on of weekly adding soluble fertiliser to the water reservoir and then mix that through the 1000 litre IBC (reservoir).
This may allow us to leave the place on holidays when we trust the automated system.
I started this outline in Solenoid Water Valve - Core Electronics Forum (core-electronics.com.au).
Hey this is great and very much appreciated. Good work & than ks heaps for the post. U have restored a lot of sanity and encouragement.