I am using a soil moisture sensor(2 pin) as an analog input.But i am only getting 1024 as output and the value remains the same even if i change the position of the sensor. I tried the sensor values using an Arduino and it was showing proper values.What is going wrong when i am using it with the bolt module? Below is the code for
When the Soil has Moisture level increased then we receive a lower Analog Value from the Sensor.
When the Soil has Moisture level decreased then we receive a higher Analog Value from the Sensor and since we have to map the moisture level in percentage then, we will divide by 1024 and then multiply by 100 to get the percentage but this value is not the final value as we have to detect the moisture and suppose we receive 2 values from the sensor at 2 different times like 35 and 1000 where 35 shows increase in moisture level and 1000 shows decrease in moisture level.
Moisture = (35/1024)*100 = 3.4% moisture…but this is not the correct value so we subtract this value from the total moisture content that is 100%…So no we get 100-3.4 = 96.6% mg/L…which shows a more appropriate value for the Moisture.
Now, we do same for 1000 value to verify our result.
Moisture = (1000/1024)*100 = 97%…Moisture = 100-97 = 3% mg/L
You can visit here https://www.hackster.io/suas106/soil-moisture-monitoring-with-bolt-iot-f3d547