Need help with Arduino Nano + LED Stripes ws2812b

Hello, I am designing the electronics for a portable battery-powered LED lamp and I would really appreciate a review before moving forward with PCB manufacturing.

I am currently designing the PCB in EasyEDA, and my goal is to have most components pre-assembled using SMD since I am not very experienced with soldering. I only plan to solder the Arduino Nano, the TP4056, and the MT3608 myself.

Additionally, the schematic includes several female JST connectors that I would like to have factory-soldered. These connectors are intended for components that must interact electrically with the PCB but cannot be physically mounted on it.

These components are:

  • CN1: Female USB connector to provide a 5V charging port
  • CN2: Connector for a single-cell 18650 LiPo battery
  • CN3: Main circuit switch. It must allow the battery to charge but prevent the LEDs and the rest of the circuit from turning on. It is intended for an external SS12D10-style switch mounted on the enclosure
  • CN4–CN7: Connectors for addressable LED strips controlled by the Arduino
  • Touch sensor (TTP223): This will also be mounted in the enclosure and connected to the PCB

I have several questions I would really appreciate your help with:

  • First, I would like to know if there are any critical mistakes in the schematic that could prevent the circuit from working. I am also open to suggestions, improvements, or design modifications that would increase reliability.
  • I want to make sure the power path is correctly designed. I do not fully understand the MOSFET placement, and I attempted to replicate this design:
    Power Path Controller Module - #4 by ShermanP
    However, I am not confident that I implemented it correctly.
  • Finally, in my design the MOSFET ( AO3401A | MSKSEMI | Price | In Stock | LCSC Electronics ) is connected to the TP4056 through the drain and to the MT3608 through the source. I am a bit confused about how current actually flows in this configuration — does it go from drain to source or source to drain?

Also, here is my MOFSET PIN configuration ( Datasheet - LCSC Electronics ):

This is my first PCB, and I would really like to get it right. Shipping is expensive, and I already made a mistake on a previous design that resulted in unusable boards, so I am hoping this one will be the final version.

Also, my arduino firmaware (if its helps):

#include <FastLED.h>

#define LED_PIN        4
#define TTP223_PIN     6
#define NUM_LEDS       8
#define LED_TYPE       WS2812B
#define COLOR_ORDER    GRB
#define MAX_BRIGHTNESS 150
#define STEP           5
#define DELAY_MS       10

CRGB leds[NUM_LEDS];
bool ledsEncendidos = false;
bool botonAnterior = LOW;

void setup() {
  pinMode(TTP223_PIN, INPUT);
  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  FastLED.setBrightness(0);
  FastLED.clear();
  FastLED.show();
}

void loop() {
  bool botonActual = digitalRead(TTP223_PIN);

  if (botonActual == HIGH && botonAnterior == LOW) {
    if (!ledsEncendidos) {
      fadeIn();
      ledsEncendidos = true;
    } else {
      fadeOut();
      ledsEncendidos = false;
    }
    delay(200);
  }

  botonAnterior = botonActual;
}

void fadeIn() {
  CRGB coldWhite = CRGB(200, 255, 255); // White
  fill_solid(leds, NUM_LEDS, coldWhite);

  for (int b = 0; b <= MAX_BRIGHTNESS; b += STEP) {
    FastLED.setBrightness(b);
    FastLED.show();
    delay(DELAY_MS);
  }
}

void fadeOut() {
  for (int b = MAX_BRIGHTNESS; b >= 0; b -= STEP) {
    FastLED.setBrightness(b);
    FastLED.show();
    delay(DELAY_MS);
  }
  FastLED.clear();
  FastLED.show();
}

Thank you very much for your time and any technical feedback you can provide.


UPDATE 1

Thanks to everyone who has been helping me in this thread. I’ve decided to make a series of changes to my PCB because, as you all pointed out, there were more issues than I initially realized (I’m truly grateful for all your help).

As a result, I’ve decided on the following configuration. I'd love to hear what you think:

This is the main schematic:

I have decided to apply a series of changes, so the functionality is now as follows:

  • Dual Power Supply: It can operate both plugged into a 5V 3A phone charger via USB or through an 18650 battery.

  • Resettable Fuse: Im using this before B+ in order to prevent a short. It's okey?.

  • Power Path Management: Whenever the USB is connected, it will draw current from there; when unplugged, it will automatically switch to the battery.

  • Manufacturing: I intend to order everything with SMD assembly from JLCPCB (the design is made in EasyEDA).

  • Control: A tactile touch button will control when to turn the LEDs on or off.

  • Voltage Sensing (Pin A0): I have tried to create a system to use the Arduino's Pin A0 to read the incoming voltage to the MT3608. My goal is to implement the following logic:

Voltage in LOAD LED Power Powers comes from
> 4.5v 100% USB
4.5v - 4.2v 100% Battery
4.2v -4.0v 70% Battery
4.0v - 3.8v 50% Battery
3.8v - 3.7v 40% Battery
3.7v - 3.6v 20% Battery
< 3.6v 0% Battery
  • LED Selection: Finally, as you can see, I have decided to swap the addressable RGB LEDs for 5V COB LEDs, as previously suggested, since they better suit my needs. Also, i decided to use only 3 LED stripes (instead 4).

So, my questions are as follows:

  • I will be using these 8mm white LED strips (3 strips in parallel, 25cm each, for a total of 75cm). I’ve seen that these types of strips (320 LEDs/m) consume around 10W per meter. Therefore, my estimated maximum power consumption would be about 7.5W. This implies a current of I=7.5W/5V=1.5A. This should be enough for my MT3608 module, right?

  • Regarding the Schottky diode, I have decided to switch to the SS54 model to ensure it can handle the required amperage. With this model, there shouldn't be any issues, right?

  • Regarding the 'LOAD' sensing system to identify whether the USB or the battery is being used: is this setup correct? Will it work properly? I am going to start developing the new firmware for it.

Finally, the MOSFETs I am using are:

Q1: Type P for power path as discussed

Q2: Type N, for controlling the LED stripes

Is this circuit functional as it stands? Are there any improvements you would suggest? I would like to test it on a breadboard first, but I don't have the necessary components on hand and they take a while to arrive. In fact, I am still finalizing whether these specific components will be the ones I use in the end. Is it 'crazy' to send the board straight to production like this without prior testing—ordering it with the components pre-assembled (even for just a few PCB units)?

Thank you all so much for the help, I really appreciate it because this is driving me crazy.

UPDATE 2

You can find a detailed description of the failures encountered in my previous PCB batch here: #50

I have started this new thread to track the progress and feedback for the complete redesign I am currently working on here:

  • What is the total number of pixels on all the strips (32) ?

Welcome to the forum

Is there a reason why you are using addressable LEDs in this application rather than simple LED strips ?

Use a prototyping board or a solderless breadboard to test your design.

Yes.

Four LED strips, each containing 8 LEDs. (I may increase the number to 10 LEDs per strip in the future.)

I have the breadboard, but I don’t have all the components to assemble it here (shipping takes quite a long time, which is why I was considering ordering it from the factory with everything pre-assembled).

  • When USB powered, USB provides MT3608 with current.
    USB voltage turns OFF Q1.
    Battery charges.

  • USB not connected, battery powers MT3608 through Q1.

    • Current from battery to Q1 drain to source to MT3608.

For now, I want to make fade in/out effects when turning the LEDs on and off. Maybe in the future I’ll add more complexity, which is why I decided to use addressable strips. Do you think that’s a bad idea?

So, would the schematic be correct? That is the desired effect: when it’s plugged into 5V, it shouldn’t use the battery, and when it’s disconnected, it should use the battery. My question is, are the MOSFET pins connected correctly, or are they reversed?

  • Looks okay.

  • C1 and C2 could be increased to 500uF each.

  • Note: MT3608 gets ~4.8v when on USB, ~3.7v when on battery.

  • Make sure D1 current rating is sufficient.

Note:

10 * 4 * 60mA = 2.5A pixel current. Your MT3608 can provide easily provide 1A @ At continuous 2A is pushing things.

And less when battery charge goes down...

Thanks for your reply.

  • Regarding the capacitors, could I replace them all with a single 1000 µF capacitor?

  • The MOSFET part is going to blow my mind. Since the MOSFET is a P-type, the current should flow from Source to Drain, right? In my example, the Drain pin of the MOSFET is connected to OUT+ (TP4056) and the Source to VIN+ (MT3608). I did it this way because in the example I shared it’s also like that, but I still don’t quite understand it…

  • Usually two 500uF are lower in height.

  • Note: pay attention to the MT3608 current limitations.

About this:

10 * 4 * 60mA = 2.5A pixel current. Your MT3608 can provide easily provide 1A @ At continuous 2A is pushing things.

If my MT3608 can only provide 1 A safely, what’s the alternative to power all my WS2812B LEDs without overloading it?

  • 1.5A might be safe but yes 2A might be a problem.
  • If you run pixels at 50% brightness things are better.
  • We always urge designs be first tested on a prototype board.

That's the typical orientation when a P-channel is used as a switch. But when the mosfet turns on, current can flow in either direction. And for use in a power path circuit, the orientation is governed by the body diode. The body diode has to be oriented to oppose current flowing from cathode of the schottky diode back to the battery. Only the TP4056 should be charging the battery.

So the way to think of this circuit is not as a switch, but as a two-diode OR circuit, consisting of the schottky diode and the body diode, both pointing in the same direction. The source with the higher voltge will supply the load current. In fact you could replace the mosfet with another schottky, and it would work the same. The only reason to use a mosfet at all is to eliminate the voltage drop in the battery line.

  • When USB is removed Battery voltage forward biases the internal MOSFET diode.
    Hence the source sits at positive, the gate is sitting at 0V (USB = 0).
  • Source at positive, Gate at 0v = MOSFET turns ON.

Thanks for your response, I think I’m starting to understand it.

We’re basically using the MOSFET in a “reverse” way, right? If I put a Schottky diode identical to D1, would everything work fine? Would the Arduino be powered correctly via the 5 V source when USB is connected, and when it’s disconnected it would run from the battery?

What are the implications of the voltage drop (which I think in a Schottky is quite low, right)?

What alternatives are there to avoid problems with the MT module?

  1. Control that the LEDs do not exceed 50% power?

  2. Use only strips of 8 LEDs as a maximum. That gives me 60 * 8 * 4 = 1920 mA, the MT maximum is 2 A, but even so I understand that it’s dangerous or not recommended, right? (We have to take into account that there will be modules like the Arduino and the TTP223, which, although they consume little, also add load.) Is this a safe option?

  3. Would there be a way to easily integrate a step-up on my PCB that could provide more current than the 2 A the MT module gives?

I really appreciate the help :slight_smile:

Either control the load on your code (brightness) or source beefier boost converter. Or use two, one per 2 strips.
2A output current would be >3A input current on batteries.