In wall light switch node - Custom PCB

  • Hardware Contributor


    My first contribution to MySensors is going to be a Light Switch node that meets a few lines of criteria. To my knowledge, this hasn't been developed yet and feel that there would be a fair few people that would benefit from a very simple switch node that actually fits in a location where an existing switch does, that way there is no signs of home automation on the switch front. Yes we have scene controllers that can be mounted onto the wall, but this starts to become bulky and obvious that there is some sort of technology there controlling something, what about if you simply just want to switch a light on with natural instincts without having to look at what you're doing? This is where I personally think this Product would prove itself worthwhile. There are currently two other projects like this going on here at the MySensors forum:
    @sundberg84's In Wall PCB - This is a node using two PCB's stacked together that will sit inside of Swedish style wall appliance box and have its own power fed to it.
    @martinhjelmare's: Box for In Wall PCB - This is a box that simply sits inside of the socket to contain all the open high voltages of electricity if being reduced down from 240v on the PCB itself.

    If there is any electricians roaming around here, please, advise me of any serious, specific implications, rules and regulations that this would need to meet that i haven't stated so. I will be getting some mock schematic and PCB designs sorted out for you guys to look at for a starting point. I will make it very obvious now that I'm not a profession electronics guy, nor am i someone that has experience in designing PCB's, electronic designs or anything. This is a huge learning curve for me, but as a community i do believe we can put together some awesome products, alongside of @sundberg84 and @martinhjelmare's proposed outcomes.

    Product Criteria:

    1. Fits inside of a slimline (25mm depth) UK Wall metal AND plastic back box/dry lining box.
    2. Able to be powered via Battery and/or mains electricity, either 240v straight from the power circuit or have it transformed down to the 5v in a central location/outside of the socket box then fed into the box for application.
    3. Allowing you to keep existing wires in the box, but terminated. This would allow us backward capabilities of reverting our alterations in case of selling the property.
    4. Form factor/Footprint must be a small as possible to remove any possible issues on the space allocated.

    The Product itself:
    The product itself will be based around an Arduino Mini Pro powered via either a cell coin battery, AA batteries or a mains electric feed reduced down to the required voltage, I'm thinking 5v step down outside of the box (in a central location, maybe even in the electric room (where your main breaker is located) then stepped down from 5v to 3.3v on the board itself. The whole system will be created and located onto a custom PCB that i propose to be all SMD, to allow for a smaller form factor for the already challenging installation size. This product will start out to be a simple ON/OFF switch, a dimming version will be the first upgrade offered to the product. The product will include a nRF24L01 radio transceiver to deal with its networking, so that is going to need some revision for the metal back box version to allow the transceiver to work with the metal, if it has issues that is.

    Currently, I have a breadboard setup with an Arduino Nano, a light switch faceplate doing the switching and an nRF24L01 doing the transmitting back to my MQTT gateway. So currently outside of the Arduino, all that is needed is terminals for the switch itself and a resistor for the switch. Then we will need the power solution, so a coin cell holder, resistors, caps whatever is needed to feed a stable 3.3v to the micro controller. The mains connection, this is going to need screw terminals, and again caps, resistors and whatever else is needed to reduce down the power (I'm still thinking to bring the mains in at 5v, so step them down outside of the application). If anyone feels like pointing me in the right direction in terms of whats needed to bring mains power down, feel free. I will continue to research the correct ways to do such a thing in the meantime.

    Environment Design work:
    I have made a pretty accurate design in google sketchup as a starting environment for the first installation of this product detailing sizes that we have to work with to enable us to fit this inside of the existing wall back box.

    Light Switch.png

    The Environment for the Product:
    For example, the below images show a light switch placement that i currently have, hopefully this will give some indication the room that we have to work with here to allow the existing cables to be terminated and left where they are for future needs. A normal back box or dry lining box installed now would be 35mm to sometimes even 50mm boxes, however we must allow for such situations that arise where the plasterers (Like myself) have had no choice but to install a 25mm box.

    DISCLAIMER: I did not install the current switch, which as you can see is a pretty poor installation to say the least. I will be using an electrician to do any mains electrical work, and therefor I'm not going to allow anything below the national standard to be installed into my property.

    DISCLAIMER: I do not advise you in any way to make/install this product into a property and therefore I take no responsibility for any issues, problems you have or even health implications that you endure while completing the installation or even using the product after installing.


    24th December 2015 - Version 1.1 Revision 1 boards have been ordered and currently being produced with
    24th December 2015 - Parts have been ordered for the production of 1 evaluation node.
    14th January 2016 - Version 1.1 Revision 1 board has arrived, populated with components.
    23rd January 2016 - Version 1.1 Revision 2 boards have been ordered and currently being produced with
    13th February 2016 - Version 1.1 Revision 2 boards have been received and populated.
    19th February 2016 - Version 1.1 Revision 2 boards are currently going through their first 24-Hour long testing period.
    21st February 2016 - Version 1.1 Revision 2 boards are undergoing troubleshooting work.
    5th March 2016 - Version 1.1 Revision 2 boards are completed and power usage tests are currently taking place.
    19th March 2016 - Version 1.1 Revision 2 has been uploaded to

    Current Eagle Files -
    Schematic PDF - 1_1457169973710_HominiSwitchNode1.0Rev2_Sch.pdf
    Board PDF - 0_1457169973709_HominiSwitchNode1.0Rev2_Brd.pdf
    Gerber Files - 0_1457460927449_Rev2
    BOM - 0_1457593789223_HominiSwitchNode1.0Rev2BOM.csv

  • Hardware Contributor


    wow, it's great, lot of inwall projects...I agree with you for smd, I think it's best suited for slimmer as we have not much place inwall..the biggest problem is the ac stepdown, it takes lots of place. if we want something as small as "fibaro" it needs a custom ac stepdown. it's a little more tricky to make well but doable, then it is not galvanically isolated, not the the biggest problem if it is well integrated I think.

    Then there is multiple connections existing inwall to connect the switch. 3wire or like at my home for instance, I have only 2 wire connected on my switch one from mains, the other one go to the lamp. And this case is much more tricky to needs a very smart power (lot of work on this) to power the device. the easy way for this one is coincell or battery.

    If it can help, and you do it before me 😉 because I have some projects in work but it shoud not take too much time to design..
    In my case, for the moment, I plan to have:

    for powering options, I am not very sure to be able to have all these options on one board but I will try to see 😉
    I wan to keep the "motherboard" on bottom, and of course, the sensors shield on top, so when opening the switch, we can't touch ac parts...lot of others ideas but I let you make your own. I don't want to interfere in your ideas 🙂

  • Hardware Contributor

    Great to see all this projects come to life! I hope we all can gather around this and create a great, small and SAFE in wall product.

  • Hardware Contributor

    @scalz - FIrstly i would love to have some sort of development input or even help you on your project once my idea has got going. Just one question, the only rs485 i know is that of the serial connection for computers, could you explain what your mean by powering via rs485 please? For Version one of my product I will be keeping it nice and simple and keep it to just the one board with screw terminals for the switch buttons. Hopefully Version 2 will bring upgrades such as a secondary (sensor) board where we will then be able to connect different sensors onto the daughter board without touching the AC/DC like you have in mind. I would like to keep everything in this thread very simple and one at a time to enable us all to have a clear working space to develop the product that is in mind. Then once we have achieved that, then we can then agree what upgrades would be worthwhile and then develop Version 2. I will be documenting everything that goes on with this product just to make everything flow as smooth as possible with reference points at every stage of the build. I'm hoping that this will help prevent any issues that would require us to rollback to a previous state/build. I came across your 'MyTinyCamel' build the other day, i love what you have done!

    @sundberg84 - That is exactly what I would love to happen, and I'm pretty sure the likes of @hek will be loving that fact he has developed such a tight and strong community that is coming together to develop what the admins would call their 'baby'. I look forward to every upgrade we make! Bring on the issues and lets develop as a community!

  • Hardware Contributor

    @samuel235: thx 🙂 sorry, like I said I don't want to interfere in your projects. I was just saying some ideas if it can help.
    for rs485, it is just I will use one pair for power and one pair for data. I know it's possible to power and data on same line but this is not the way I will use I think.

    so, good luck with your project 😉

  • Hardware Contributor

    @scalz Ahh so it is the serial cable you speak of! I would honestly really appreciate your input on this topic. I don't want you to leave from the topic at all. Please, share your inputs and suggestions whenever you feel the need, just want to keep everything organised here, so it doesn't end up with a caotic mess. I luck forward to your suggestions on various issues and upgrades along the path!

  • Hardware Contributor

    I have attached the Board and Schematic mock-ups. Would it be possible to hear your opinions on what needs to be changed, if anything that is. All being well the RF Module fits where i intend it too, sitting just above the chip itself.

    Does that capacitor look okay being grounded to the ground line rather than directly onto the ground pin of the RF module (To stabilize the vcc and ground of the RF module).

    A quick little list to show what is what on the board:
    AVR CONNECT - Connection for AVR Programmer to bootload.
    SW1 - Screw terminals for Switch 1.
    SW2 - Screw terminals for Switch 2.
    SW3 - Screw terminals for Switch 3.
    ATMEGA328P-AU - The obvious, ATMEGA328P-AU.
    NRF24L1 - NRF24l01+, will use header pins and solder so its sitting just abover the ATMEGA.
    C2 - 4.7uF Capacitor to bridge the VCC and GND on the radio.
    BAT1 - Cell coin holder (CR2450)

    I don't need any mounting holes at the moment so that isn't an issue. I plan on elevating it off of the metal back box to stop any chance of shorting too.

    Would you say that i need to be wiring the terminals for the switch using VCC and a resistor or would a input pin to ground be okay? I've seen so many people people do it both ways in the forums and on the general internet, what is the preferred method?

    I'm more than happy with receiving any sort of criticism on this board, as this is my first attempt of a custom PCB and my first attempt of using Eagle software.

    Sch1.jpg Brd1.jpg

  • Hardware Contributor

    Why not use a 4-pol screw terminal instead? One common and then one input for each switch. Also, consider if the corners could be 45 degrees instead of 90. That would make it fit more easly in a round back box. Aren't you missing a pull-up for reset and a few decoupling caps for the ATMega?

  • Hardware Contributor

    Indeed, decoupling cap (100nF) is needed or the powerline (VCC-GND) would be unstable when transmissions occur. This effect could block or reset the atmega.
    With this setup, you will not be able to program sketches when the NRF is connected. If you add an FTDI header, you can program via serial port and monitor the processor while the NRF is connected. Will help in debugging code.

  • Hardware Contributor

    @mardah @GertSanders - Sorry guys, for some reason i just assumed that the decoupling caps were only needed for if i was using an external crystal, for increased power needed for 16MHz. I'll get that on.

    I'm going to have a look at that header you speak about when i get home tonight, i was planning on programming the board then soldering the RF module on. Now you point this out that would be a very silly amature mistake to do. Thank you for making that obvious.

    I'm also planning on refining the layout of the board and the shape. So i will take the corners off to adapt it to a round box.

  • Hardware Contributor

    You might want to have both the 1x6 pin FTDI-serial-"arduino" port and the 2x3 pin AVR ISP port. Note that pin# are standardized.

  • Hardware Contributor

    @m26872 Could i ask why i would need both? They essentially do the same thing, right? Except FTDI uses the DFU bootloader and then the SPI connection overrides the DFU bootloader, am i correct in thinking this or do i have my lines mixed up? If so then i was planning on using the 6 pins i have on the edge of the board, connect them via jumper cables to the 6pin SPI connecter that would come with the USBasp programmer i plan to purchase. The reason i plan to go down this route is simply to save room in the socket, limited height room.

    @GertSanders - Is the 6 pins that i have added to the board not a FTDI header? What makes it not, the pin layout or the pins used on the mega chip? I thought that if i added 6 pins, wired them to the chip using the pins i have (gnd, vcc, ce, csn, irq, miso, mosi and sck) that made it a FTDI, I'm guessing I'm incorrect?

    @mardah - Free space depending, i'm looking into doing this now, so do you feel that my switching method is sufficient enough without using vcc and a resistor to each switch and then to the input pin? You're happy with the Input pin -> switch -> GND method? EDIT: The only 4 Pol i can find that would be big enough to accept 3 cables into the common is working out at a stupid price in comparison to the rest of the board. At the moment, i will be using the 3 terminal setup i have currently sketched.

    I planned on using this as the USBasp programmer, however if i can use just an FTDI connection to do both (program the MYSBootloader and to upload sketches) that would be better for saving space on the board.

    The FTDI programmer: Link
    Can you use this to program the MYSBootloader as well as upload a sketch or is this simply to upload a sketch to the mega?

    The decoupling caps, as a rule of thumb, its 100nF cap per supply pin, correct? I will supply all 3 VCC pins with the power, so i should connect a 100nF cap to each of the pins. Does this sound over kill or okay?

  • Hardware Contributor

    @mardah If i wire a 4-Pol screw terminal as follows:

    1 - GND
    2 - INPUT1
    3 - INPUT2
    4 - INPUT3

    Then i wire GND into Switch1's COM connector, then L1 goes to screw terminal pin 2 (INPUT1). Then i take the com from the back of Switch1 into the COM connector of Switch2, then wire Switch2's L1 connector to screw terminal pin 3 (INPUT2) and the same for switch 3. Do you feel this would work as intended?

  • Hardware Contributor


    just a little thing, it is "better" to have nothing under radio antenna (no gnd plane..) for range and operation. it could help as it will be inwall 😉

  • Hardware Contributor

    @scalz Thank you for that heads up, i will get that down onto my board documents to change too. Thank you!

  • Hardware Contributor

    @samuel235 I can't tell you what you need, I'm just saying that if you provide an AVR-ISP port looking like FTDI-port, everyone except yourself will be confused or even risk to destroy the AVR by mistake.
    Let's look at the Sensbender diagram as a reference. The FTDI-port is JP2 and the AVR-ISP is JP3. Most people would prefer to program bootloader once and then use the FTDI to upload and debug new programs.
    If I couldn't fit an AVR ISP port, I would try to make to make the nRF SPI-pin + Reset, accessible. Maybe even better is to make (if you don't already have?) a special board for 328p-AU (TQFP-package) bootloader programming, then solder it in place with bootloader already on it.
    Please also note that the JP2 FTDI-port needs R3 and C5 to work.

  • Hardware Contributor

    @m26872 Firstly, thank you for referencing the sensebender and its pinout. I can now have a look at this and use it to better improve the pinout and layout of my board. So, i will try to get both headers onto my board to allow better programming capabilities. If i use the same pinout as the sensebender does for the AVR ISP and the FTDI-port, would i then be able to burn the bootloader and upload sketches while the RF module is soldered. If not, do you think i could use some jumper headers to effectively remove the RF module from the board while I upload the sketch and then put the jumpers back on to close the circuit back up?

  • Hardware Contributor

    @samuel235 I can't recall that I've actually used the ISP with the nRF, but the whole point of ISP is that it should work.

  • Hardware Contributor

    @m26872 Okay, so its probably best to just burn the bootloader, then solder the nRF inplace and then upload the sketches using the FTDI port just in case i solder on the nRF then turns out i can't burn the bootloader?

    I believe i can leave the AREF pin unconnected. Is this true?

    Do you have any other input other than the following changes i'm scheduling to make on the board tomorrow:

    • Remove GND plane around the area of nRF module to reduce chance of interference.
    • Remove current screw terminals and replace with 1 4-Position with GND as common and other 3 going to input pins.
    • Connect all GND pins.
    • Connect all VCC pins.
    • Add decoupling Caps in the layout that Sensebender uses, 1 on each VCC, so 3 in total.
    • Add Pullup to reset pin.
    • Remove current 'FTDI' connector and add correct FTDI layout connector along with a SPI header connection for bootloading, use Sensebender for reference of the pinout for these two connectors.

    While looking through the Sensebender schematic and images, i have noticed there is Q1 (What i think is a transistor, correct me if i'm incorrect), may i ask if you know what this is for, as it is not actually on the final board images.

    Sorry if i have made any more school boy errors.

  • Hardware Contributor

    Arduino Pro Mini should be your no1 reference. Schematics and Eagle files povided. There your can see the normal layout of Q1 e.g. It's the crystal/oscillator (with 22pF caps if you choose xtal) I don't know why Sensebender looks like it does.

    I haven't studied your design closely or know your intentions, but I don't know of any proven coin cell nRF designs, but I suppose you'll have it sleeping a lot.

    Sometimes it's good to breadboard prototypes if there're any hesistance.





Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.