In wall light switch node - Custom PCB

  • Hardware Contributor

    Other than re-designing pretty much all of my board to allow for jumpers on the SPI lines that collide with the nRF24 lines, to allow for SPI uploads, how else would you go about this?

    The other option would be to run with a 8MHz external crystal to allow my FTDI Serial header to upload sketches. Which if i'm honest, I'de rather not do due to power consumption (If it was a case of using a 16MHz crystal the power consumption would be worth the clock speed increase to get the uC back to sleep quicker, but on wake the uC only have one thing to process then it will go back to sleep anyway, it isn't like it has a lot to process before sleeping again).

  • OK then,
    But a thought: if instead of soldering the radio to the PCB, we solder female pins? That way we can easily detach the radio when we want to flush new sketch and attach again.

  • Hardware Contributor

    @Sefi-Ninio - This was a plan of mine right from the start as stated in a few of the early comments. However, to me, this is not an option due to the height restrictions on the board. I really want to keep this as thin as possible to accommodate for various 'new' style switches that take up more than normal ones in terms of the depth of the back box.

    I would turn the radio round and stack it on top of the coin-cell but i do not want to be battling with any interference, it will have enough to contend with being nested inside of a metal backbox as it is.

  • @samuel235
    While we're on the subject of switches - how is it that you are able to control the switch without a relay on board?

  • Hardware Contributor

    The light switch board itself sends a signal to my controller, that then triggers my other node (relay with button actuator node) to toggle on or off. I've attached a image of my other node that we speak about here that the one side of the relay is connected to my lighting circuit and then i have another switch connected to that node to be able to locally switch the light in case the controller goes down for some unknown reason.

  • @samuel235 said:

    So here we have it guys, Revision 2 is now complete, tested and working perfectly! Its been a grueling process but so rewarding. I plan on making a few tiny little changes, including some headers/jumpers to allow ISP uploads while the radio is attached and pull-up resistors to the switch lines. I will get these all ironed out in the next few days and get the designs sent off to get the final boards manufactured. However, I don't feel that there is a great rush for this last board as the upgrades are very minor ones that won't effect its usability right now. The files on the original post are all up to date and relevant including the schematic. I'm yet to test the current draw, I'm trusting that it is sleeping in between the switch toggles, would this be tested via the current draw, if so where should it be measured to confirm this?

    Here are a few photographs of the final board attached to a switch plate:


    But here, you show the PCB connected directly to the switch, right?

  • Hardware Contributor

    Indeed this is. However I have two switches for this light setup. So, this board is essentially a slave device for the light itself. The relay module that i just posted a picture of is connected to another switch with two length of wire/cable, one connected to GND and the other connected to pin 3. The relay module itself uses the RelayWithButtonActuator sketch, then i can use the local switch and this slave board to control the lighting.

  • OK, so if I get you correctly, the wall switch, when turned on, is detected by the slave module that updates the gateway, which in turn issues a command to the relay module to turn the light on/off. And the slave module detects the switch state change because it makes or breaks the connection.

    That is a smart approach! But for each light you have 2 modules (slave on the switch side and relay on the lamp itself)... That can sum up to a lot of nodes for the entire property...
    More so considering a light with 4 way switch (3 different switches that can turn it on/off) - that would require 3 slave modules and a relay module.

    Also - what are the expectations for battery drain?

  • Hardware Contributor

    @Sefi-Ninio If i understand you correctly, you are correct. However, not every light needs two modules, this has two because i want two switches for this light. For a light that needs only one switch i use the locally connected switch on the relay node itself.

    I'll sort out a rough diagram later illustrating this.

  • @samuel235
    Thanks, I'd really appreciate that!

    Saw you added the gerber files, thanks for that. Could you also provide the BOM file?
    a couple more questions, if you don't mind:

    1. Do you know how long the battery is expected to last before it needs to be replaced?
    2. Does the module support GPIO pins as well, for some sensors to be connected?

    Thanks again for taking your time to help!

  • Hardware Contributor

    @Sefi-Ninio - I will get the BOM uploaded when i get home again. This full-time job really does get in the way of my 'MySensors Life' ahaha. I'm sorry, i forgot to get the BOM last night.

    To answer your questions:

    1. The only calculations i've done are based on Maniacs workings regarding coin cell powering the uC with an led and rf module. He worked out it should last as long as the battery does, he claimed it used less power than the battery discharge rate. So around 1 year 4 months he calculated. With my current plans for revision 3 having an external 8MHz crystal on board, it should still remain at around that length of time.

    2. It doesn't unfortunately since this was designed to be a minimal sized board that fits in the most shallow socket box I work with, i'm a building (plasterer and tiler) by trade and as this is the smallest back box we generally use in the building trade i wanted it to fit in without issues. It was designed to be just a light switch, i did have enitial thoughts to be able to interface the switch with a motion detector and even a temperature sensor to feed back to the controller the temp for the room. But i have a much bigger and more productive module in the design phases at the moment to handle this for each room. I will release another thread based on this new module soon.

  • Hardware Contributor


    This is my current setup @Sefi-Ninio. The controller is an obvious one for you. Module 1 is currently just an arduino nano connected to a SSR with a NPN transistor (serving as an amp, just to relieve the arduino from harder work than needed to turn the relay). I will at some point have this all on one board, this is designed to be placed in the ceiling close to the light itself. Depending on your needs, this can run either of the MySensors sketches, Relay or RelayWithButtonActuator. I have chose to have mine run the second, so i have a locally connected switch to this module to operate the light from upstairs, this will work whether or not the controller is alive. If you only need one switch and can run a cable/wire, this is your best bet. If not you can either use my board as a 'wireless switch' or as a slave switch for the light.

    My board will enable you to control the light module through the controller, however if this controller goes offline, obviously my board will not work. So, if do only need one switch and can run a cable from the light to the switch go with my first example, if you need a secondary switch or even just a case of a wireless switch then go with my board.

  • @samuel235

    Hello, I'm also very interested about light switch, which is connected to controller, topic. I'm freshman at MySensons comunity, so don't judge me if I have silly questions 🙂

    How You was writting in Your last posts, it is possible to use same PCB like RelayWithButtonActuator sketch. Please corect me if I'm wrong. If I want to control 1 light bulb with 1 button, then I connect solid state relay (SSR) to SW1 and button to SW2.

    1. Am I right with this description?
    2. SSR needs 5VDC input, so in same circuit we would need a step up from 3VDC to 5VDC. But if we were using step up, does 3V battery still have long life (about 1years and 4 months theoricaly)?

    Another questions with the look ahead of same project. I think it will be interesting @sundberg84 too.
    I was thinking how to put everything in one place with same priorities: safe and small as possible node.
    I drew an example:

    From here I have few questions too:

    1. I ordered SSR G3MB-202P and in datasheet there was written that it has snubber circuit already. So do I need another snubber circuit near the thermo fuse?
    2. What would be smarter if we want to make 'universal' PCB for at least 4 switches with buttons: to integrate SSR relays into PCB or make just the connections, like in already made @samuel235 PCB like SW1 and SW2?

    Thanks for answers!

  • Hardware Contributor

    I'm currently attempting to find a solution to my ISP uploading with the radio attached dilemma.

    My initial thought was to have 3 sets of 2pin headers with jumpers on, then remove the jumpers when you need to upload through ISP. But I'm really struggling to do this with the size of the board.

    My next thought was to have 3 sets of Surface Mount header pads, then solder them together, then if i needed to use ISP, just de-solder this connection with solder wick, then solder it back together once ISP connection is complete.

    The only real need that we would need to upload to this board would be to change the node ID if its set manually (which i do) or to update the sketch with more up to date solutions. The only way around this would be to use a controller such as MysController where you can do OTA uploads, but this would require me to have a crystal on board to allow the use of FTDI to get the bootloader and sketch on in the first place. Am i correct in thinking this, or is there a way to upload just a sketch to the uC through ISP where it allows a bootloader to be present on the uC, as far as i understand when you 'upload using programmer' it uses all of the uC's flash for the program you're loading.

  • Hardware Contributor


    Firstly, thank you for showing so much interest!

    To answer your questions:

    1. Yes you're correct, in theory.
    2. In my relay module i use a NPN transistor to bring the load off of the arduino/uC itself and to create a 'boost' for the SSR to properly register the switch. However, i do use a standard SSR, not a on-board style one. (this is the one i use).

    Me and Sundberg have shown interest in each others projects, hopefully soon i will be moving onto a module that will incorporate in-wall powering for itself and its sensors, that i hope to work with @sundberg84 to develop a solution that i have a feeling many of people will like here.

    Your next questions:

    1. I'm not very confident in answering this question right now and i hope that Sundberg will assist you here with that.
    2. The smart approach (Which i do plan on creating at some point) would be to create a board that has the relays on board along with screw terminals for 4 switches, so one ground and 4 digital input pins. Because these switches will be local to the relays, the board itself wont need to sleep at all, so then this means the only limit on the amount of switch you use are the amount of pins available. Right now my limit of 2 switches is dictated by the amount of interrupt pins we have on board of the ATmega328p-au. If the module sleeps to save energy the only way to have a switch work is to attach it to an interrupt enabled pin, which we only have two of.

    There seems to be a slight miss understanding with a few people around here on the duty of this module. This is simply a slave to a relay module because i can not round a cable/wire all the way from the desired location of my relay module, acting as a second switch as i also have a locally connected switch to the relay module, shown in my previous image/sketch.

  • Hardware Contributor

    Battery voltage measuring investigations and monitoring methods are now being discussed at This will enable me to have the controller act accordingly when the battery is running low, even have an indicator on the switch itself to let us know when we need to replace the battery before it is too late and we can not use the light switch any more.

    Please be sure to add your input on this topic to help us develop this product further.

  • Hardware Contributor

    I'm currently researching into capacitive touch sensing. I'm very tempted to create face plates from a 3DPrinter and enable it to have multiple capacitive sensors behind this plate to allow the use as a light switch. This will be an additional option, not necessary for this PCB to work. You will still be able to use a normal switch connected to the PCB. Just would be different software, potentially.

  • Hardware Contributor

  • @Samuel235 Any news regarding the new revision?

  • Hardware Contributor

    @Sefi-Ninio said:

    @Samuel235 Any news regarding the new revision?

    I'm struggling with time at the monent due to my full time job. I'm currently working on the upload issues. I feel that its the bootloader not matching the avr settings correctly with the upload speeds. @GertSanders has given a couple of bootloader examples for me to try which i will start testing tonight on that for you guys.

  • Hardware Contributor

    Currently experiencing some issues with what we speculate to be a fuse burning issue. I'll be troubleshooting further today. Will keep updates coming.

  • Is that related to the circuit for battery level? Or something else?
    What are the differences between the current rev. and what you are working on now?

  • Hardware Contributor

    @Sefi-Ninio said:

    Is that related to the circuit for battery level? Or something else?
    What are the differences between the current rev. and what you are working on now?

    It is concerning the serial upload issues i was having. The current revision doesn't include a bootloader and then therefor we can't upload via serial adapter. This in turn makes it unable to program anything once the radio is soldered directly to the board. I'm currently in discussions with GertSanders to try and figure out the issues with my bootloaders. Once this is sorted i will be able to program and debug the node through the serial interface/monitor.

    The next step will be to include a basic voltage divider method of reading the battery level i think. I did do various tests about a month ago and i will re-evaluate the situation on that. I may be a simple voltage divider solution or i may go for some exotic method. Even though the power consumption is slightly more heavy on the voltage divider method, i think i will go ahead and choose this method because of its simplicity for new users to just solder a couple of resistors on board. We will see.

    I do have another project/module in the design phases and a topic thread located here.

  • I have a problem finding the right wall switch. Normally they are all laid out for 230 volts, making them really big and requiring a lot of depth. Does anyone have experience with low voltage switches, which look nice and can be used for such projects ?
    Thanks !

  • Hardware Contributor

    @Sander-Teunissen, I have these running on a coin cell battery and the sizes for the overall board are: Height: 16mm, Width: 26mm, Length: 48mm. Please note that these sizes are that of the module without insulation. My current working node has its back covered with some fabric to stop it shorting out on the metal backbox. I need to come up with a solution for this. When i order my 3D Printer i'm hoping to fashion some sort of shielding for the rear.

  • Hardware Contributor

    I'm currently waiting on some more components to get this module up and running with thanks to @GertSanders providing the bootloader. All being well we will have it completed in the next month to be running with the radio and allowing ISP and FTDI/Serial uploads with the radio all connected.

    Does anyone have any feature requests for this module other than simple battery monitoring?

  • Just wondering, any of you guys looked into touch switches like below 0_1461627979698_HT1j2QTFGhXXXagOFbXh.jpg

  • Hardware Contributor

    @jeylites, i was going to make a thread on these exact switches soon to discuss the possibility of interfacing them as they run on RF. Keep your eyes open for the thread asap ;).

    I would like to make my own switch front with pressure capacitance at some point but thats for another day.

  • Hardware Contributor

    UPDATE - Feature upgrades

    I have had the materials arrive to attempt to get the latest fixes sorted for this board. Hopefully this will allow us to serial upload while the radio is soldered permanently onto the board. I will update soon as i have attempted this. Keep you posted!

  • Hardware Contributor

    @Samuel235 said:

    @jeylites, i was going to make a thread on these exact switches soon to discuss the possibility of interfacing them as they run on RF. Keep your eyes open for the thread asap ;).

    I would like to make my own switch front with pressure capacitance at some point but thats for another day.

    I didn't read this. of my current project in progress is exactly this! Designing a special shield for glass plate etc 🙂 the same for controlling one switch or more 😉
    I have few Livolo that I have disassembled and looked how it works inside. but I'm not fan of 433mhz radio (or that would need some rflink). I'm actually trying to decidde the best way, if I want to hack it, or if I will do my own switch with glass plate I found. because I would like dimming, rfm69, authentication and my shield...

  • Hardware Contributor

    @scalz, If i'm honest I would like to see both. I love to see hacks being perfected, especially in products with such a clean finish as these but then again i also love seeing brand news products being brought to life. Either one you do, i'll be sure to support your ideas!

  • Hardware Contributor

    Having some very intermittent issues regarding uploading to this board using an FTDI adapter, 2 in fact. I have tried two adapters now and neither are giving me solid results. I have checked all solder joints and all seems fine. Time to start troubleshooting further. I'm uploading to this board using fuse settings of Low: E2 and High: DE, with a brownout detection point of 1v8. The error that i get 9/10 times is just that the programmer is out of sync. I will report back with my findings.

  • Hardware Contributor


    We have a working node. We're now able to serial upload and monitor the module with thanks to @GertSanders and his bootloader.

    So the node currently has 2 switch inputs and that would be the maximum for the hardware interrupt, i may do some investigating to get another port for interrupt to enable us to have 3 switches on the one node.

  • Hardware Contributor


    Well, lets all thank the lead designer of the Optiboot boot loader: Bill Westfield !
    Without his code and repository my compilations would not give any results.

  • Hardware Contributor

    @GertSanders, get him here and lets all buy him cake and beer!

  • For more than two switches see:
    I would add a hardware debouncing (R/C) to avoid the problems mentioned in the article.

  • Hardware Contributor

    @Xander Thank you. I may try implimenting this into Rev 3

  • Contest Winner

    @Xander said:

    For more than two switches see:
    I would add a hardware debouncing (R/C) to avoid the problems mentioned in the article.

    It's very good trick, but this circuit allows use of only tact switches. If you are interested - check my schematic ( It allows use of on\off switches too. I've drawn it after a little brainstorm 🙂 I'm not sure it is optimal, but it works very nice.

  • Hardware Contributor

    @Koresh I had a quick look earlier, i will study it in more depth later. Thank you!

  • Hardware Contributor

    @Koresh, thank you for linking me your module, i'm finally getting around to looking into some depth in this. First of all, i would like to ask something regarding the Exclusive-OR Gates;

    I know how the gates work, in this case it uses Exclusive-OR (XOR) Gates, in simple terms, if the inputs are different the output will be HIGH, if the inputs are the same it will be LOW. The input you have connected to GND, could you tell me why that has to be connected to VCC with a resistor, could you not just connect that to GND?

    I really like your use of the Schmitt Triggers here, makes the signal nice and sharp on the falling edges for the logic gates to work with.


  • Hardware Contributor

    We're currently working on locating the issue that we have with the light switch not being synced with OpenHab correctly. It works as intended but you have to double click to get the light on. We have located the issue lying within OpenHab's item configuration issues. Will post the resulting configuration needed to get this node working 100% perfectly.

  • Hi Samuel,

    thanks for your great work.

    I'm currently starting with my first steps in Home Automation.
    I'm trying to control our lights in our flat. Our light switches are push switches with 12V. (dont know the right Translation to English. In German its called "Taster" - with no ON/OFF state, just a Push)

    Is this board useable for my switches? So can i connect the 12V to your board somehow and send the 12V "press button" to the main Fuse Box?

    Thank you,


  • Hardware Contributor

    @artipi - As I'm not completely sure about the German wiring system I can't give you a answer that would be strictly abiding your rules. However, I will attempt to answer from my own personal opinion:

    I'm not sure what you're sending the 12v back to the main fuse box for, this will simply send a 1/on or 0/off to your MySensors gateway. What you do with that signal is completely up to you. You could have a relay connected to mysensors gateway and then switch that relay with this light switch node. So, i suppose you could actually get a line on your fuse box switch with this but it would have to be sending signals to the gateway first, not directly to the fuse box.

    Sorry if I haven't understood your intent correctly.

  • @Samuel235 - Thanks for the fast reaction:).
    Ok, now i understand your switch node.
    I think i need something with a 12V Relay. So i can send a command (ON/OFF) to a relay node that will act like my light switch.

  • Hardware Contributor

    @artipi - That sounds very likely what you need. A double relay situation. However, if it was me, i would question what you need to switch it at the fuse box for. I would run the line to the lights from the fuse box and then switch it behind the like using a relay like i do (and will be releasing my relay node tonight on here and Then that is switched using this wireless switch node.

    However, the regulations in german wiring may be so that you have to do all switching inside of the fuse box.

  • Nice, will be waiting for your relay node! 🙂

  • @Samuel235

    In Germany and also in Belgium a lot of house installations have been built with pulse relays and 0-10V dimmers in a central switch box and only 12V controls to the switches. Makes for a bit more work when building the home (conduit from the fusebox to all seperate switch boxes) but changes during the lifetime are a breeze.

  • Hardware Contributor

    @DavidZH - I have to be honest here. I would love it if we did this in the UK. I wouldn't be scratching my head about how to fit a double relay board behind a light switch. I really do wish we had low voltage at human accessible point through-out the house, rather than switch 240V inside of a light switch.

    Out of interest, is this 12V in your switches DC or AC?

    Also, this is the relay board that i have just published. Development work to be done a little further though.

  • @Samuel235
    As far as I know the power to the switches is AC. Only a simple transformer, and Bob your uncle. They do also work on DC, as they only use a short pulse to change state.
    Here in NL only a handful have an installation like that. I am most certainly not opposed to it, but most houses over here do not have room for a huge switch box needed for such an installation. And another plus is that those relays can stay and you only have to add your domotica controls to the panel. Only difficult thing is the feedback to the controller of the state. You'd have to add auxilary contacts, or measure the live wire.

    I do not have a system like this but was just explaining what Artipi has.

    And I think there are some other things in the UK electrical system that need te be dead and buried in a hurry. Like the 32A ring circuit.... 😣

  • Hardware Contributor

    @DavidZH - I really hate our electrical system here, but that is coming from an electronics guy, not a electrician. I like the idea of low voltage in the switches, however its AC. I would prefer to see DC, but the voltage drops might be something that they're attempting to avoid by sending AC instead. Yes, i agree about those damn rings and we also don't have the room here in the UK like you mentioned about the NL.

Suggested Topics