This programm works with Chineese Soil Moisture Sensors YL-69. Read Analog value from A0 pin and out percent of Soil Moisture to UART .
Dependencies: mbed-STM32F103C8T6 mbed
Diff: main.cpp
- Revision:
- 3:6a2c1d1cc937
- Parent:
- 2:38c1190c9ac7
diff -r 38c1190c9ac7 -r 6a2c1d1cc937 main.cpp --- a/main.cpp Fri Jun 08 16:22:39 2018 +0000 +++ b/main.cpp Sat Jun 09 01:15:49 2018 +0000 @@ -12,19 +12,22 @@ int main() { float meas; - float very_hum_value = 0.30; + float very_hum_value = 0.27; float soil_hum_perc; - - + AnalogIn analog_value(A0); - + DigitalOut VCC(PB_7); while(1) { + + VCC = 1;// VCC on wait(1); meas = analog_value.read(); + VCC = 0; //VCC of soil_hum_perc = (1 - (meas - very_hum_value)/(1 - very_hum_value)) * 100; // perevod v % - pc.printf("Soil_Humidity: %f %\n", soil_hum_perc); - //myled = !myled; + pc.printf("Soil_Humidity: %f %% \n", soil_hum_perc); + + wait(600); //period izmereniy } }