Power Meter

Im working on a power meter ,I intend to use it for RC purpose , DC current. It’s just a handheld type unit using the source, up to 24V DC , with a Max of 27V to power it.
Its based on the Alegro ACS758B current sense , rated at 150Amp ,13.3mv/A

Heres the schematic and some sample code Ive been toying with .
results are promising …Another opinion would be appreciated.

#include <LiquidCrystal.h>

 /* This sketch describes how to connect a ACS715 Current Sense Carrier
 (http://www.hacktronics.com/Sensors/Current-Sensor-30-to-30-Amp/flypage.tpl.html) to the Arduino,
 and read current flowing through the sensor.

 */

 LiquidCrystal lcd(2,3,4,5,6,7);

 /*

 Vcc on carrier board to Arduino +5v
 GND on carrier board to Arduino GND
 OUT on carrier board to Arduino A0

 Insert the power lugs into the loads positive lead circuit,
 arrow on carrier board points to load, other lug connects to
 power supply positive

 Voltage Divider

 11.66 from + to A4
 4.62k from A4 to Gnd
 Ratio 2.5238

 */
 int batMonPin = A4;    // input pin for the voltage divider
 int batVal = 0;       // variable for the A/D value
 float pinVoltage = 0; // variable to hold the calculated voltage
 float batteryVoltage = 0;

 int analogInPin = A0;  // Analog input pin that the carrier board OUT is connected to
 int sensorValue = 0;        // value read from the carrier board
 int outputValue = 0;        // output in milliamps
 unsigned long msec = 0;
 float time = 0.0;
 int sample = 0;
 float totalCharge = 0.0;
 float averageAmps = 0.0;
 float ampSeconds = 0.0;
 float ampHours = 0.0;
 float wattHours = 0.0;
 float amps = 0.0;

 int R1 = 4300000; // Resistance of R1 in ohms
 int R2 = 1000000; // Resistance of R2 in ohms

 float ratio = 0;  // Calculated from R1 / R2

 void setup() {
   // initialize serial communications at 9600 bps:
   Serial.begin(9600);
   lcd.begin(20, 4);
   lcd.clear();
 }

 void loop() {
  
 int sampleBVal = 0;
 int avgBVal = 0; 
 int sampleAmpVal = 0;
 int avgSAV = 0;
  
 for (int x = 0; x < 10; x++){ // run through loop 10x

   // read the analog in value:
   sensorValue = analogRead(analogInPin);  
   sampleAmpVal = sampleAmpVal + sensorValue; // add samples together

   batVal = analogRead(batMonPin);    // read the voltage on the divider
   sampleBVal = sampleBVal + batVal; // add samples together
  
   delay (1); // let ADC settle before next sample
 }

 avgSAV = sampleAmpVal / 10;

   // convert to milli amps
    outputValue = (long) avgSAV * 5 / 1024 -524 * 1000 / 133;
  
 /* sensor outputs about 100 at rest.
 Analog read produces a value of 0-1023, equating to 0v to 5v.
 "((long)sensorValue * 5000 / 1024)" is the voltage on the sensor's output in millivolts.
 There's a 500mv offset to subtract.
 The unit produces 133mv per amp of current, so
 divide by 0.133 to convert mv to ma
 Changed value to 13.3mv to match 150amp sensor
          
 */

 avgBVal = sampleBVal / 10; //divide by 10 (number of samples) to get a steady reading

   pinVoltage = avgBVal * 0.00488;       //  Calculate the voltage on the A/D pin
                                 /*  A reading of 1 for the A/D = 0.0048mV
                                     if we multiply the A/D reading by 0.00488 then
                                     we get the voltage on the pin. 
                                   
                                     NOTE! .00488 is ideal. I had to adjust
                                     to .00610 to match fluke meter.
                                    
                                     Also, depending on wiring and
                                     where voltage is being read, under
                                     heavy loads voltage displayed can be
                                     well under voltage at supply. monitor
                                     at load or supply and decide.
 */

   ratio = (float)R1 / (float)R2;
   batteryVoltage = pinVoltage * ratio;    //  Use the ratio calculated for the voltage divider
                                           //  to calculate the battery voltage
                                          
                                            
   amps = (float) outputValue / 1000;
   float watts = amps * batteryVoltage;
    
   Serial.print("Volts = " );                      
   Serial.print(batteryVoltage);     
   Serial.print("\t Current (amps) = ");     
   Serial.print(amps); 
   Serial.print("\t Power (Watts) = ");  
   Serial.print(watts);  
  
    
   sample = sample + 1;
  
  msec = millis();
  
  time = (float) msec / 1000.0;
  
  totalCharge = totalCharge + amps;
  
  averageAmps = totalCharge / sample;

  ampSeconds = averageAmps*time;
  
  ampHours = ampSeconds/3600;
  
  wattHours = batteryVoltage * ampHours;
 
   Serial.print("\t Time (hours) = ");
   Serial.print(time/3600);
  
   Serial.print("\t Amp Hours (ah) = ");
   Serial.print(ampHours);
   Serial.print("\t Watt Hours (wh) = ");
   Serial.println(wattHours);
  
     lcd.setCursor(0,0);
     lcd.print(batteryVoltage);
     lcd.print(" V ");
     lcd.print(amps);
     lcd.print(" A ");
  
   lcd.setCursor(0,1);
   lcd.print(watts);
   lcd.print(" W ");
   lcd.print(time/3600);
   lcd.print(" H ");
  
   lcd.setCursor(0,2);
   lcd.print(ampHours);
   lcd.print(" Ah ");
   lcd.print(wattHours);
   lcd.print(" Wh ");
  
   lcd.setCursor(0,3);
   lcd.print(ratio, 5);
   lcd.print("   ");
   lcd.print(avgBVal);
  
   // wait 10 milliseconds before the next loop
   // for the analog-to-digital converter to settle
   // after the last reading:
   delay(10);                    
 }

A quick glance, and I had already 10 remarks.

1 ) The 7805 needs 100nF at input and output to ground. No matter what, they should be there.

2 ) You connect the 5V to the Arduino Vin. That causes a voltage drop for the Arduino. You can connect the 5V to the Arduino 5V pin. That is not recommended, since it might destroy the voltage regulator on the Arduino board. However, I do that all the time.

3 ) The current sensor is in the ground wire of the motor. I would prefer to have one side of the motor connected to ground, and the current sensing in the 27V wire.

4 ) I am very interested in your current sensor board. The design of the copper traces is a big deal, some are badly designed. The newer ones seem to be better.

5 ) You use zener diodes for safety to protect the Arduino input. That is okay, but you could omit them and increase the 470 ohm to 4k7. For now, just keep them.

6 ) The potentionmeter to tune the voltage divider to measure the 27V is not needed. Use a fixed resistor and adjust it in software.

7 ) You use 10 samples to average the current sensor value. The ACS712 is very sensitive for 50Hz/60Hz mains noise and other magnetic noise. Perhaps you have to increase that to 1000 samples or more. If you do, use long integers.

8 ) I'm sorry to say but this line does not tell the compiler what to do.

outputValue = (long) avgSAV * 5 / 1024 -524 * 1000 / 133;

Please use brackets and please use float variables. And add comment, so you will know what the numbers are when you look at it after a year. There is no need to write that on a single line. You can convert it to a voltage at the Arduino pin, and adjust it for the resistor divider voltages in another line. I would rather have 10 lines of code with many temporary variables with good comment, than a single line that I don't understand.

9 ) If the voltage of the Arduino 5V pin is lower than 5V, you could use the internal analog reference to measure voltages. You have to adjust the resistor dividers if you do.

10 ) Variable 'msec' is millis(), that will rollover some day.

Thank you!!
That line of code has been a headache.I’m still mulling it about.
Im a new old hand…make sense??? Im working on the fritzing editing thing…sorry.
Ive tried it out with this sample code …for the ACS758.(I dont know just yet how to edit parts in Fritzing Mine is the ACS758,) I got to within +400ma of two other meters

I revised the Schematic , I get so used to looking at the Arduino board.

/*
50A Current Sensor(AC/DC)(SKU:SEN0098) Sample Code
This code shows you how to get raw datas from the sensor through Arduino and convert the raw datas to the value of the current according to the datasheet;
Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing) is used to make the outputting current value more reliable;
Created 27 December 2011
By Barry Machine 
www.dfrobot.com
Version:0.2
*/
/*
Regarding Sensitivity:
The equation (readings[index] = (readings[index]-510)*5/1024/0.xxx-0.xxx;  ,requires that you input the sensitivity
for your particular current sensor in millivolt. These Sensitivity values can
be found in the Allegro ACS758 Data Sheet pg 2 ,or in the selection giude.
just note wheter or not your Sensor is uni or bi directional.
*/
#include <LiquidCrystal.h>
 LiquidCrystal lcd(2,3,4,5,6,7);

int RawData = A0;
const int numReadings = 30;
float readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
float total = 0;                  // the running total
float average = 0;                // the average

float currentValue = 0;

void setup()
{
  Serial.begin(57600);
  lcd.begin(20, 4);
   lcd.clear();
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;       
}
void loop()
{   
    total= total - readings[index];          
    readings[index] = analogRead(RawData); //Raw data reading
    readings[index] = (readings[index]-508.96)*5/1024/0.0133-0.0133;//Data processing:510-raw data from analogRead when the input is 0; 5-5v; the first 0.0133-0.0133V/A(sensitivity); (the second 0.04???WTF!!)-offset val;
    total= total + readings[index];       
    index = index + 1;                    
    if (index >= numReadings)              
      index = 0;                           
    average = total/numReadings;   //Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing)    
    currentValue= average;
    Serial.println(currentValue);
    lcd.setCursor(0,1);
   lcd.print(currentValue);
   lcd.setCursor(10,1);
   lcd.print("     AMPS  ");
    delay(30);
}

I understand about the current,I was just thinking Dc current goes that way, I’ll admit to testing exactly as you say and the other way , It worked both ways just as its supposed to be able to do… so I changed it back.

4 ) I am very interested in your current sensor board. The design of the copper traces is a big deal, some are badly designed. The newer ones seem to be better.
I got it on Ebay.

This one is sensitive around Magnets, I used a small fridge magnet to manipulate the readings , Had to be close ,I didnt want to use my #5lb pickup tool ,thought I might really screw something up. For testing ,I made up a short patch cord out of 10ga wire.Its less than 2ft, to test motors,get the meter close to the source,everything after that is load. For testing I have a few 12v 100watt halogen bulbs, They draw about 6 amp each. I tried with motors ,but EMF was bad enough on my ICL7106 ammeter…I elected to scavenge a few bulbs…quiet to…

I got rid of the pot in the divider. I then came across a note for the 328pa , advising not to use a high impedence sources.So I got rid of the pot and set my resistor’s R1 4.3K and R2 1k I’ll measure them out and adjust in the software.

I added a 100Uf Cap on the regulator ,and added a note to use a heat sink, its not the load ,but the difference in potential that got me thinking ,it may get hot on a 22v lipo system.

I will difinetly experiment with the sample cycles as you suggest.

Do you really think I should lose the Zeners?

Thanks for your help!

Keep the zener diodes. That is a simple and good solution. The pins of the Arduino can have 1mA overflow current. So it is possible to design a circuit without the zener.

The 7805 needs two 100nF (0.1 uF) capacitors. One at the input to ground and one at the output to ground.
They have to be close the 7805.
If you omit them, the 7805 could give noise, start oscillating, and do al kind of crazy things.

For an analog input it is a rule of thumb to have a circuit that has an impedance of 10k or below.
You have now 4k3 and 1k (measuring 0 to 26.5V).
You could also use 47k and 10k (measuring 0 to 28.5V).
To measure a battery of 27V I would use a much larger range. For example with 33k and 4k7 (measuring 0 to 40V).
I like to see when something is wrong, or overcharging, or something else.

I don't know why you use an array. Is that for a 'walking' average ?

You changed the Arduino board into a stand-alone microcontroller.
The crystal needs two 22pF to ground.
The microcontroller needs 100nF decoupling between 5V and GND.

The input voltage for the 7805 can be up to 35V, so the 27V is okay, but it will get hot. The background of the LCD draws some current.
If it gets too hot, you might have to look at a DC-DC converter.

So I had it all wrong ,the divider does not have to have both resistances less than 10k ,as long as R2 to ground is less than 10k?

I hit a snag ,Cant for the life of me find a 43k resistor..

I im a victim of my own habits, and I dont have a scope, I thank you for your input on the capacitors for the regulator.I forget that MCU's can be vulnerable , not to mention the sensor would probably behave erratic .

Ive revised the schematic.

I think I have it now,

I would like to see a decoupling capacitor of 100nF next to the ATmega chip between 5V and GND.
There is already one in the 5V next to the 7805, but there should be another one next to the ATmega chip to decouple the 5V.

Please add also a 100nF at AREF and ground. It will improve the accuracy of the analog value.
When I didn't use that in a circuit, I use 3 times more samples for the average.

The way you have drawn the picture of the ACS712, I think a positive current will cause a lower output.
It is not a problem, you can fix that in software.

My LCD backlight has a 220 ohm resistor. That was bright enough. You have to test yourself if that 100 ohm is okay for you.

I wrote about the zener diodes before. Sorry if that was confusing. This time I do it right.
The zener diodes are 4.7V. That means you don't have the full range anymore of 0...5V.
The datasheet of those zener diodes shows that at 1mA the voltage could be 0.8 * 4.7V = 3.76V
The zener diode starts conducting and generating noise at 3.76V and that voltage is lower with higher temperatures.
The ACS712 can not output more than 5V. Remove that zener diode. You can keep the 470 ohm protection resistor.
The 47k/10k voltage divider can put 0.5mA into the ATmega chip. For example if the 10k resistor breaks. That 0.5mA is allowed as far as I remember. So please remove also that zener diode. Keep that 470 ohm protection resistor.
You can make me happy by using 56k and 10k for a range of 0 to 33V.

The impedance of the analog circuit is not just the 10k to ground. It is the whole circuit.
Suppose you have 47k and 10k, without zener diode, but with the 470 ohm. And the battery has and internal resistance of 0.1 ohm, but that is further reduced by the capacitor to 0.01 ohm.
The impedance at A4 will be: ((47k + 0.01) parallel 10k) + 470 = 8k7

Your right about the Zener Diode's , That part number came up in Fritzing as a 5.1 volt diode.

I'll fix it. 1N4733A

That is a 5.1V zener. I have seen that in many other schematics on the internet, but that doesn’t mean that it is good.
I stick to my explanation in my previous post.
The zener starts conducting with very low currents at 0.8 * 5.1 = 4.08 (lower at higher temperatures).
You are using it with analog input, and that 5.1V zener is also not good in this situation.

I think I have it now. Math wasnt my strong suit ..

Im getting this laid out.. I double checked the current sensor and it checks out with two other meter's , on paper the math works ,as well
The spec for this sensor is 13.3mv/Amp
At rest it reads 2.491V
apply current 2.567V
difference 0.076mv

0.076 / 0.0133 = 5.714 Amp.

This project is evolving .
with the addition of both and infrared tachometer and temperature meter . this would be a module that will plug into the Power meter. A laser pointer may be added to pin point an area ,but like a rifle scope it will have to be adjusted in. that will require patience and a very focused point of heat to dial it all in.
The user can then determine power ,rpm and temperature.
I am ,whats called in the scale model industry , “Kit Bashing” Arduino code. Essentially you take a box of various parts ,assemble them into a presentable creation…

/*
Regarding Sensitivity:
The equation (readings[index] = (readings[index]-510)*5/1024/0.xxx-0.xxx;  ,requires that you input the sensitivity
for your particular current sensor in millivolt. These Sensitivity values can
be found in the Allegro ACS758 Data Sheet pg 2 ,or in the selection giude.
just note wheter or not your Sensor is uni or bi directional.
*/
#include <LiquidCrystal.h>
 LiquidCrystal lcd(2,3,4,5,6,7);
 int val;
long last=0;
int stat=LOW;
int stat2;
int contar=0;

int sens=75;  // this value indicates the limit reading between dark and light,
              // it has to be tested as it may change acording on the 
              // distance the leds are placed.
int nPalas=2; // the number of blades of the propeller

int milisegundos=500; // the time it takes each reading

int RawData = 0;
const int numReadings = 30;
float readings[numReadings];      // the readings from the analog input
int index = 0;                // the index of the current reading
float total = 0;                  // the running total
float average = 0;                // the average

float currentValue = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  lcd.begin(20, 4);
   lcd.clear();
  for (int thisReading = 0; thisReading < numReadings; ++thisReading)
    readings[thisReading] = 0;       
}
void loop()
{     // read the input on analog pin 3:
   int sensorValue = analogRead(A3);
   // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
   float voltage = sensorValue * (5.0 / 1023.0);
   // print out the value you read:
   Serial.println(voltage);
 
 
 
 
 
  
    total= total - readings[index];          
    readings[index] = analogRead(RawData); //Raw data reading
    readings[index] = (readings[index]-510)*5/1024/0.0133-0.0133;//Data processing:510-raw data from analogRead when the input is 0; 5-5v; the first 0.04-0.04V/A(sensitivity); the second 0.04-offset val;
    total= total + readings[index];       
    index = index + 1;                    
    if (index >= numReadings)              
      index = 0;                           
    average = total/numReadings;   //Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing)    
    currentValue= average;
    Serial.println(currentValue);
    lcd.setCursor(0,0);
   lcd.print("A ");lcd.print(currentValue);lcd.print("  V ");lcd.print(voltage);
  
   
    delay(30);
 val=analogRead(0);
  if(val<sens)
    stat=LOW;
   else
    stat=HIGH;
   digitalWrite(13,stat); //as iR light is invisible for us, the led on pin 13 
                          //indicate the state of the circuit.

   if(stat2!=stat){  //counts when the state change, thats from (dark to light) or 
                     //from (light to dark), remmember that IR light is invisible for us.
     contar++;
     stat2=stat;
   }
   if(millis()-last>=milisegundos){
     double rps=((double)contar/nPalas)/2.0*1000.0/milisegundos;
     double rpm=((double)contar/nPalas)/2.0*60000.0/(milisegundos);
     Serial.print((contar/2.0));Serial.print("  RPS ");Serial.print(rps);
     Serial.print(" RPM");Serial.print(rpm);Serial.print("  VAL ");Serial.println(val);
     contar=0;
     last=millis();
    
     
     lcd.setCursor(0,1);
     lcd.print("RPM ");lcd.print(rpm);
   }

}

I hope you don't mind, but please be more accurate with the code layout. Use the same indents and same style everywhere. That would make it better to read.

You still have a zener in a high (10k) impedance circuit. That will make the analog reading inaccurate.

Do you use the MLX sensor with I2C? and you use pin A2 and A3 for that ?

Please understand I am a novice .Your suggestions and comments are not falling on deaf ears ,and you input is greatly appreciated. My previous experience with code was on a Tandy Color Computer3 …back in 1986…then on a Commodore computer in high school , 5in floppys …those were the day’s…
I think Ive cleaned it up a bit.
Your pretty sharp…I will loose the zener…I forgot about it.
Im awaiting the infared sensors.so untill I actually have them in my hand , and can bread board them,I’m winging the proposed connection’s via source’s on the net…I really need to sit down with the data sheets .I think it would be best to have the parts so I dont get any more confused than I am.

/*
Regarding Sensitivity:
The equation (readings[index] = (readings[index]-510)*5/1024/0.xxx-0.xxx;  ,requires that you input the sensitivity
for your particular current sensor in millivolt. These Sensitivity values can
be found in the Allegro ACS758 Data Sheet pg 2 ,or in the selection giude.
just note wheter or not your Sensor is uni or bi directional.
*/
 #include <LiquidCrystal.h>
 LiquidCrystal lcd(2,3,4,5,6,7);
 int val;
 long last=0;
 int stat=LOW;
 int stat2;
 int contar=0;

 int sens=75;  // this value indicates the limit reading between dark and light,
              // it has to be tested as it may change acording on the 
              // distance the leds are placed.
 int nPalas=2; // the number of blades of the propeller

 int milisegundos=500; // the time it takes each reading

 int RawData = 0;
 const int numReadings = 30;
 float readings[numReadings];      // the readings from the analog input
 int index = 0;                // the index of the current reading
 float total = 0;                  // the running total
 float average = 0;                // the average
 float currentValue = 0;

  void setup()
  {
  Serial.begin(9600);
  pinMode(13,OUTPUT);
  lcd.begin(20, 4);
   lcd.clear();
  for (int thisReading = 0; 
  thisReading < numReadings;
  ++thisReading)readings[thisReading] = 0;  
    }
    void loop()
   {     // read the input on analog pin 3:
   int sensorValue = analogRead(A3);
   // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
   float voltage = sensorValue * (5.0 / 1023.0);
  
   Serial.println(voltage);   // print out the value you read:
   
   total= total - readings[index];          
    readings[index] = analogRead(RawData); //Raw data reading
    readings[index] = (readings[index]-510)*5/1024/0.0133-0.0133;//Data processing:510-raw data from analogRead when the    input is 0; 5-5v; the first 0.04-0.04V/A(sensitivity); the second 0.04-offset val;
    total= total + readings[index];       
    index = index + 1;                    
    if (index >= numReadings)              
      index = 0;                           
    average = total/numReadings;   //Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing)    
    currentValue= average;
    Serial.println(currentValue);
    lcd.setCursor(0,0);
   lcd.print("A ");lcd.print(currentValue);
   lcd.print("  V ");
   lcd.print(voltage);
  delay(30);
  val=analogRead(0);
  if(val<sens)
    stat=LOW;
   else
    stat=HIGH;
   digitalWrite(13,stat); //as iR light is invisible for us, the led on pin 13 
                          //indicate the state of the circuit.

   if(stat2!=stat){  //counts when the state change, thats from (dark to light) or 
                     //from (light to dark), remmember that IR light is invisible for us.
     contar++;
     stat2=stat;
   }
   if(millis()-last>=milisegundos){
     double rps=((double)contar/nPalas)/2.0*1000.0/milisegundos;
     double rpm=((double)contar/nPalas)/2.0*60000.0/(milisegundos);
     Serial.print((contar/2.0));Serial.print("  RPS ");Serial.print(rps);
     Serial.print(" RPM");Serial.print(rpm);Serial.print("  VAL ");Serial.println(val);
     contar=0;
     last=millis();
    
     
     lcd.setCursor(0,1);
     lcd.print("RPM ");lcd.print(rpm);
   }}

Changed it.!

What about the MLX sensor and I2C ?
Do you want to use that sensor with the I2C mode ?
If so, you need the A4 (SDA) and A5 (SCL) pins.

Quite honestly Im not up to speed on this sensor. Im still reading and coming up to speed on I2C.
However I will not dismiss your assessment. I'll keep it in mind.

I have question ,Im a bit boggled with the voltage divider. I used a seperate 9v battery as the source to be calculated.

This line as is returns a negative value in the serial monitor voltage = (voltage / 1024) * 5.0;
To return a positive value I had to change it to voltage = (voltage / -1024) * 5.0;
first I thought I had the polarity reversed,That didnt work,
the ground from the divider is bonded with the Arduino.
A mistake in the code maybe?

You mentioned making up the differential voltage of the divider by maniplulating the software.Im assuming this meant adjusting the resistor value (R1)until the readings match. This makes sense my voltmeter or any off the shelf meter will have variances when reading resistance.
The code below returns the readings that match my voltmeter"s(I used three and took an average), an the correct polarity.

//Analog volt read pin

const int voltPin = 0;

//Variables for voltage divider

float denominator;

int resistor1 = 32075;

int resistor2 = 4700;

void setup() {

  Serial.begin(9600);
  //Convert resistor values to division value
  //  Equation is previously mentions voltage divider equation
  //  R2 / (R1 + R2)
  //  In this case returns 0.20 or 1/5
  denominator = (float)resistor2 / (resistor1 + resistor2);
} // Void Setup Close

void loop() {

  float voltage;
  //Obtain RAW voltage data
  voltage = analogRead(voltPin);
  //Convert to actual voltage (0 - 5 Vdc)
  voltage = (voltage / -1024) * 5.0;
  //Convert to voltage before divider
  //  Divide by divider = multiply
  //  Divide by 1/5 = multiply by 5
  voltage = voltage / denominator;
  //Output to serial
  Serial.print("Volts: ");
  Serial.println(voltage);
  //Delay to make serial out readable
 delay(50);
} // void loop close

With the negative sign, you have a calculation that no one understands anymore. If no one understands it, you might as well delete it.

I prefer myself to use more variables and more code lines.
The source code is only to make it better to understand. The compiler will probably compile it into the same fast code anyway.
The example below is not even over the top, it's just a good way to write code in my opinion.

  // Caltoa wants more variables and more code lines, code not tested.

  //Obtain RAW ADC value of 0...1023
  int rawADC = analogRead(voltPin);

  //Convert to actual voltage at the Arduino pin (0 - 5 Vdc)
  float voltageAtPin = (rawADC / 1023.0) * 5.0;

  // Convert to voltage using the voltage divider
  // Using 33k and 4k7, the multiplier is (33k+4k7)/4k7 = 8.02
  // After testing it with a multimeter, it might need a little correction.
  float voltageBattery = voltageAtPin * 8.02;

  //Output to serial
  Serial.print("Battery = ");
  Serial.print(voltageBattery);
  Serial.println(" V");