have small problem wants a soil moisture sensor with blynk read only when I with gauge mach shows it at dry 1023 instead of 0 and if damp is 0 on instead of 1023 you can help me
Have this code used under loop:
Serial.println (Sensorvalue);
Sensorvalue = analogRead (A0);
Sensorvalue = map (Sensorvalue, 160,1023,1023,0);
SensorValuePercent = (Sensorvalue / 1023) * 100; // In percent
Delay (3000);
Edit: Or if that is already your code and its still wrong then just comment out the map function. Or #2, if you are trying to remap min 160 & max 1023 to 0-1023 then its like this:
Not exactly. He’s not performing Blynk.virtualWrites() so he not flooding anything. His arduino hardware will be happy enough performing an ADC read and map() in the loop.
The issue is he is relying on the app to read the hardware determined in the widget settings in the app. The INTERVAL time. Default is usually 1 second.
This is okay… but its kinda slack and only works while the app is open. So only good to play with.
@markop, you need to use some virtualpins. Copy the PushData.ino Example (also in your IDE menu). Set it up on your network, with your auth code etc and get it working.
Then change the widget to a gauge.
Then change this part of the code from this:
Blynk.virtualWrite(V5, millis() / 1000);
to this:
Blynk.virtualWrite(V5, analogRead(A0) );
Or just add a new line and change the V5 to V6 etc… then have both (why not eh).
This will update the gauge every 1 sec on the HARDWARE side… far more reliable.
Work from this example from now on and you will be okay.
You need to use some virtualpins. Copy the PushData.ino Example (also in your IDE menu). Set it up on your network, with your auth code etc and get it working.
The code is so correct for gauge
Because in the case of a soil moisture sensor, it indicates dryness instead of 0 1023 and in the case of moist 0 instead of 1023