Smart FlashLight
Greetings everyone and welcome back, and here's something Bright and useful.
Using an XIAO SAMD21 M0 microcontroller and an XIAO expansion board, we have created an OverEngineered SMART Flash light from scratch. This light uses an SSD1306 OLED screen to show the light intensity in percentage.
This device was created since I will soon be departing on a camping trip and needed a few camping essentials. A flashlight with wide coverage is one of these essentials. Regretfully, I was unable to find an adequate flashlight, so I aim to build one myself.
The idea was to use the XIAO expansion board, which has a circuit for charging lithium-ion batteries and is ideal for providing power to drive an LED load—in this case, a specially made copper-clad board that was etched.
We are using the XIAO SAMD21 M0 microcontroller as the brain of this project, which is connected to a push-button-rocker switch, user can use this switch to change the state of the LED.
Additionally, we are using an A03400 N channel mosfet as a switch configuration linked to an XIAO microcontroller in order to drive LEDs.
The LED load of this flashlight operates in four different ways: 20% power on the first press, 40% power on the second, 100% power on the third, and OFF on the fourth press.
Supplies
These were the materials used in this build:
- XIAO SAMD21 M0
- XIAO Expansion Board
- Li-ion Cell 3.7V, 2000mAh
- 3D-printed parts
- LED white 2835 Package
- Resistor, 5.6 Ohms, 2512 Package
- LED Board
- AO3400 N-channel Mosfet SOT23 Package
- Resistor 10K 0603
- Push Button-Rocker Switch style
- Wires
- M2 Screws
ELECTRONICS: XIAO SAMD21 With Expansion Board
We're using the XIAO SAMD21 M0 Development Board, which, paired with the XIAO extension board manufactured by Seeed Studio, is the heart of this project.
We are using the OLED display and battery charging IC of the XIAO Expansion board, to which we have connected a 2000mAh 3.7V Li-ion battery.
In order to link everything together, we connected the LED load, the Mosfet switch configuration, and the XIAO expansion board using the wiring schematic that was provided.
With the help of a 10K resistor, the gate of the AO3400 N channel Mosfet in the Mosfet Switch Section is connected to the D2 of the XIAO SAMD21 MCU.
The XIAO Expansion Board's 3V is linked to the LED load's positive terminal, while the mosfet's drain is connected to the LED load's negative terminal.
The source of the mosfet is connected to the GND of the expansion board.
One question: why are we using this particular mosfet switch setup? Why not directly connect the GPIO pins to the LED load? Why would it not operate with these SMD LEDs if it works with 5mm ones?
This is because, while the I/O pins of a microcontroller can drive an individual 20–30 mA LED, the high-power LEDs we are using can draw current of at least 200–500 mA each, and because they are connected in parallel, they can draw up to 2 A of current, which is not possible with regular I/O pins.
Using a Mosfet or even a transistor to connect the load directly through a power line—in this case, 3V—is one way to solve this problem. A Mosfet is similar to a switch in that it connects to the I/O pin of the microcontroller and, when voltage is supplied to the gate, allows current to flow from the drain to the source. Controlling the load is simple when one sends a PWM signal to the mosfet's gate.
We are using a spare Etch LED board that I had lying around for the LED load.
It has eight 2835 LEDs connected in parallel. The current that flows through each pair of LEDs is limited by a 5.6 ohm resistor.
DESIGN
The design of the flashlight was prepared next, which included the model of the XIAO expansion board and battery, which we arranged in such a way that the expansion board was placed on the right face of the model and the battery was placed inside.
The model is composed of two parts: the main body, which houses the expansion board and battery, and the PCB holder, which is mounted to the front of the main body and on which the LED PCB is installed.
The rocker switch was positioned on the uppermost face of the model, which was designed so that the user could hold the body comfortably and press the switch without having to move their thumb too much.
Following the completion of the body, we exported the mesh files and used a 0.4mm nozzle with a 0.2mm layer height to print the main body in purple PLA and the LED holder in transparent PLA.
TEST SKETCH 01
We added a basic blink sketch to the XIAO SAMD21 MCU in order to test this configuration. By passing the sketch via the microcontroller, LED Load turns ON and OFF, indicating that we are ready to continue on to the next stage, which is to add the main sketch to the board.
TEST SKETCH 02
The main sketch was then uploaded into the XIAO SAMD21 configuration.
By pushing the switch, this code enables the user to toggle between various light brightness levels. An OLED screen, rotated to be viewed in portrait orientation, shows the brightness level currently in use.
ASSEMBLY PROCESS
- Using a soldering iron, remove all of the parts from the XIAO expansion board, including the battery, switch, and LED load, to start the assembly process.
- Next, using a window provided on the expansion board mounting location, we select and position the expansion board on the main body before running all the cables inside.
- To permanently fasten the expansion board in its position, we utilize four M2 screws.
- The lithium cell was then installed in the main body.
- Next, we linked the expansion board to the positive and negative wires of the lithium cell.
- We turn the ON/OFF switch on the expansion board to confirm that the battery is connected to the board. When we do this, the XIAO SAMD21's status LED illuminates, indicating that the board is receiving power.
FINAL ASSEMBLY
- In order to begin the final assembly procedure, we place the LED load on the PCB Holder component and fasten them both together with two M2 screws.
- The LED load's negative terminal will then be linked to the mosfet's drain. Next, attach the positive terminal of the LED load to the expansion board's 3V.
- Wires are connected to the LED load, and the PCB holder assembly is pushed into the main body. The PCB holder and main body are then fastened together with two M2 screws.
- Using a soldering iron, we finally reconnected the rocker switch to D1 and GND. After that, we pushed the rocker switch into place to finish the assembly process.
The flashlight is now ready.
RESULT
We tested this arrangement outside in the woods to see how well it would perform for lighting up the area. The results are seen in the video.
Compared to conventional focus LED flashlights, the light spread angle of this flashlight, which is a flood light kind, is wider.
I will be using this item on an upcoming camping trip; it was a truly overengineered take on a basic yet essential thing.
Overall, this project was successful, however in order to cut down on wiring and makeshift processes we will soon be working on a Version 2 that will house the Mosfet as a switch configuration and LED array together on single PCB.
Thanks for reaching this far, and special thanks to Seeed Studio Fusion for supporting this project. Check them out for all sorts of PCB manufacturing and assembly services for great quality and less price.
Peace