logo elektroda
logo elektroda
X
logo elektroda

Arduino Nano: Connecting Power via Mini USB or VIN & GND with a 12V Supply - Aquarium Lamp

pdzran 11433 15
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 17923588
    pdzran
    Level 13  
    Posts: 266
    Help: 2
    Rate: 20
    Hello all

    I have an Arduino Nano that controls a lamp over an aquarium and I have a question about powering the Arduino itself.
    Nano has a mini USB input and a VIN pin from the description on the net.
    How to power them? Power supplies with mini USB output are usually 5V and this is according to description is not enough, it should be 6.5-12V.
    I bought a 12V power supply but it has a round output.

    Now the question is whether I should convert the plug in the 12V power supply and power it via mini USB or cut the tip and connect to VIN and GND on the board?
  • ADVERTISEMENT
  • #2 17923605
    kaczakat
    Level 34  
    Posts: 1748
    Help: 317
    Rate: 229
    You don't have any plug on Nano, you can sacrifice a 12V power supply, after disconnecting from the socket a quick snip and enter the voltage on Vin here. 5V power supply you do the same, only you connect to USB or after cutting the plug to the 5V pin. Of course, GND to the set for GND pins. You connect only 5V to USB and of course a 500mA phone charger is enough for NANO (you can't supply more than about 200mA through the pins anyway). And if you're powering something else from it, you'll need to take that into account.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 17923614
    snow
    Level 31  
    Posts: 1825
    Help: 178
    Rate: 201
    Arduino has a VIN pin and there you can enter the voltage, e.g. 9V
  • #4 17923623
    pdzran
    Level 13  
    Posts: 266
    Help: 2
    Rate: 20
    Currently I have a better 5V power supply, will 12V under VIN give me anything compared to 5V over USB?
    I am asking because I have a DIY aquarium lamp connected, 4 channels of 3W diodes and one 1W UV channel, theoretically they have 80x3W + 8x1W in total, I give 255 PWM on each channel and the wattmeter shows only about 90-100W, the lamp is bright, even the neighbor was wondering what I have at home, the power supply for the lamp is 240W.

    Is it the fault of the 5V power supply and the PWM signal is too low despite setting the value to 255 or something else?
  • #5 17923629
    snow
    Level 31  
    Posts: 1825
    Help: 178
    Rate: 201
    Giving 12V to VIN won't result in a 12V PWM output - it will still be 5V. Devices that draw large currents are best controlled by a transistor.
  • #6 17923658
    pdzran
    Level 13  
    Posts: 266
    Help: 2
    Rate: 20
    In other words, powering Arduino 5V via USB can cause lower voltage on PWM and thus weaker LEDs?
    If replacing the 5V USB power supply with 12V VIN won't do anything, I won't mess with it.

    I didn't think about it before but I will measure the voltage on PWM.
  • ADVERTISEMENT
  • #8 17923685
    kaczakat
    Level 34  
    Posts: 1748
    Help: 317
    Rate: 229
    Whether you power the Arduino with 5V on USB or 12V on Vin does not matter for PWM, on the processor you have 5V on the power supply and 5V on the outputs anyway. It's better to give 5V, because 12V is only partly converted into heat to have 5V on the board, the more losses the more receivers and power consumption from 5V. If you have a wrongly selected transistor (if you use it), only this can have an effect, but if you have a mosfet opening at 10V, powering the Arduino with 12V will not do anything. At most, you will have such a voltage available in the area, you control the NPN transistor by giving it 12V and it will work properly. However, there are logic level mosfets (usually L in the name) that open fully already at 2V and you should aim for them.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #9 17923689
    pdzran
    Level 13  
    Posts: 266
    Help: 2
    Rate: 20
    I noticed this relationship:
    - the lamp connected to the turned off Arduino does not light up - normal, because PWM has 0;
    - the lamp connected to the turned on Arduino, either through a 5V power supply or to a laptop, shines brightly at PWM 255;
    - the lamp is connected without Arduino (the Arduino PWM pins are physically disconnected the board with the drivers, the PWM pins and of course the ground), the lamp shines much stronger;

    I am not an electronics engineer, so the question is how to connect transistors and what kind?
  • #10 17923701
    kaczakat
    Level 34  
    Posts: 1748
    Help: 317
    Rate: 229
    But it doesn't have to be PWM, if you want to give a 100% signal for comparison, you can just put one digitalWrite() on the pin and you have a certain 100% filling, then when it shines, measure it with a meter, wattmeter, energy consumption will be proportional, senses they can be unreliable.
    Helpful post? Buy me a coffee.
  • #11 17923719
    pdzran
    Level 13  
    Posts: 266
    Help: 2
    Rate: 20
    Dusk and dawn and they work fine, quite smoothly, one blue channel remains for the night and PWM 1 or 2 on it, my consumption is low, I don't remember how much but something about 2-4W, when I do dawn, i.e. PWM 255, it is bright and power suits me, but the wattmeter shows the mentioned 90-100W.
  • #12 17923725
    snow
    Level 31  
    Posts: 1825
    Help: 178
    Rate: 201
    The PWM signal is best viewed on an oscilloscope. If the lamp shines brighter without PWM control than when PWM is set to 100%, it means that there is something wrong with the current efficiency of supplying this lamp with PWM power.
  • #13 17923744
    pdzran
    Level 13  
    Posts: 266
    Help: 2
    Rate: 20
    I'll measure something more today and post it here, I don't have an oscilloscope.
  • #14 17924123
    snow
    Level 31  
    Posts: 1825
    Help: 178
    Rate: 201
    The only thing you can measure is whether PWM 100% you have 5V on the output.
  • #15 17924132
    pdzran
    Level 13  
    Posts: 266
    Help: 2
    Rate: 20
    That's what I want to do, because I suspect that the power supply may be to blame and if it does not give 5V, it may be less at PWM.
    I will measure today and possibly replace the power supply with 12V under VIN.

    Added after 2 [hours] 25 [minutes]:

    I measured and it turned out that the voltage at PWM 255 is 4.77 V and now it's a strange thing, I changed the power supply to 12V and on the same pin it is now 4.98 V, so it's good, the lamp looks brighter and the wattmeter still shows the same, i.e. 98 W.
    Is there any explanation for this?
  • #16 17935191
    snow
    Level 31  
    Posts: 1825
    Help: 178
    Rate: 201
    Any layout diagram? Maybe it's not the fault of the PWM but the system.

Topic summary

✨ The discussion revolves around powering an Arduino Nano for controlling an aquarium lamp. The user inquires about the appropriate method to supply power, noting that the Nano has a mini USB input and a VIN pin, with a preference for a 12V supply. Responses clarify that the Arduino can be powered via the VIN pin with 6.5-12V, while the mini USB typically provides 5V. It is suggested that using a 12V supply connected to VIN is preferable for higher current applications, but the PWM output remains at 5V regardless of the input voltage. The user experiences issues with LED brightness and suspects the power supply's voltage may be affecting PWM performance. Measurements indicate that switching to a 12V supply improved the PWM output voltage slightly, leading to brighter lamp performance, although the wattmeter readings remained consistent. The discussion emphasizes the importance of using transistors for controlling high-current devices and suggests measuring PWM output for troubleshooting.
Generated by the language model.

FAQ

TL;DR: For Arduino Nano LED control, power source choice doesn't change 5 V PWM; "does not matter for PWM." Logic‑level MOSFETs can fully turn on near 2 V. Use USB 5 V for efficiency; VIN adds heat from the regulator. [Elektroda, kaczakat, post #17923685]

Why it matters: This helps DIY aquarium‑lamp builders avoid dimming and overheating while wiring Nano power and PWM drivers.

Quick Facts

  • VIN recommended input is typically 7–12 V; the onboard linear regulator drops everything to 5 V. [Arduino Nano Tech Specs]
  • PWM outputs remain 5 V logic whether you power via USB or VIN; PWM is not 12 V. [Elektroda, snow, post #17923629]
  • Per‑pin current: 20 mA recommended, 40 mA absolute max; excess load sags voltage and risks damage. [ArduinoPinCurrentLimitations]
  • Measured in thread: 4.77 V at PWM 255 on USB vs 4.98 V on VIN; lamp still ~98 W. [Elektroda, pdzran, post #17924132]
  • “There are logic level mosfets … that open fully already at 2V”; pick logic‑level parts. [Elektroda, kaczakat, post #17923685]

Can I power an Arduino Nano via mini USB or VIN for PWM LED control?

Yes. PWM output stays 5 V logic regardless of USB 5 V or VIN input. Use USB 5 V when possible to reduce regulator heat. Using VIN is fine within spec, but it will not boost PWM amplitude. Select the input based on thermal budget and wiring convenience. [Elektroda, kaczakat, post #17923685]

Will 12 V on VIN make PWM 12 V or brighten my LEDs?

No. VIN at 12 V does not change PWM to 12 V; PWM remains a 5 V logic signal. Drive high‑current LEDs with a transistor or MOSFET, not directly from the pin. “Devices that draw large currents are best controlled by a transistor.” [Elektroda, snow, post #17923629]

What VIN voltage is safe, and when should I prefer USB 5 V?

Typical VIN is 7–12 V. The linear regulator drops VIN to 5 V, creating heat. Prefer USB 5 V when the board and sensors draw noticeable current. Use VIN when only higher‑voltage power is available, and ensure ventilation for the regulator. [Arduino Nano Tech Specs]

How much current can an Arduino pin safely drive for LEDs?

Use 20 mA per pin as a design limit; 40 mA is absolute maximum. Exceeding those limits causes voltage droop and can damage the MCU. Aggregate current across ports also matters, so switch LED loads with transistors or MOSFETs. [ArduinoPinCurrentLimitations]

My LEDs get brighter when I unplug PWM. What does that indicate?

Your PWM path is current‑limited. The MCU pin or driver cannot supply the required current at full duty. Use a proper transistor or MOSFET stage to switch the LED current, and keep PWM as a logic‑level control only. [Elektroda, snow, post #17923725]

I saw 4.77 V at PWM 255 on USB and ~4.98 V on VIN. Why?

Your 5 V source quality differs. The USB supply likely sagged under load or regulation. Switching to VIN used the Nano’s regulator, which held the logic rail nearer 5 V. Note the lamp power stayed ~98 W in that test. [Elektroda, pdzran, post #17924132]

How do I verify PWM is really 5 V at 100% duty with a multimeter?

Try this simple check: 1. Temporarily set the PWM pin with digitalWrite(pin, HIGH). 2. Measure between the pin and GND with a DMM. 3. Expect near 5.0 V; if low, reduce load or add a driver stage. [Elektroda, kaczakat, post #17923701]

Which transistor or MOSFET should I use to switch 3 W LED channels?

Use logic‑level MOSFETs with low Rds(on) at 4–5 V gate drive. Avoid MOSFETs that need 10 V gate to fully enhance, or they will run hot and dim LEDs. “Logic level mosfets … open fully already at 2V.” [Elektroda, kaczakat, post #17923685]

Is a 500 mA phone charger enough to power a Nano for PWM control?

Yes. A 500 mA USB charger is sufficient for the Nano and light logic loads. Do not power LED currents from the pins; switch them with transistors and supply LEDs from a suitable driver. Keep grounds common. [Elektroda, kaczakat, post #17923605]

Do I need a common ground between the Nano and the LED power/driver?

Yes. Tie Nano GND to the LED driver or power supply ground so the PWM reference matches. Connect PWM to the driver input and keep load current off the MCU pins. [Elektroda, kaczakat, post #17923605]

What is the Nano’s PWM frequency, and does it affect LED drivers?

On ATmega328P boards, PWM is typically ~490 Hz on most pins and ~980 Hz on pins 5 and 6. Some LED drivers prefer particular frequencies; if needed, adjust timers or choose pins accordingly. [Secrets of Arduino PWM]

How do I troubleshoot dim output at PWM 255 with a large supply?

Confirm 5 V at the PWM pin at 100% duty. Add a logic‑level MOSFET to offload current. Ensure your LED driver can deliver the rated current. If LEDs brighten without PWM, your PWM drive path is limiting current. [Elektroda, snow, post #17923725]

Is it safe to power other modules from the Nano’s 5 V pin?

Keep external loads modest. The USB port and on‑board regulator have limits, and the MCU pins cannot supply high currents. Do not exceed a few hundred milliamps on 5 V, and never source significant current from I/O pins. [Elektroda, kaczakat, post #17923605]

Why didn’t my wattmeter rise when PWM rose from 4.77 V to ~4.98 V?

Your LED power is set by the LED driver and load, not tiny PWM amplitude differences. In the thread, power stayed near 98 W despite higher PWM pin voltage. Correct switching and drivers matter more than small logic‑level changes. [Elektroda, pdzran, post #17924132]
Generated by the language model.
ADVERTISEMENT