Using external power for a circuit and measuring a signal using analog pins returns zero?

void setup(){
  Serial.begin(9600);
}

void loop(){
  int raw_in = analogRead(A1);
  float V_in = raw_in * (0.00488);
  Serial.println(raw_in);
  Serial.println((String)"In: " + V_in);
  delay(1000);
}

I am trying to measure an output current for an external DC source for which I am trying to measure the voltage using an analog pin. But the pin is reading zero value. I have attached the circuit diagram, and code here. I am beginner in arduino and electronics, please let me know what I am missing.

P.S - In image I have shown wrong position for A1, but on circuit I have made all the connections correctly.

The image shows the positive of the source being connected to Arduino GND... this will cause A1 to always negative.
Positive of source should go to R1.

so my source arrangement should be reversed? I have always thought current goes from negative to positive. That's why I have made this arrangement.

The international convention is that current flows from positive to negative. You may have damaged the analog input pin.

Note: negatively charged electrons flow from negative to positive, but the convention assumes positive current.

1 Like

Maybe a bit more clear: The convention assumes positive charge to move from plus to minus.

1 Like

If you think the direction of the current matters, then you are not understanding how electricity works.

It maters not which convention you use but you have to be consistent. So best to use conventional current where the current flows from the positive to the negative.

In the days before scientists knew about electrons they did know about electro plating. So they defined voltage negative as the place where the copper plating ended up and the positive where the copper came from. So the transfer between the copper in the anode onto the negative cathode.

It was a good guess but it was wrong. Rather than change things over they then invented the idea of conventional current, which almost everyone in the electronics industry uses.

It is only when dealing with solid state physics that you need to consider that normally charge is carried by electrons. However, in some materials the absence of an electron is the majority carrier of charge, it is called a hole, and can be treated as a positive charge. Holes remarkable can have a positive mass, in certain circumstances, meaning that electrons can have a negative mass.

However electronics is like an onion, you only need to know about the layer where things are relevant and important. So in the world you are in at the moment, then apply a conventional current flow.

A few more points here. Current flow aside and well covered. Your voltage source appears to be 1.5 volts so assuming an Arduino Uno (you never mention which Arduino? Next assuming an Arduino Uno using the 5 volt reference since you never call out an Internal or External reference you have about a 1000:1 voltage divider. With 1.5 volts applied to your divider you input voltage to A0 will be about 1.49850 volts. You have a 10 bit ADC in your Arduino so you get 0.0 to 5.0 volts becomes 0 to 1023 bits. Resolution is about 4.88 mV. Then in your code you multiply the raw in by 0.00488. I don't quite understand what your objective here is? I get the 0.00488 as the mV step resolution but not as it's applied here.

Measuring a voltage and assuming a perfect 5.00 volt reference I would expect to see:

  value = analogRead(A0);
  voltage = value * (5.0/1023) * ((R1 + R2)/R2);

R1 being the top resistor in your divider. Now less a divider I would expect to see:

   int analog_value = analogRead(A0);
   input_voltage = (analog_value * 5.0) / 1024.0; 

What exactly is what you want to do? Since you mentioned measuring current:

Measure current based on the voltage drop across a one ohm resistor?

Ron

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.