I just successfully integrate this sensor into Espruino. As far as I know, nobody did it yet (or did not publish a basic example code), so I decided to post it here.
You will notice that this piece of hardware integrate a capacitive sensor, as well as a luminosity & temperature sensor.
The temperature result is in [°c/10] : if result is 226, temperature is 22.6°c.
The capacitive & luminosity sensor are both relative.
If you try it, do not forget to add two ~10k Pull-ups on both SDA and SCL.
// Soil Moisture Sensor Example | JRY | 26.06.2015
var Temp;
var Lumi;
var Capa;
I2C1.setup({scl:B6,sda:B7});
function getLuminosity(){//takes ~2 sec. to acquire
I2C1.writeTo(0x20,0x03);
setTimeout(function(){
I2C1.writeTo(0x20,0x04);
Lumi=I2C1.readFrom(0x20,2);
print("Lumi:"+(Lumi[0]*256+Lumi[1]));
},2000);
}
function getCapacitance(){
var Res;
I2C1.writeTo(0x20,0x00);
Res=I2C1.readFrom(0x20,2);
Capa=Res[0]*256+Res[1];
print("Capa: "+Capa);
}
function getTemperature(){
var Res;
I2C1.writeTo(0x20,0x05);
Res=I2C1.readFrom(0x20,2);
Temp=Res[0]*256+Res[1];
print("Temp: "+Temp);
}
I2C1.writeTo(0x20,0x06);//reset the sensor
//setInterval(getTemperature,10000);
//setInterval(getLuminosity,4600);
setInterval(getCapacitance,1000);
If anyone has a better code or a dedicated .js class, do not hesitate to publish it! :-)
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi guys.
This following post refers to the "Chirp" soil moisture sensor (https://www.tindie.com/products/miceuz/i2c-soil-moisture-sensor/).
I just successfully integrate this sensor into Espruino. As far as I know, nobody did it yet (or did not publish a basic example code), so I decided to post it here.
You will notice that this piece of hardware integrate a capacitive sensor, as well as a luminosity & temperature sensor.
The temperature result is in [°c/10] : if result is 226, temperature is 22.6°c.
The capacitive & luminosity sensor are both relative.
If you try it, do not forget to add two ~10k Pull-ups on both SDA and SCL.
If anyone has a better code or a dedicated .js class, do not hesitate to publish it! :-)
1 Attachment