SHT20 wiring

Morning All,

I spent another frustrated weekend fighting with a Temperature sensor that is a SHT20


So where am I up to:
Well i have stripped the sensor back to expose the board and have translated those values into the wiring diagram like this:

Then found a plethora of contradictory wiring info, and nothing with a resistor in it, so I started with power & earth like this


The out with the mulitmeter that gave me more zip.

From lessons learned from the anemometer that one needed a resistor or two that were positioned so illogically but gave me a reading less the base line 2 volts.

The Raspberry Pi is a verson 4 and the pin outs are in the last pic above.
GPIO 1 - 3.0 v power
GPIO 3 - SDA blue wire
GPIO 5 - SLC yellow wire
GPIO 9 - Ground green wire

Code I have started doe not return any errors, but also does not return an values because or the wiring issue.

The code thus far FYI is bad but got as far as :

#1/usr/bin/env python

# Libraries
import time
import datetime
from datetime import date
import RPi.GPIO as GPIO



Your lead identification looks correct according to the product Wiki. It’s not possible to tell from the image how you have connected it to the Pi, but Vcc seems to be missing.

Once you have the wiring set up you shold run a utility to find the I2C address of the device. This confirms that the wiring is correct and the device is responding.

You have posted only a fragment of the code you are using - you should post the full code, or a link to the source you are using for your code.

1 Like

Thanks Jeff,
Thanks for the quick response. From the pinout GPIO’s I have the Pi Connections


This appears to cover off the I2c’s ( as that is what I thought I needed in desperation ) :


Any pointers as to what the name of that any utility will be as that is my missing link and i reasonably suspect the SHT20 is not as straight forward as I have it wired.

Wiki ? can you point me to the address of that.

Code as admitted is incomplete, but not returning errors at this stage. I again suspect it is because the wiring is incorrect, but feel I need to solve one knowledge gap at a time and logically wiring seems to be first ( but I may be very wrong about that too ) .

You can’t know whether your wiring is correct or not until you test it with code, so you have to tackle the two together. The reference above includes a utility to detect the I2C devices:
Configuring I2C | Adafruit’s Raspberry Pi Lesson 4. GPIO Setup | Adafruit Learning System
(about half-way down).

The wiki is at SHT20_I2C_Temperature_&_Humidity_Sensor__Waterproof_Probe__SKU__SEN0227-DFRobot

Pi I2C is usually GPIO2 (Header pin 3, SDA, data) and GPIO3 (Header pin 5, SCL, Clock). There is some useful discussion here:
Raspberry Pi GPIO Pinout: What Each Pin Does on Pi 4, Earlier Models | Tom’s Hardware (



Awesome, on to it now. Tks.

Like the all at once approach but it is very intimidating though knowing what I just dont know.

I have seen the Tom’s hardware and also something similar to the I2c Test but that is succinct code and cuts to the chase.



Yes U are correct as usual as the Vcc Power was disconnected as I did not have the faith in the wiring I achieved and was not willing to risk blowing up either the R-Pi or the sensor.

Sorry Package Unavailable


Do you have a reason for running that command? What happened when you did the I2C detection (sudo i2cdetect -y 1)?

If I2C support is not already installed you will have to go through a comprehensive installation procedure. What OS version are you running? You can google the error message to see what circumstances can create that error and what people have done to resolve it, but you will need to be able to identify your OS and Python versions to choose the correct solution…


Thanks Jeff,

Hey, No need to be sorry. The instructions were run these 2 & I did.
Yes, I needed to check the SHT31 was being seen by the R-Pi, but as usual not.
I will detail what I have done in another post to first externalise my process and see if I can figure out any errors or omissions while also allowing informed assistance.

Thanks again for the post & clarification

Ihave documented this for you, take a look on your other post.

Dont keep making different posts or people wont see them.

This is a totally different temp humidity sensor that they ones that you said that you were trying to get working, but one thing is for sure, DONT put resistors in the circuit, you dont need them.

Im not sure why you are using the proto board, again, you dont need it and it is introducing areas of potential errors. Go from the sensor to the Pi directly.

Just run
sudo i2cdetect -y 1

If that doesnt work then you dont have the correct packages installed and that is the core of all your issues.


This quote is concerning me.
That code wont do anything, so I’m not sure what you expected it to do.

Can you link, as asked, as to where you are getting your information from, because you seem to be jumping around all over the place with various levels of correct and incorrect information that shows a fundamental lack of understanding what you are trying to accomplish.
That is not a criticism, it is an observation on process that you are taking.

You need to go back to first principals and listen to some of the advice that you are being given.
Start again, explain what you have done fully.
ie, have you even turned on the I2C interface in the Raspberry Pi by using sudo raspi-config?

Look at the code that I put in the other thread:

import smbus
import time
# Get I2C bus
bus = smbus.SMBus(1)
# SHT31 address, 0x44(68)
bus.write_i2c_block_data(0x44, 0x2C, [0x06])
# SHT31 address, 0x44(68)
# Read data back from 0x00(00), 6 bytes
# Temp MSB, Temp LSB, Temp CRC, Humididty MSB, Humidity LSB, Humidity CRC
data = bus.read_i2c_block_data(0x44, 0x00, 6)
# Convert the data
temp = data[0] * 256 + data[1]
cTemp = -45 + (175 * temp / 65535.0)
fTemp = -49 + (315 * temp / 65535.0)
humidity = 100 * (data[3] * 256 + data[4]) / 65535.0
# Output data to screen
print ("Temperature in Celsius is : %.2f C" %cTemp)
print ("Temperature in Fahrenheit is : %.2f F" %fTemp)
print ("Relative Humidity is : %.2f %%RH" %humidity)

See how different it is to what you have pasted in this thread?

ie why are you doing this, can you explain?:


This is one of the issues if this is the code that you are using to determine that the sensor is working.


@Andre191880 hang 5 while I replicate everything that I have told you so that I can 100% confirm that you wont have nay issues.

I am well familiar with “fighting” with a circuit for days! - generally I take a step by step approach starting with the basics
Some ideas - forgive me if these are telling you how to suck eggs :slight_smile:
(1) Write a program to toggle the relevant IO lines - check this with oscilloscope/multimeter/LED (with current limiting resistor)
(2) I2C Needs pullup resistors to VCC on SDA and SCL - 3-10K should suffice
(3) Check VCC supply volts - 3.3 or 5V?
(4) I2C is a serial standard - it needs the relevant code/timing to address the bus/peripheral etc - this is the hard bit. You should read relevant articles on the I2C standard
It needs an address and setup code and the standard clock frequency is 100KHz (I think) - there are faster options. One device is master - the peripheral will be a slave
In Arduino I use the Wire.h library - there are no doubt libraries for the Pi.
If you are familiar with Arduino and have a board lying around you could try using this and reading via the Serial port - I have recently done this for an MLX90614 IR thermometer - this would confirm whether the peripheral is OK

If you have a decent CRO/logic analyser you could check that the relevant code is being written - but most people dont have these - have to just try code until it works
Good luck!


You are grossly overcomplicating what is, in fact, a trivially simple task.

I made this guide in one of the other identical threads that the OP has made:

I performed all these steps myself, from scratch, and get the following results when I run the code that I ncluded:


Raspberry Pi I2C already has pull up resistors.

As I said, follow my guide and it will work, you dont need to go the trouble of anything that you posted, these are off the shelf tinker parts, they work.


True - everything is trivial when it works. But it doesnt and he will have to take a systematic approach to find the problem. I havent used this particular part but I have built stuff with Pi and Arduino and other micros. Anyway this sort of banter is not helpful so I will shut up :slight_smile:

1 Like

Can confirm the setup and code @AndrewBG provided works to read temperature and humidity for a SHT31 sensor. Very similar to the SHT20 except for wire colours.
i2cdetect -y 1
Shows 44 as the device.

My version of Python wanted brackets around the print statements, only change.
print(“Temperature in Celsius is : %.2f C” %cTemp)

SHT31 Wiring
Red to pin 1 3v3
Green to pin 3 SDA
Yellow to pin 5 SCL
Black to pin 9 GND

A confusing point is the colour schemes used by these sensors.
Product Wiki (links on Core Electronics web pages)
For SHT20 Red Green Black White. Alternate Red Green Blue Yellow.
For SHT31 Red Black Green Yellow.

The pics from @Andre191880 show Red Green Blue Yellow so its using the alternate colours.
With such varying colour schemes is it any wonder you can easily get it wrong.

Possibly Blue & Yellow need to be swapped, it could be something worth trying.

It is ridiculous the manufacture used Green for ground on one version and Black on the other. Then uses the same colours for data.

Anyway Hope @Andre191880 can get it to work.


1 Like

Yes, but there is soooo much that we dont know about @Andre191880’s setup, that is why I went back to the start and documented it.
It could be as simple as not enabling I2C, or as @James46717 says, maybe the wiring is incorrect.
One thing is for sure, without following the steps that I itemised, it wont work.

As does mine, that’s why I changed it :wink:


@Andre191880 so what was the outcome, it has been a week since you have replied to anything and lots of people have gone well out of their way to help you, despite you not being willing to actually give all the information about what you have done.
It would be good to close off this saga knowing that you were able to get a positive outcome.


Thanks Andrew,
Yes this is the 20 version and different to the 30 version.

I was told to separate posts about them as they are ‘different’