Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHT20 feature request #84

Closed
Aapjes94 opened this issue Jan 29, 2018 · 21 comments
Closed

SHT20 feature request #84

Aapjes94 opened this issue Jan 29, 2018 · 21 comments

Comments

@Aapjes94
Copy link

I'd like to put in a feature request for SHT20 weatherproof temperature and humidity sensor. I run a very humid environment and would like to monitor soil moisture as well. Other sensors easily get corroded under these circumstances, but these seem to be up to the task. The sensor is essentially just an SHT-20 with the 4 data/power wires brought out so any SHT-2X code for a microcontroller will work. It uses I2C, I'm not sure if that will form a problem.

@theyosh
Copy link
Owner

theyosh commented Jan 29, 2018

Do you have an example of a device? I do find SHT15 and SHT21 but no 20. I do see some people got a SHT21 working on a PI. So that should be not an issue. But I would like to test it myself so I need some hardware to test with.

@Aapjes94
Copy link
Author

I was thinking of something like this or this The way I read it, it runs the same software as a SHT21, but is a cheaper(less accurate version).

@theyosh
Copy link
Owner

theyosh commented Jan 29, 2018

Hmmm... they look cool... I will look into it.

@theyosh
Copy link
Owner

theyosh commented Feb 9, 2018

Hardware is ordered for testing... shipping is about 20 days :(

@Aapjes94
Copy link
Author

Aapjes94 commented Feb 9, 2018

Really cool that you're willing to do this, thanks a lot.

@theyosh
Copy link
Owner

theyosh commented Feb 26, 2018

Just got update that shipment has started.... so still 20 days waiting :(

@Aapjes94
Copy link
Author

Thanks for the update. Chinese New Year delayed some of my orders as well.

@theyosh
Copy link
Owner

theyosh commented Mar 15, 2018

Hardware has arrived!! Now we need to read Chinese :P

@Aapjes94
Copy link
Author

Cool! Let me know if you get stuck with some of the documentation and I'll try to help.

@theyosh
Copy link
Owner

theyosh commented Mar 16, 2018

I figured out the colors with google translate to chinese.. So now it is only matter of connecting them and trying some code...

But if you have already something working, please share...

@Aapjes94
Copy link
Author

These are the colours as labelled from my order. Not using black for the ground is strange to me...

connection mode: VCC-red GND-green DATA-black SCK-white

With studying and exams last week I haven't gotten around to testing the sensors myself but I found someone who linked this a while ago and saved that. I'm still learning python so while I feel comfortable editing code I'm not really able to write that well. This code is well documented and commented so it should provide a good starting point.

@theyosh
Copy link
Owner

theyosh commented Mar 16, 2018

Ah, now it gets funny. I have the following colors: black, brown, yellow, blue :p

And I found: https://github.com/imonkey-tw/weather168_raspberry_pi/blob/master/SHT20/SHT2x2xively.py

So that are already two ways of coding. That is nice... I hope to do some testing this weekend

@Aapjes94
Copy link
Author

Let’s make this some more fun, shall we? I just looked it up and the product I have does not correspond with the product description. The sensors I have are RELed, Green, Blue and Yellow.

I took the sensor appart and the PCB is labeled at least.

Red - VCC
Green - GND
BLUE - SDA
Yellow - SCL

theyosh added a commit that referenced this issue Apr 1, 2018
@theyosh
Copy link
Owner

theyosh commented Apr 1, 2018

do a git clone, restart and clear browser cache. You should be able to add new type of sensors.

To find the right ID, use i2cdetect -y 1 and enter the found ID. Probably 40. Use that as address
Downside, only 1 sensor can be used for now. I do not know how change the sensor I2C address. That is needed to support multiple SHT2X sensors through I2C

@BashSer
Copy link

BashSer commented Apr 1, 2018

How about "template" for i2c ? =D
User input bus (example, i use 1 for hw_clock, and 0 for other. Another can ise any multiplexer and i2c bus can = 3, 8 and etc), address and need formulas from datasheet. This can realization of template from GUI or import file where user write all needed data.

@theyosh
Copy link
Owner

theyosh commented Apr 1, 2018

Sorry, it is unclear what you try to tell. I do not have I2C experience. Nor do I have other hardware to test. So please be more clear what you mean.

It is possible to enter a value like [BUS_ID],[HEX_ADDRESS] which can be 0,40 using bus 0 in stead of bus 1

@BashSer
Copy link

BashSer commented Apr 1, 2018

Sorry, my language is not good.
I will adding more information at night (UTC+3).
It's easier not to work on each sensor, and make a template that the user will fill in himself.
Upper left pins on RPI this bus 1 i2c, pins 27-28 bus 0.
"HEX-address" for access to a certain sensor.
And in this "hex_address" you have one more matrix with data. Example in bus 0, hex_address 0x40, inner address 0x00 has data "0C". This data from datasheet, example, mean "0x40" address from factory (not all can change this with user), "0x00" data with temp (0x01 data with humidity end etc) and "0x40" this "real temp" but it's need multiple/divide and etc for "human view".
In template user can input all data this is easy for you and more flexible for user.
Because many sensor has different address, formulas and user can use many other hardware to adding extra bus.
I can help with payment for this hardware/sensor if you can give bill for payments in ruble =)

@BashSer
Copy link

BashSer commented Apr 1, 2018

rpi
First use breadboard, sorry xD
If you type "i2cdetect -y 1" you see only RTC module, but if you type "i2cdetect - y 0" you can see LCD, SHT15 and DHT12(i dont know about third module on this schema :D). But, again, user can use, example, MCP23017 and can use not only bus 0 and 1, but also bus 43 and etc.

In datasheet for DHT12 we can read:

"| BYTE ADDR | R/W |        Description       |           Note           |"
"|    0x00   |  R  | Humidity integral digits | Relative humidity values |" 
"|    0x01   |  R  |      Humidity Scale      | Relative humidity values |" 
"|    0x02   |  R  |  Temperature integer bit |   The temperature value  |" 
"|    0x03   |  R  |      Temperature scale   |   The temperature value  |" 
"|    0x04   |  R  |                          |         Checksum         |"

Ok, example code from internet for this:

  #read 5 bytes of data from the device address (0x05C) starting from an offset of zero
  data = bus.read_i2c_block_data(addr,0x00, 5)

  print "Humidity = " + str(data[0]) + "." + str(data[1]) + "%"
  print "Temperature : " + str(data[2]) + "." + str(data[3]) + "C"

  if (data[0] + data[1] + data[2] + data[3] ==  data[4]):
    print "checksum is correct"
  else:
    print "checksum is incorrect, data error"

And after this can be done "template" - user need input: I2C_BUS, ADDRESS and inner data.
Example:

BUS = 0;
Address sensor = 0x5C;
Hum = 0x00;
Hum_scale = 0x01;
Temp = 0x02;
Temp_scale = 0x03;
Check_sum = 0x04;

80% sensor uses this data. Exception - more expensive sensors(temp + hum + pressure and other). But if user can import template and enter data himself, then this should not be a problem

Many sensors have a programmed address on a bus, because it is not possible to use several identical sensors =(
But I heard user can use multiplexer and other things =)

For si7021 in short:

# 0xF5(245)	Select Relative Humidity NO HOLD master mode
bus.write_byte(0x40, 0xF5)
# Read data back, 2 bytes, Humidity MSB first
data0 = bus.read_byte(0x40)
data1 = bus.read_byte(0x40)
# Convert the data
humidity = ((data0 * 256 + data1) * 125 / 65536.0) - 6
 
#0xF3(243)	Select temperature NO HOLD master mode
bus.write_byte(0x40, 0xF3)
# Read data back, 2 bytes, Temperature MSB first
data0 = bus.read_byte(0x40)
data1 = bus.read_byte(0x40)
# Convert the data
cTemp = ((data0 * 256 + data1) * 175.72 / 65536.0) - 46.85
fTemp = cTemp * 1.8 + 32

# Output data to screen
print "Влажность: %.2f %%" %humidity
print "Температура C: %.2f" %cTemp
print "Температура F: %.2f" %fTemp

Or i can help to collect scripts for difference sensors =D

@theyosh
Copy link
Owner

theyosh commented Apr 2, 2018

I am sorry, but above message is not helping with this issue. Please post on the right issues.
Also this will need very smart people, as even I am not able to understand this. How can this then be added by non technical persons. Sorry, this is not going to work.

This issue will be closed now, as support for the SHT20 is now available

@BashSer
Copy link

BashSer commented Apr 2, 2018

If i give you tested and working python scripts for different sensors for measurment can you adding this in your project ?

@theyosh
Copy link
Owner

theyosh commented Apr 3, 2018

Yes, but please, create new issue per sensor / code. So it is easier to debug and fix issues per sensor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants