12V/2.5A/30W 1-channel LED switch for MySensors
Information for those who read this on openhardware.io: Please visit the github repo to download the files since openhardware doesn't support .zip, .json and .f3d files.
Download the Gerber files for the PCB from this repository. Get the PCB manufactured by your favourite boardhouse (Size: 25x50mm). I chose AllPCB who sent me 12 50x100mm boards (green soldermask, HASL with lead, 1.2mm thickness) for about 15€. Note that you will save some cost if you order a larger board with multiple designs placed next to each other like I did.
Prepare the electronics components listed on the BOM. Start by soldering the male 8pin JST connector to the side of the board. Be careful not to melt the plastic with your iron. Also don't apply solder to the top part of the contact blades since that will lead to bridges. Then continue with the ATmega 328p microcontroller, the two 100nF capacitors C1/C3, the resistors R1, R4 and R5 and the dual LED D1.
Double check your solder connections, then continue with step 2
To program your ATmega you will need adapter cables for ICSP and Serial. Instructions on how to solder these can be found on my website (https://thdev.org/?Projects___misc___micro_JST). You'll also need to add the barebone ATmega328p to the board definitions of your Arduino IDE.
Plug the ICSP adapter into your board and connect a 3.3V FTDI adapter to it. Then connect the FTDI adapter to your computer via USB. Select "ATmega328p (8 MHz internal clock)" from the Board menu and make sure the correct serial port is selected. Then select Tools > Burn Bootloader and wait for the process to complete. Then unplug the USB cable and the ICSP adapter and connect the Serial adapter to your board. Plug the adapter's header into your FTDI board and reconnect the USB cable. To test your micro load the Blink sketch, change the LED pin to 7 and load it to your board. Now the LED should blink green.
Once you have tested your microcontroller you can continue soldering the other components.
Assemble all the other parts: begin with the small parts on the top side (voltage regulator U3, capacitors C2/C4, mosfet Q1). Flip the PCB and continue with R2, R3 and the RF69HW module. If you want to have an expansion port (external buttons/serial communication) you'll have to solder a 4-pin header and the pullup resistors R6/R7. Then connect the small pin next to the power terminal (NOT the one labeled "ANT") to the pin next to the output using solid core wire. To complete the assembly solder the tactile switch S1, a 2pin screw terminal for the LED output and either a screw terminal or a DC barrel jack for the power input. Thn you need to make your RF antenna. To do this, cut a piece of solid core wire to the quarter of your RF module's wavelength. The easiest way to calculate the antenna length in meters is dividing 75 by the frequency of you module in (in my case 868).
Example: 75 / 868 MHz = 0,0864m = 8,64cm
Then solder your antenna to the pin labled "ANT", wrap it around a pencil to make it more compact and you're done! As always: check your soldering, then continue to testing.
Flash the Arduino sketch to your board using the Serial adapter. Then connect some 12V LED strip to the output and apply 12V to the input terminal. If you have a working MySensors Gateway nearby you should see the LED flashing green a couple of times and the LED switch appear in the Devices section of your smart home server. Once you have set it up you will be able to control your LEDs from your computer or phone. You can also manually control the LEDs using the button. Pressing it should switch the LEDs on/off, holding it enables you to dim them.
Common errors (at least the ones I've encountered):
LED flashing red/orange: error with the wireless connection to your gateway. Try decreasing the distance or bending the antenna. Also make sure your gateway+server is working.
Download the provided STL files for the case, place the bottom part next to the top part in your slicer (rotate the top 180° around Y-axis), and print them using a 3D printer. I've used my Prusa MK3, blue and white PLA filament and 0.15mm layer height.
To get the cool 2-color look you can use Joe Prusas ColorPrint tool (https://www.prusaprinters.org/color-print/) and add a color change at 0.5 mm. Start the print with the colorful filament (in my case blue). The printer will print the first two layers and then ask you to change the filament. Now load white or light grey filament and continue the print. The whole print will take about 1h (depends on your printer).
Put the top piece upside down on your table. Then insert the PCB (make sure button, LED, terminals and the mounting holes line up withe the case). Finally close the case using the bottom part and 2 self-tapping screws. Now you can install your module whereever you have some 12V leds to control. Mine is doing it's job at the 1m led strip over my bed ;-)
This project is licensed under the CC-BY-SA license, so you can modify and re-publish it, as long as you'll keep it under that license and give me, the ThetaDev, credits.
I've created the PCB design using EasyEDA. The source files are located in the PCB folder. But you can also directly visit my project on EasyEDA (https://easyeda.com/ThetaDev/MySen_ledV2-e1ad562137ac4dbb967d829ceed0bd0b) to edit it.
The microcontroller gets programmed using the Arduino IDE, you'll find the sketch in the Arduino folder. The required libraries are:
The case was designed using Autodesk Fusion 360. Source files are in the Case folder.
|Designator||Quantity||Type||Part number/value||Price/part||Price (total)|
|C1,C2,C3||3||1206 SMD Ceramic capacitor||100nF||0,008 €||0,02 €|
|C4||1||6032 SMD Tantalum capacitor||22µF, 25V||0,010 €||0,01 €|
|D1||1||5mm Bi-Color LED||red/green||0,020 €||0,02 €|
|J2||1||DC Barrel Jack||5.5x2.1mm||0,051 €||0,05 €|
|J3||1||5.08mm Screw terminal||2P||0,054 €||0,05 €|
|P1||1||Male 2.54mm header||4P||0,005 €||0,01 €|
|PROG||1||SMD male 1.25mm JST connector||8P||0,093 €||0,09 €|
|Q1||1||Mosfet||IRLML2502||0,034 €||0,03 €|
|R1,R3,R6,R7,R2||5||1206 SMD resistor||10kΩ, 1%||0,003 €||0,02 €|
|R4||1||1206 SMD resistor||100Ω, 1%||0,003 €||0,00 €|
|R5||1||1206 SMD resistor||300Ω, 1%||0,003 €||0,00 €|
|S1||1||Tactile button||12mm||0,018 €||0,02 €|
|U1||1||Microcontroller||ATmega 328p-AU||1,088 €||1,09 €|
|U2||1||RF module||RFM69HW 868MHz||1,670 €||1,67 €|
|U3||1||Voltage regulator||AMS1117-3.3||0,028 €||0,03 €|
|-||2||Self-tapping screw||M2.3 x 8mm||0,031 €||0,06 €|
|-||1||PCB||25x50mm||0,314 €||0,31 €|
|-||1||3D printed case||10.4g PLA filament||0,220 €||0,22 €|