Go Down

Topic: Question about a DC0-24 Voltage Sensor  (Read 142 times) previous topic - next topic

RDaugherty

So I've been messing around for a bit with trying to make a rudimentary but accurate voltage meter for a project.

I started with a simple resistor-built voltage divider but my numbers were sporadic. I then moved to using

ADS1115 16-Bit ADC
+ The resistor-voltage divider.

I feel like it helped a bit but I decided to go for broke and wen't with a premade voltage sensing board so now I have

ADS1115 16-Bit ADC
Arduino Uno
DC0-25V

And upon first test ( a 9V battery ) it kicked out 9.00V so that was nice. I of course need it further resolution but for first test it was great.

But then I moved onto a AAA battery and sadly it kicked out 8.00V so not so nice :(

Now, for some clarification, both of these readings are done with reverse polarity. IE: the board is setup properly but for the two "meter leads" they are reversed on the batteries. If I have them non-reversed I get: 1.00 on the 9V and 2.00 on the AAA.

So not sure why that is. So some help in getting this right would be awesome!

Here is my code;

Code: [Select]

#include <Wire.h>
#include <Adafruit_ADS1015.h>
 
Adafruit_ADS1015 ads1015;
Adafruit_ADS1115 ads(0x48);

int val1;
int val2;
 
void setup(void)
  {
  Serial.begin(9600);

  ads1015.begin();
}
 
void loop(void)
{
  int16_t adc0, adc1, adc2, adc3;
  float temp;
 
  adc3 = ads1015.readADC_SingleEnded(3);
  val1 = adc3;
  temp = val1/5.092;
  val1 = (int)temp;
  val1 = ((val1%100)/10);
  temp = val1;
  Serial.print("Voltage = ");
  Serial.println(temp, 2);
  delay(700);
}
[center][/center]


And I can provide a wire diagram of the project if need be (never done it before, but can try) but I'm fairly sure I got it all hooked up right.

Goals: Get detecting between two different batteries to be accurate. Get resolution down to exact; IE: 9.54 and 1.87 for the two batteries.

Thanks in advanced!

KingDubDub

You're going to need different maths for the different batteries, unless the sensor can detect the battery. A system where you calibrate the code for a 9-volt battery is going to give out weird readings for a battery of 1/6 the voltage. I have a similar problem, made a post here: http://forum.arduino.cc/index.php?topic=595905.0
The best code isn't the what does the most in the least amount of lines, but the simplest kind, that anyone of any skill-level can understand.

WattsThat

Quote
Now, for some clarification, both of these readings are done with reverse polarity. IE: the board is setup properly but for the two "meter leads" they are reversed on the batteries. If I have them non-reversed I get: 1.00 on the 9V and 2.00 on the AAA.
I have no idea what that means. If you don't understand how to properly connect the board, please ask, don't just start swapping wires as things tend to blow up when they're connected backwards.

You said you bought an ADS1115. Then you post code that uses the ADS1015 object which is 12 bit part rather than using the correct 16 bit ADS1115. Further, your code makes no sense whatsoever, it looks like code that would use the a/d in the Uno. Download and use the Adafruit library AND the demo program for single-ended inputs. That's where you start, that's how you prove out the ADS1115 board. Stick with input voltages 5 volts and less. Get that working correctly.

After you have the ADS1115 working, then you can use a voltage divider for higher voltages. The DCO-25 part provides a fixed 5:1 ratio so you want to multiply the input value, not divide it as your code does.

Vacuum tube guy in a solid state world

Go Up