Notifications
Clear all

Powering Arduino through Vin and 5V pin.

68 Posts
3 Users
34 Likes
904 Views
mrbond007
(@mrbond007)
Eminent Member
Joined: 5 months ago
Posts: 34
Topic starter  

I'm using Arduino Uno for the project.

I'm working on implementing an Arduino project, which alerts a user with SMS if there is a power failure and once again after the power is restored. I have made some changes to the project according to my needs. I will power the GSM900A module using a medium-sized UPS, which I use to power my networking equipment in case of power instead through Arduino. I have a few queries regarding the project. The author has powered Arduino using a 12V battery through a 5V pin by reducing the voltage. Instead of the 5V pin can I use Vin pin for battery input? To accept Mains power (through AC-DC Adapter of proper rating) through pin 2 author used the below command. How much voltage can I provide to the pin without damaging the board?

 pinMode(2,INPUT);

The author used resistors to divide the 12V and provided it to pin 2. Can I use DC voltage regulator IC instead?

What if I use an AC-DC Adapter which provides 5V-1A of DC supply to power pin 2? 

Is it necessary to add a Diode between the battery and any pin of Arduino which accepts power supply?

Shall I ground the negative terminals of the DC power sources?

The link to the original project is attached below. Please guide. Thank you.

https://create.arduino.cc/projecthub/mbraccagni/mains-failure-detector-7e8b2c


   
Quote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4001
 

First, make sure ALL grounds are connected together. There are several ways to power an UNU. The 2.1mm jack is a popular way to provide power.

For specific answers, goto Arduino.cc Hardware UNO and look down the left side for various docs. I have included one such doc that may get you started.

Note that in your example the 5V pin is being used for INPUT, the doc I attached from Arduino specifically says that is a no no. Power in is either USB or the 2.1mm jack, or VIN.

Screen Shot 2022 09 29 at 08.25.44

 

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
mrbond007 reacted
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4001
 

The author used resistors to divide the 12V and provided it to pin 2. Can I use DC voltage regulator IC instead?

There are 2 PIN 2's, I assume he is using the IOREF pin. Leave it the way he designed it.

What if I use an AC-DC Adapter which provides 5V-1A of DC supply to power pin 2? 

Power is supplied to USB, 2.1mm jack, and only one pin, VIN.

Is it necessary to add a Diode between the battery and any pin of Arduino which accepts power supply?

The only pin that accepts power suply is VIN and the diode is already on the board

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
mrbond007 reacted
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4001
 

I don't have fancy drawing tools but I managed to cobble this together. You can use his schematic as is IF you add 1 more blocking diode. It may be that the UNO already has an interior diode, but based on the arduino docs I have seen it appears to NOT so add it where shown.

I think you might have missed the point of some of the components, the 9V battery is backup to the 12V jack input. This is a common design when you want to make sure power remains when unplugging.

Screen Shot 2022 09 29 at 08 45 05

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
mrbond007 reacted
ReplyQuote
DaveE
(@davee)
Noble Member
Joined: 2 years ago
Posts: 796
 

Hi @mrbond007,

  I fear there are opportunities for misunderstandings.  I would have liked to see a sketch of the circuit you intend to build,  as what you are proposing is substantially different from the reference you provide, and it would have been much clearer.

However, my concerns are even greater now that I have seen the circuit in the reference you quoted:

image

This shows the output of diodes D1 and D2 connected to the 5V input of the Uno and heading off to the GPRS module.

The voltage at the output of these diodes would be about 11.5V if the 12V is present, and about 9V from the battery if the 12V was supply was absent.

------------------------

The maximum voltage that should be applied to the 5V pin of an Arduino board is ... 5V ... not 9-12V!

----

You do not supply details of the GPRS, beyond "GSM900A" ... I found

https://www.electroniclinic.com/gsm-sim900a-with-arduino-complete-guide-with-gsm-based-projects-examples/

which provides some details of a module with the Sim900A chip onboard.

Somewhat worryingly (to me), the SIM900A chip seems to be specified as requiring a supply in the range 3.4V-4.5V .... and the article says there is no regulator on board ... but suggests it will work with a 5V supply. Obviously, all real devices will work with a voltage 'slightly' higher than the spec, but doing so may shorten its life! I'll leave it to you to decide if 5V is 'close enough' ... if it was my project, I would be looking for a 4.5V supply...

----------------

So we have a schematic circuit that will deliver 9-12V to a Uno expecting 5V, and a GSM exepcting 3.4V-4.5V   ... magic smoke seems to be the most likely prognosis!

----------------

Perhaps the author of the schematic meant to use the Vin on the UNO and the 5V output to the GPRS.

----------------

You say you intend to use a UPS to power the GSM module ... but assuming the UPS output is mains, not how it connects to the GSM module.

Plus you need to detect when the mains has failed..

-----------------

I can visualise some possibilities to get around these queries, but as it is your project, I would be more comfortable if you designed it ... and when you have drawn up an accurate schematic of what you intend to build, please post it to the forum for comment if you wish.

Good luck with your project ... I wish you well, Dave


   
mrbond007 reacted
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4001
 

@davee Dave, I think you need to update your specs. D1 and D2 do NOT go to the VIN pin which is beside the 5V output pin. This device is erroneously connected to without a diode. Get a magnifier and you will see VIN beside the A in Arduino UNO/NANO/MINI. The arduino.cc hardware page for UNO has it in writing, power comes in at USB (5V), DC power jack (5V-12V) or the VIN pin (5V-12V)

To quote Arduino

Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
mrbond007 reacted
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4001
 

@davee I forgot to mention, another diode is needed on the 5V pin to prevent back feeding from D1 and D2. See my earlier post.

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
mrbond007 reacted
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4001
 

@mrbond007 FYI @davee Perhaps it will help if you think of the GPRS power coming from one of 3 places, the power jack via D2, the 9V battery via D1, and the 5V pin via the new diode.

NOTE My post has the diode backwards

https://forum.dronebotworkshop.com/postid/34347/

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
mrbond007 reacted
ReplyQuote
mrbond007
(@mrbond007)
Eminent Member
Joined: 5 months ago
Posts: 34
Topic starter  
Posted by: @zander

Note that in your example the 5V pin is being used for INPUT, the doc I attached from Arduino specifically says that is a no no.

Instead now I will use vin to take input from the battery. 


   
ReplyQuote
mrbond007
(@mrbond007)
Eminent Member
Joined: 5 months ago
Posts: 34
Topic starter  
Posted by: @zander

Power is supplied to USB, 2.1mm jack, and only one pin, VIN.

But in code the author has used pinmode command to take input at pin 2


   
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4001
 

@mrbond007 I assume that the project you referenced is very different from yours. What is powering the UNO?

 

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
mrbond007 reacted
ReplyQuote
Ron
 Ron
(@zander)
Famed Member
Joined: 2 years ago
Posts: 4001
 

@mrbond007 I should have checked re your noobiness. Pin 2 is an input, it is used to determine if power is applied at the power jack (2.1mm). It is a signal line, not a power line.

Pin 2 is the heart of the system. If pin 2 is low then mains power is off. Look at the loop, it is all about the state of Pin 2 then look at the comment at line 32 just before the pinMode(2, INPUT). It says 

// Set pin 2 as input for Vin detection

That voltage divider pin 2 is connected to is onlyh across what he erroneously calls VIN as it is in reality PowerJackIn.

 

Arduino says and I agree, in general, the const keyword is preferred for defining constants and should be used instead of #define
"Never wrestle with a pig....the pig loves it and you end up covered in mud..." anon
My experience hours are >75,000 and I stopped counting in 2004.
Major Languages - 360 Macro Assembler, Intel Assembler, PLI/1, Pascal, C plus numerous job control and scripting


   
mrbond007 reacted
ReplyQuote
mrbond007
(@mrbond007)
Eminent Member
Joined: 5 months ago
Posts: 34
Topic starter  
Posted by: @davee

I fear there are opportunities for misunderstandings.  I would have liked to see a sketch of the circuit you intend to build,  as what you are proposing is substantially different from the reference you provide, and it would have been much clearer.

I have a few doubts which needs to be cleared before I make my own diagram. I will post my build in tomorrow morning. Its night here in my country. 

Posted by: @davee

The voltage at the output of these diodes would be about 11.5V if the 12V is present, and about 9V from the battery if the 12V was supply was absent.

Instead of diodes I will use resistors to drop voltage. Will this be fine? 

Posted by: @davee

The maximum voltage that should be applied to the 5V pin of an Arduino board is ... 5V ... not 9-12V!

Got it. 

Posted by: @davee

Somewhat worryingly (to me), the SIM900A chip seems to be specified as requiring a supply in the range 3.4V-4.5V .... and the article says there is no regulator on board ... but suggests it will work with a 5V supply. Obviously, all real devices will work with a voltage 'slightly' higher than the spec, but doing so may shorten its life! I'll leave it to you to decide if 5V is 'close enough' ... if it was my project, I would be looking for a 4.5V supply...

I will again add 2 more resistors between 5V and input of Gsm900A module. 

Posted by: @davee

So we have a schematic circuit that will deliver 9-12V to a Uno expecting 5V, and a GSM exepcting 3.4V-4.5V   ... magic smoke seems to be the most likely prognosis!

I will apply the battery 9V pin to Vin instead of 5V pin

Posted by: @davee

Perhaps the author of the schematic meant to use the Vin on the UNO and the 5V output to the GPRS.

Yes it could be the case.

Posted by: @davee

You say you intend to use a UPS to power the GSM module ... but assuming the UPS output is mains, not how it connects to the GSM module.

Plus you need to detect when the mains has failed..

I will use a 5V AC-DC adapter connected to UPS if further discussion points to use of this method of powering GSM Module instead from the 5V pin from Arduino

Posted by: @davee

I can visualise some possibilities to get around these queries, but as it is your project, I would be more comfortable if you designed it ... and when you have drawn up an accurate schematic of what you intend to build, please post it to the forum for comment if you wish

I will post it tomorrow morning. 

Posted by: @davee

Good luck with your project ... I wish you well,

Thanks Dave for your guidance and wishes.

@Dave


   
ReplyQuote
mrbond007
(@mrbond007)
Eminent Member
Joined: 5 months ago
Posts: 34
Topic starter  
Posted by: @zander

@mrbond007 I assume that the project you referenced is very different from yours.

No. This project stood out to me so I thought changing only a few aspects. 


   
ReplyQuote
mrbond007
(@mrbond007)
Eminent Member
Joined: 5 months ago
Posts: 34
Topic starter  
Posted by: @zander

What is powering the UNO?

According to original project the author is using 12V to pin 2.


   
ReplyQuote
Page 1 / 5