Hello everyone, I am using the Spark Fun - Soil Moisture Sensor to measure soil moisture content, which only requires 3 pins for connection.
I read a few articles describing how to formulate an A/C using 2 digital pins, and reversing the current with a delay, but the examples I saw pertained to a D.I.Y built sensor. I connected a 2nd digital pin to the VCC on my SparkFun, and coded an imitation of the reversal, and even output the values to a serial monitor, but I'm not sure if it actually worked.
I was just wondering if it was possible to provide power using 2 digital pins, instead of 1, on a 3 pin sensor?
Here's a copy of my code:
void setup()
{
pinMode(SOIL_POWER_UP, OUTPUT); //pin 7
pinMode(SOIL_POWER_DOWN, OUTPUT); //pin 8
Serial.begin(9600);
Serial.println("RESET");
}
void measureSoilMoisture()
{
int powerUp = digitalRead(SOIL_POWER_UP);
int powerDown = digitalRead(SOIL_POWER_DOWN);
digitalWrite(SOIL_POWER_UP, HIGH);
digitalWrite(SOIL_POWER_DOWN, LOW);
delay(1000);
Serial.print(powerUp);
Serial.print(' ');
Serial.print(powerDown);
Serial.println();
digitalWrite(SOIL_POWER_UP, LOW);
digitalWrite(SOIL_POWER_DOWN, HIGH);
delay(1000);
Serial.print(powerUp);
Serial.print(' ');
Serial.print(powerDown);
Serial.println('\n');
}
Also a copy of the output:
RESET
0 0
0 0
0 1
0 1
(repeats 0 1)