Chirp is a great little soil moisture sensor. This is a library for the Chirp soil moisture sensor. It supports reading Capacitance (soil moisture) and soil temperature. You can get Chirp on Tindie https://www.tindie.com/products/miceuz/i2c-soil-moisture-sensor/ And read documentation on github https://www.tindie.com/products/miceuz/i2c-soil-moisture-sensor/
Revision 1:faff11456df9, committed 2017-01-20
- Comitter:
- Vlad
- Date:
- Fri Jan 20 00:36:11 2017 +0000
- Parent:
- 0:6164b94deb27
- Commit message:
- 10khz i2c
Changed in this revision
Chirp.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6164b94deb27 -r faff11456df9 Chirp.cpp --- a/Chirp.cpp Thu Jan 12 22:01:43 2017 +0000 +++ b/Chirp.cpp Fri Jan 20 00:36:11 2017 +0000 @@ -6,10 +6,11 @@ Chirp::Chirp(PinName sda, PinName scl, char slave_adr) :i2c_p(new I2C(sda, scl)), i2c(*i2c_p), address(slave_adr) { - + i2c.frequency(10000); } float Chirp::getCapacitance(){ + i2c.frequency(10000); short capacitance = 0; char i2cData[2]= {0}; @@ -29,9 +30,11 @@ } float Chirp::getTemperature(){ + i2c.frequency(10000); short temperature = 0; char i2cData[2]= {0}; + char dataReg = 5; //Temperature is stored in 2 bytes at address 5 i2c.write(address, &dataReg, 1); int success = i2c.read(address, i2cData, 2);