I am using a Raspberry Pi to turn on a 3.3 output pin, then using Arduino Nano to read a voltage divider. How do I read the voltage in higher resolution (2.131235) than 2.1?
The raw analog output is 717-720. The output for my conversionFactor is 0, whether I use int or long.
/*
Print output for voltage divider
*/
int v1 = A0;
int v2 = A1;
int conversionFactor = 3.3/1023;
void setup() { // Function to setup serial
Serial.begin(9600);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int vol1 = analogRead(v1);
int vol2 = analogRead(v2);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 3.3V):
long voltage1 = vol1 * conversionFactor;
long voltage2 = vol2 * conversionFactor;
// print out the value you read:
Serial.print("v1:");
Serial.print(conversionFactor);
Serial.print("|v2:");
Serial.print(voltage2);
Serial.println();
delay(1000);
}