To Read Potentiometer Value

Hello Blynkers,
my simple second project is to read a potentiometer value.

So, on Arduino side I uploaded the GetDataExample and I connected a potentiometer to A0,
on Blynk side I put a value display to show the “analogRead” with “analog” pin A0.
When I turn the potentiometer the values are:
left corner: 1,2, 8, 16…
central corner always: 16
end of right corner: 1004

In other words there is no linearity in the scale

Where am I wrong?

Thank you very much!

Can you show your sketch and format with the </> icon.

Of course. Thanks


#define BLYNK_PRINT Serial // Comment this out to disable prints and save space
#include SPI.h>
#include Ethernet.h>
#include BlynkSimpleEthernet.h>
#include SimpleTimer.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “my-auth”;

SimpleTimer timer;

void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
// You can also specify server.
// For more options, see Transports/Advanced/CustomEthernet example
//Blynk.begin(auth, “server.org”, 8442);
//Blynk.begin(auth, IPAddress(192,168,1,100), 8888);

// Setup function to be called each 1000 milliseconds
timer.setInterval(1000, sendUptime);

}

// This function sends Arduino’s up time every second to Virtual Pin (5).
// In the app, Widget’s reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendUptime()
{
// You can send any value at any time.
// Please don’t send more that 10 values per second.
Blynk.virtualWrite(5, millis()/1000);
}

void loop()
{
Blynk.run(); // Initiates Blynk
timer.run(); // Initiates SimpleTimer
}

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = “my-auth”;

SimpleTimer timer;

void setup()
{
Serial.begin(9600);
Blynk.begin(auth);
// You can also specify server.
// For more options, see Transports/Advanced/CustomEthernet example
//Blynk.begin(auth, “server.org”, 8442);
//Blynk.begin(auth, IPAddress(192,168,1,100), 8888);

// Setup function to be called each 1000 milliseconds
timer.setInterval(1000, sendUptime);

}

// This function sends Arduino’s up time every second to Virtual Pin (5).
// In the app, Widget’s reading frequency should be set to PUSH. This means
// that you define how often to send data to Blynk App.
void sendUptime()
{
// You can send any value at any time.
// Please don’t send more that 10 values per second.
Blynk.virtualWrite(5, millis()/1000);
}

void loop()
{
Blynk.run(); // Initiates Blynk
timer.run(); // Initiates SimpleTimer
}

`

Ok so there is no specific code within your sketch for analogue readings which should be fine as Blynk should just read the port and display it.

When you make reference to ‘corner’ are they the max, min and centre positions on the pot?

In the Value Display what read frequency do you have (PUSH, 250ms up to 59 seconds)?

I restarted the phone and the arduino. And now works !!! :slightly_smiling:

Yes, I use “corner” to mean the pot position
The frequency was 1 second

Thank you

Errata Corrige.
Unfortunately, sometimes it works properly, some not … 50% / 50%
In other words: sometimes there is linearity between rotation of the potentiometer and Blynk Value Display … other display has the same flaw: the values ranging from 0, 16 … then (continuing to turn) nothing happens … then at the end of rotation, the value showed is 1000.
What happens ?
Thanks