Hello , Is it possible to get current value from voltage sensor? I try to set up variable float for current because i think ( if im not wrong ) just by dividing the voltage obtained from arduino divide by the resistors 30k and 7.5k could get it done but when i open serial monitor it still shows zero.Can someone please explain why this happens and how to fix this? do i need to use current sensor also? sorry for my bad english and Thank you
int analogInput = A1;
float vout = 0.0;
float vin = 0.0;
float current = 0.0;
float power = 0.0;
float R1 = 30000.0; //
float R2 = 7500.0; //
int value = 0;
// read the value at analog input
value = analogRead(analogInput);
vout = (value * 5.0) / 1024.0; // see text
vin = vout / (R2/(R1+R2));
current = vin / (R1+R2);
power = vin * current ;
Can you please post a circuit diagram, showing your input circuit and power supply?
Please not a Fritzy image, a picture of a hand drawn schematic will be fine.
Please include pin labels and component names.
The current that you are calculating, is in fact the current that is been drawn by your 'voltage sensor'. This is not the current being drawn by whatever your load is.
The voltage sensor is purposely made so that it only draws a small current, so that it does not load the circuit under test.
If the input voltage is 25V (maximum it can be to give 5V on the analogue input) then the current is only 0.667mA, or 0.000667A. (= 25 / 37500)
Because you are calculating it in amps, and only displaying 2 decimal places then this gets rounded down to zero.
As has already been said you need a dedicated current sensor to measure the current being drawn by your load.