Soil moisture with raspberrypi 3

I am new to this platform , so can anyone help me in how to get data from soil moisture using raspberry pi 3
when i tried to add widget it doesn’t gave any option in connectivity and channel.

1 Like

Hi
You must have added ADC converter to Raspberry Pi because Raspberry Pi does not have an ADC converter.
Then connect the analog sensor to the ADC.

I am using soil sensor with a adc sbt4447 which has 2 input pins which is going to sensor and 4 pins in which two are for power i.e vcc and gnd and other two are a0 and d0.

RaspPi - Sensor
3.3V - Vcc
Gnd - Gnd
Digital pin - D0

A0 must connect to ADC converter.

1 Like

Thank you tad.dvor

2 Likes

Hello, I was wondering if it is a good idea to use an Arduino pro mini 3.3 etc to take readings from the sensor every so often? I was reading on some of the instructions with the soil sensors that leaving them powered on all the time could cause them to corrode? would it be possible to use a Arduino pro mini 3.3 volt, a Sparkfun SEN-13637 and then send the readings to Cayenne through a RaspberryPI 3 that is already running some other temp sensors relays etc? Code from Sparkfun:

/* Soil Mositure Basic Example
This sketch was written by SparkFun Electronics
Joel Bartlett
August 31, 2015

Basic skecth to print out soil moisture values to the Serial Monitor 

Released under the MIT License(http://opensource.org/licenses/MIT)

*/

int val = 0; //value for storing moisture value
int soilPin = A0;//Declare a variable for the soil moisture sensor
int soilPower = 7;//Variable for Soil moisture Power

//Rather than powering the sensor through the 3.3V or 5V pins,
//we’ll use a digital pin to power the sensor. This will
//prevent corrosion of the sensor as it sits in the soil.

void setup()
{
Serial.begin(9600); // open serial over USB

pinMode(soilPower, OUTPUT);//Set D7 as an OUTPUT
digitalWrite(soilPower, LOW);//Set to LOW so no power is flowing through the sensor
}

void loop()
{
Serial.print("Soil Moisture = ");
//get soil moisture value from the function below and print it
Serial.println(readSoil());

//This 1 second timefrme is used so you can test the sensor and see it change in real-time.
//For in-plant applications, you will want to take readings much less frequently.
delay(1000);//take a reading every second
}
//This is a function used to get the soil moisture content
int readSoil()
{

digitalWrite(soilPower, HIGH);//turn D7 "On"
delay(10);//wait 10 milliseconds 
val = analogRead(soilPin);//Read the SIG value form sensor 
digitalWrite(soilPower, LOW);//turn D7 "Off"
return val;//send current moisture value

}

Thanks, Adam

Do you mean this: Raspberry Pi ADC: MCP3008 Analog to Digital Converter? I have the same pins on my sensor. It looks like this: https://images.app.goo.gl/81p65H9Yewhw2qHs9

Would I be right in thinking this is how it needs wiring? pi 3 - Preventing corrosion on YL-69 - Raspberry Pi Stack Exchange

yes, that is the write to connect the soil sensor to raspberry pi and to send data to cayenne you need to use MCP plugins GitHub - myDevicesIoT/cayenne-plugin-mcp3xxx: An MCP3XXX extension plugin for Cayenne

I have wired the sensor up via the MCP3008. Cayenne loaded about 8 MCP widgets with zero or low values, is that normal? I deleted all bar the one with the highest reading.

With the probes in a glass of water, I get 0.3. Is this just a question of adjusting the range?

The reading appears for 2-5 seconds and then goes to zero. If I refresh the value returns again for a few seconds.

Any idea what I have done wrong?

navigate to the plugin folder and open sudo nano cayenne_mcp3xxx.plugin and disable all the other channel you dont want. the plugin reads only the raw data from the sensor.

Thanks! Will that stop the reading appearing and resetting to zero? What about the 0.3 reading in water? Is that down to adjusting ranges or something?

Give it a try and let me know whether the same error occurs.

hai miss,where can i choose yl69 sensor on my widget?

hai sir,where can i choose yl69 sensor on my widget?i have cnnect my raspberry pi with mcp3008,however i dont know where to pick yl69 sensor?

can you share a link to your sensor. The mcp3xxx plugin gives the raw analog data and is displayed on cayenne dashboard.