I have a Nano board, which is fed from an external power source. It is getting 24V supplied to it. It is supposed to be 10V powered via an LM317, but on power up the trimpot controlling the LM317 is sometimes set to full 24V!!. I need to measure the supply voltage, and blink the on-board LED if it is not within the correct range, as a warning, so the voltage gets adjusted pronto..
Is there any way to retrieve the supply voltage and use it in the code?
I don't seem to have found it anywhere, and I suspect it's not supported.
The easy and obvious way is to use a potential divider, as shown here. To measure it using the "internal" reference you would need to choose suitable resistors.
However the nano has a limit of 7 -12V at its Vin pin; so maybe you would be better advised to redesign your power supply to prevent over-voltage?
1. Without giving any power, make the following setup as per Fig-1.
Figure-1:
2. Disconnect A5, Vin, and GND wires from NANO.
3. Connect DVM across 1uF capacitor of power supply.
4. Adjust 5k pot until you get 12 V reading on DVM.
5. Using DVM, measure voltage at the tap-point of R2-R1 network and record. This value is to be entered in the while() loop of the sketch of Step-6.
6. Upload the following sketch on NANO to monitor the Vin voltage on L (the built-in LED of NANO).
#define L 13
void setup()
{
Serial.begin(9600);
pinMode(L, OUTPUT);
}
void loop()
{
while ((5.0 / 1023.0)*analogRead(A5) <= 3.83) //change 3.83 to the DVM reading
{
digitalWrite(L, HIGH);
}
while ((5.0 / 1023.0)*analogRead(A5) > 3.83) //chnage 3.83 to the DVM reading
{
digitalWrite(L, LOW);
delay(300);
digitalWrite(L, HIGH);
delay(300);
}
}
7. Remove PC connection fron NANO.
8. Connect NANO's Vin-pin and GND-pin with 12 V supply.
9. Connect the tap-point with A5-pin of NANO.
10. Press RST Button of NANO. Check that L (Built-in LED of NANO) is ON indicating that Vin is <=12V.
11. Connect DVM across Vin and GND.
12. Slowly turn 5k pot so that Vin goes to about 12.5/13V. Check that L blinks.
13. Bring Vin back to 11.0V/12.0V. Check that L remains turned on instead of blinking.
@GolamMostafa Why do you support the very bad idea to feed 12V to VIN to power the Arduino?
@wiresplus redesign the power supply to generate 5V and feed that to the 5V pin.
For reprogramming via a normal USB cable, you would have to disconnect it,
or use an USB cable with a cut/switched 5V line.
Engineers have the priveleges of acquiring experiences by destroying prototypes in the course of experiments. Let the @wiresplus play around. He has asked for a voltage monitoring system and hope that he has got it.
What @GolamMostafa said. I know I'm outside the normal use case for Arduino. it's in an Industrial Automation setting.
I actually want 10V at VIN. If it's more than 10V, I want the LED to blink, so that I can commission it on site without a multimeter etc.
I had one that had the LM317 fail, and feed 24V to VIN. Funny, but the wispy smoke stuff came out and then the darn thing won't work....
Thanks @johnerrington those are some good references. I wish I could choose two solutions to give kudos to both helpers. Your answer article is more in depth, but @GolamMostafa put the answer up on here for everyone, so I'm torn on who gets the green tick . Kudos to you both anyway.
Why do you want to burn 5V*consumtionOfArduinoAndAttachedStuff W
by the tiny regulator on the Nano?
If that thing overheats, it shuts down. Gives a nice intermittent failure, I would try to avoid.
Lots of Industrial stuff uses 0-10V, and this Nano reads the 0-10V signal and performs actions based on the voltage. As the Ref volts at A0 cannot be more then VIN, VIN has to be 10V But you do have valid points and I'm not ignoring your advice.
Or, am I wrong?
No. vREF may not be higher than the supply voltage, which is 5V.
VREF Reference Voltage 1.0 - AVCC V
How many Nanos have you killed until now?
Only the one. All the others (30 odd) are fine
And you apply 10V to the AREF pin?
Or were you just thinking it were related to VIN in some way?
My bad. I edited that out again. Not vREF sorry. A0.
And you apply 10V to A0?
Just don't do that, but use a voltage divider to bring the voltage down to the allowed range.
A0 gets a 0-10V signal, and converts it to binary for use elsewhere
It's been going fine so far.. should it not have?
There seems to be too much resistance in the connection to burn the pin directly.
I hope these are not controlling/measuring something important.
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.