Hi Guys,
I think this is the correct place to post this i am trying to create a voltage divider to measure a voltage greater than 5V the analog pin can handle(15Kv is the end goal but i just chose these resistance values to test). I am new to using Arduino but i was able to get the circuit/program working but i am having issues with the accuracy of the measurement i added the line "Vcalc = Vcalc*9.81;" so i can use the exact ratio of the divider measured with a multimeter. i use this measurement and the 10V will read 8.5 and 20V will read 17. I can adjust the Ratio in the program to get it closer to 10V at 10V (around 10.2-10.5) but the 20 will then go up to 22/23V.
I would also sometimes have my LCD showing 1.1-1.4V with nothing connected to the A0 PIN
I think this problem is to do with the Arduino as the divider is working correctly (its just 2 resistors) and the LCD is working correctly
Edit: I had uploaded the wrong circuit diagram
Edit2: I have had a lot of comments about safety. I am not currently using 15KV i am trying to get the circuit to work with a lower voltage 50V before i try anything HV i am just trying to get the circuit to work correctly
MY CODE
#include <Adafruit_NeoPixel.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
//VCC to 5V
//GND to GND
//SCL to A5
//SDA TO A4
//Voltage divider/measurement
int VoltageV = A0; // Pin that the voltage is measured from
void setup() {
pinMode (VoltageV, INPUT); //declares A0 as input
lcd.init();
lcd.backlight();// initialises lcd and backlight
}
void loop() {
int VoltageMsmt = analogRead(VoltageV); // read voltage on A0 pin
float Vcalc = (5.0/1023)*VoltageMsmt; //divide max voltage by 1023 and times it by the reading from the analog pin
Vcalc = Vcalc*9.81; //ratio of the divider
lcd.setCursor(4,0);
lcd.print ("Voltage");//top row of segments
lcd.setCursor(5,1);
lcd.print(Vcalc);//bottom row of segments
}