In Wall AC/DC Pcb (with Relay) for MySensors (SMD)

This is a PCB that uses AC power to run a MySensors node and a relay (SSR) inside a wall socket. The main goal is to have a MySensors node with I/O to be able to build your own node with your own sensors inside a normal (European) wall socket. It comes with PCB and a 3d box for protection and safety.

This is a development of my first In-Wall-ACDC-Pcb-for-MySensors (Not SMD components, only axial)

Note: This PCB are using SMD components!

Current Status and revision

Testing rev 7.1

Rev 7.1 (Under testing - latest rev).

  • ISCP header now connects from botton (mirrored).
  • MYSX 2.4
  • Relay circuit improved.
  • Added silkmask with AC-DC seperation (Rev 7.1 > 5mm)
  • AC clearance 2.5mm minimum
  • Safety recommendations: This PCB meets the criteria of pollution level II (2,5mm (Basic) AC seperation and 5mm (Reinforced) AC-DC sepertion) and can be used "where only non-conductive contamination occurs. However, occasional temporary conductivity must be expected as a result of moisture condensation." Always use a sealed case to avoid contamination. Always read disclaimer.txt before using this PCB.

Rev 7.0 (TESTED)

  • Changes in resistors and NPN transistor for relay to work better.
  • Designed 3dboxes for safety.
  • Increased AC-DC separation (Rev 7 = 5mm)
  • AC clearance 2.5mm minimum, added millings.
  • Redesigned outer dimension/border.
  • Safety recommendations: This PCB meets the criteria of pollution level II (2,5mm (Basic) AC seperation and 5mm (Reinforced) AC-DC separation ) and can be used "where only non-conductive contamination occurs. However, occasional temporary conductivity must be expected as a result of moisture condensation." To be on the safe side - use a sealed case!

For rev history, see Changes.txt

Note when buying through may say another rev. This is only revision for manufacturer, not current PCB revision. I always update PCB gerber files for sale first on


I designed this project for the main purpose of safely powering a node from a AC source. Battery operations and 5v phone chargers in all its glory but I needed a node small enough to put inside a wall-socket, adaptable/dynamic and AC powered.

We have AC mains running everywhere in our houses today and this project aims for converting AC to 5vDC with safety as priority #1.

Aim of this project

  • Convert 240v/120v AC to 5v DC (using HLK-PM01)

  • Make it safe!

  • Fit inside standard appliance box / in wall

  • Run MySensors node (Arduino Pro Mini, NRF24L01+, MysX Gpio for sensors)

  • Have a on board relay (SSR).

  • Make it as small as possible using SMD components.


By using this you have everything you need for a AC powered MySensors node. With MysX connector you have plenty of options both digital and analog input/outputs for you sensors. For the AC power there are both a temperature fuse, a normal fuse, and a varistor to protect your node.

I wanted the node to be dynamic (no sensor specific) - and therefore the MysX connector. Now you can add any sensor you like to the connector. Also, while at it - why not add a relay. Since Im going to use this around AC i might also be able to switch it in the same time.

Follow this thread for latest info:

Build instructions coming soon, see BOM for more info.


**Power **- Using the HLK-PM01 converting AC 240/120v to 5v dc and running the MySensors node. The input is protected with a fuse, temp fuse and varistor (read this discussion).

**MySensors **- A Atmega328p-au (normal schematics) and a Nrf24l01+ SMD Radio with all the normal components.

I/O - MysX (Raw input not possible) + some extra (A4+A5), ICSP**

Relay(SSR) - A Omron G3MC-202PL protected with a fuse of your choise (axial)

3d-box - A part of safety, attached is a .stl file with a case for 3d printing. This can be printed in your 3d printer or sent to a 3d-hub.

MysX 2,1 - This is The MySensors expansion connector to which you can connect any daugherboard using this standard. This is also your main input/outputs for sensors and actuators so any wires can be connected accordingly. With this PCB as motherboard you can use draughtboards if you need multiple copies and needs a quicker way to build - just like a shield on Arduino or Raspberry Pi.


Safety is one of the most important aspects of this project! Se more here: It is highly recommended to use the latest revision for best safety.

Text below is written for the latest posted revision. For older revisions, please see changes.txt

AC-DC Separation

My thoughts has been to separate AC (primary) and DC (secondary) sides completely. At this point (Rev 7.0) this separation is 6.5mm so below minimum for use outdoor (in pollution level 3 = 8.0mm) but it should be OK if you dont use in in worst case pollution. In upcoming revisions I may add millings to increase creepage. This revision i recommend using it indoors and with the 3d case (or any case!) If you put it in a completely sealed case it should be ok to use outdoor.

The HLK-PM01 has been discussed in many threads here and are transformer based so it should be safe. More about it here and here.

Note: there has recently (Sept 16) been some fake/pirated HLK components! Warning!

AC high voltage trace creepage

As for the separation within the AC traces I have tried to use 3mm creepage and clearance but this turned out to be to hard. This PCB (Rev 7.0) has a creepage distance on the AC side of 2.5mm. This means if you are using 240v you can put it in pollution level II Sames as above, dont use it outdoors and put it in a case.


If you order or use this you agree to and understand that the author is not liable for any injury or damage howsoever caused and that you use this PCB at your own risk. This is DIY and the author has not made any professional test. This product has not been marked with any certification marks and cant be guaranteed to compliance with any standards.


Total cost for one node is about US$14 where the relay and HLK-pm01 is about US$10(See BOM).


You can actually cut/split the PCB between AC and DC side and get a normal 5v MySensors node where you can attach sensors to MysX connector.

I want it!

  • Order 10pcs: (Recommended!) and support me and MySensors!
  • Download from this page to get Eagles and Gerber files.
  • If you want a faster shipping time or less pieces you can buy them from me via Ebay.

Questions needing answers

  • Reliability, when will it fail? (compared to a commercial product?)
  • How will it fail? What is it weakest point?
  • Will my safety components be enough and prevail damage... ?
  • What will happen when it fails?


Design Files

NameSize# Downloads
InWallPCB71smd.GBS34.3 kB3566
InWallPCB7smd.brd207.84 kB3588
InWallPCB7smd.sch487.84 kB3840
3dBoxWMysX.stl16 kB3522
3dBoxWORelay.stl15.22 kB3396
3dBoxWRelay.stl16 kB3555
License_howto.pdf55.06 kB1903
PRODUCT.txt113 B2357
COPYRIGHT.txt421 B2331
License.txt8.94 kB2352
DISCLAIMER.txt353 B2359
InWallPCB71smd.GML31.49 kB3489
InWallPCB71smd.GTL46.32 kB3201
InWallPCB71smd.GTO126.04 kB3237
InWallPCB71smd.GTP33.43 kB3137
InWallPCB71smd.GTS36.24 kB3249
InWallPCB71smd.TXT1.29 kB2228
InWallPCB71smd.sch491.53 kB3321
InWallPCB71smd.brd114.92 kB3326
InWallPCB71smd.GBL38.72 kB3299
InWallPCB71smd.GBO31.73 kB3200
InWallPCB71smd.GBP31.49 kB3183
HLKPM01EaglesLib.lbr5.79 kB2919

Bill of Material

PCBPartValueSizeCost (Feb-16)Cost/PcsLink
FuseCeramic Slow Blow Fuse250V, 0.2A (50W)AxialUS $0.99 0.09Ebay:
Thermal FuseThermal Cutoffs FUSE73degr CAxialUS $4.990.5Ebay:
F3Glass Tube Fuse Axial Leads 3.6 x 10mm 2A2A, 250VAxialUS $1.990.2Ebay:
g3mc-202plOmron SSR Relay (Optional)g3mc-202plAxialUS $5,955.95Ebay:
T12n2222 npn transistor (not tested!)NPNSOT-23 US $0.990.0099Ebay:
VaristorZinc Oxide Varistor 250VAC 60J 2500A 10mmAxialUS $1.89 0.19Ebay:
AC2 Pin Screw Terminal Connector 5.08mmAxialUS $1.230.06Ebay:
ISCPPinheads 2x35.08mmAxial
MYSX 1.3Pinheads 2x75.08mmAxial
-Tactile Push Button Switch3*6*2.5mmSMDUS $1.780.0178Ebay:
-Crystal Oscillator16mHzSMDUS $1.380.069Ebay:
-HLK-PM01220V to 5VSMDUS $3.993.99Ebay:
-NRF24L01+ SMDSMDUS $7.731.546Ebay:
Volt_Reg662K 5V-3.3V Step Down RegulatorSOT-23 US $0.990.0495
ATMEGA328P-AUATMEGA328PSMDUS $12.161.216Ebay:
C1 (Volt reg)Capacitor SMD Ceramic0,1uF0805US $4.100.041Ebay:
C2 (volt reg)Capacitor SMD Ceramic10uF0805US $1.470.0147Ebay:
C3 (Radio)Capacitor SMD Ceramic4,7uF0805US $2.120.0212Ebay:
C4 (Oscillator)Capacitor SMD Ceramic22pF0805US $2.140.0214Ebay:
C5(Oscillator)Capacitor SMD Ceramic22pF0805US $2.140.0214Ebay:
C6 (Gnd-Vcc)Capacitor SMD Ceramic0,1uF0805US $4.100.041Ebay:
C7  (Aref)Capacitor SMD Ceramic0,1uF0805US $4.100.041Ebay:
C8 (Reset ISCP)Capacitor SMD Ceramic0,1uF0805US $4.100.041Ebay:
C9 (Reset MysX DTR)Capacitor SMD Ceramic0,1uF0805US $4.100.041Ebay:
R1 (Reset button)Resistor SMD10k ohm0805US $0.990.0099Ebay:
R2 (Led SCK)Resistor SMD330 ohm0805US $0,990.0099Ebay:
R3 (Led ON)Resistor SMD330 ohm0805US $0,990.0099Ebay:
R4 (Relay)Resistor SMD1k ohm (not sure)0805US $0.990.0099Ebay:
LED1LED SMDRed0805US $0.990.0198Ebay:
LED2LED SMDRed0805US $0.990.0198Ebay:
TestPointsTotal US $14.1911

Related Content