works after a few hours of learning :)
For I2C Soil moisture sensor
Bought this sensor cause all other soil moisture sensors on the market are fare more expensive, so i wanted to give this one a try... had no experience with electronics before, i'm a software guy not into hardware till now, so to help other users after me, i will describe my setup (perhaps you can integrate this into the documentation)
i have a raspberry pi 1 (rev 2 i think, with 512 mb ram)
connected sda, scl lines and 3,3 v and gnd ... had to learn first that you do not need pull up resistors with the raspberry pi i2c ports...
got the newest raspbian image (jessie)
added "dtparam=i2c_arm=on,i2c_arm_baudrate=3000" to "/boot/config.txt" ...the low baudrate should be needed because of some clock streching bug (i don't know if i really need this until now)
after a few tries with the code from https://github.com/JasperWallace/chirp-graphite i started to code myself, because with the code from JasperWallace i got strange readings (wrong values after a few iterations)
so now my one great python code ( i started to learn python 3 hours ago :)
first i got the great i2c libary from adafruit: https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code/tree/master/Adafruit_I2C
download the Adafruit_I2C.py and put it in the same directory with my code...
get my code in better formatting here: https://www.dropbox.com/s/go165cd3dhiapo0/i2c-moisture-sensor.py?dl=0 because the review system ommits whitespaces...
START my code =====================================
#!/usr/bin/python
import time
from Adafruit_I2C import Adafruit_I2C
deviceAddr = 0x20
i2c = Adafruit_I2C( deviceAddr, -1, False )
#to change adress
#i2c.write8( 1, 0x22 )
#to reset
#i2c.write8( deviceAddr, 0x06 )
while True:
temp = i2c.readS16(5, False)
moisture = i2c.readU16(0, False)
i2c.write8(deviceAddr, 3)
time.sleep(3)
light = i2c.readU16(4, False)
print "Temperatur: " + str(temp/float(10)) + \
" Moisture: " + str(moisture) + " Light: " + str(light)
time.sleep(1)
print "ende."
END my code =======================================
just simple code, no classes or more generic code, hope this helps someone...
btw. my readings
indoors, dry on my desk: Temperatur: 25,8 Moisture: 307 Light: 16022
indoors, submerged into waterglass: Temperatur: 21,5 Moisture: 733 Light: 18207
one improvment suggestion: wouldn't it be cool to have the same sensor with a 1-wire bus interface (i'm a bit scared about the whole bunch of cable i will need if i want to monitor the 6 flower pots on my balcony), btw any suggestion how to make the sensor waterproof??