I'm very new to this. I found this tutorial.
But it don't explain how to read voltages higher than Arduino 5V. I have connected a 100K ohm resistor to positive and 10K ohm to negative of my 24V power supply.
I need some guidance for writing the code for this specific ADC, please.
-
So you want to measure the voltage of your power supply?chrisl– chrisl10/14/2019 14:05:43Commented Oct 14, 2019 at 14:05
-
Yes i want to measure voltages higher than 5V.BIGsmall– BIGsmall10/14/2019 14:57:33Commented Oct 14, 2019 at 14:57
-
You cannot measure much more than 5V with that device neither. (VDD +0.3V) You and that "tutorial") use an adafruit library and should get information from them. If those 2 resistors (100k + 10k) build a voltage divider and negative is connected to GND, 24V is reduced to 24V/11 ~ 2.18V between the two resistors.DataFiddler– DataFiddler10/14/2019 15:01:40Commented Oct 14, 2019 at 15:01
-
i know that Datafiddler but i don't know how can i convert and read that 2,18V to 24V!BIGsmall– BIGsmall10/14/2019 15:03:23Commented Oct 14, 2019 at 15:03
-
It's called "math". For example: Arduino has 10 bit precision and usually 5V reference voltage. That means one step is 5V / 1024 = 0.004883V. And if you divide input voltage by 11, that means you have to multiply previous result by 11 too.KIIV– KIIV10/14/2019 15:11:44Commented Oct 14, 2019 at 15:11
1 Answer 1
As KIIV mentioned you need to do the math:
Use this online voltage divider calculator to calculate your maximum input.
- Keep in mind you shouldn't exceed Arduino 5V.
- Use a multimeter to measure the resistors actual resistance.
- Do the math for your example assuming R1 is exactly 100K and R2 10K you have to multiple the voltage by 11.
- remember any error is going to multiple by 11 too, so make sure the first reading is accurate/stable.
ADS1115 is actually 15bit which will give you resolution of 32768, with default PGA setting you get:
6.144 / 32768 = 0.0001875V
per bit.
Voltage = (your ADC reading) * 0.0001875V;
Voltage = Voltage * 11;
Take a look at This question/answer to see how I did reduced Arduino ADC noise, some steps can be done for ADS1115 as well.