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 ) .
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…
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.
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:
# 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 * 256 + data
cTemp = -45 + (175 * temp / 65535.0)
fTemp = -49 + (315 * temp / 65535.0)
humidity = 100 * (data * 256 + data) / 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.
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
(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
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
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)
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)
VCC GND SDA SCL
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.
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.
@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.