Not clear if you want to just power the ESP from 230v or control 230v with ESP.

Here is an option for the latter:


Is the riple not to high for the ESP? Do you have experiance with it?


I need power for the ESP8266, i think the Sonoff is good but to largae to make it concealed in a existing electrical plug socket

You mean like this?

Read the item description. It says it’s low ripple and noise.

[details=Item Description]The ultra-thin, subminiature
The full voltage input (90 ~ 264 vac)
Low ripple and low noise
Output overload short circuit protection function
High efficiency and power density
Product design to meet the EMC and safety testing requirements
Low power consumption, green environmental protection, no-load loss < 0.1 W
Aging and
100% load test
Meet the requirements of UL, CE,
The quality guarantee period of 10.1 years
The name of the project
Technical indicators:Single bit
Working temperature: - 20-60 +degree
Storage temperature: + 80-40 -degree
Relative humidity: 5-95.%
The cooling way: Natural cooling
The atmospheric pressure: 80-106Kpa
The altitude :2000M or less
Vibration coefficient of 10 ~ 500 hz, 2 g10min. / 1 cycle, 60 min. Each along the X, Y, Z axes[/details]

I see. If it is already to be in a junction box, then the Sonoff circuit could be removed from it’s own case to reduce size.

But I think we might need more context as to what you are making and trying to control.

@Fettkeewl @Jamin

Is it just me, or isn’t this a nice change from being asked to write all the code for someone :slight_smile:


What i mean is concealed “in wall” mounting. But as you know (i think you know it better than me) you need power for the ESP (3.3V) or NodeMCU (5V). If i want to put an ESP in wall, i need power for it but there are only 230V available. I think @Fettkeewl Link would be good or do you have a better idea?

I want it concealed mounting in a plug socket for triggering an existing light. So i need power supply and relay for controloing and the space is more less.

OK, I think I understand a bit better.

Short of seeing the socket box (do you have any pictures of the outlet in question?) and knowing clearances, everything we suggest will be just a guess.

However if I understand you correctly, you want to control a 230v socket with an ESP based device which also gets it power from the source AC line; all while fitting, safely, inside the wall box that holds the socket.

If that is all correct, then I don’t think you could build anything smaller than the, already designed to be as small as practical, Sonoff circuit board. The only benefit to a DIY merger of ESP, PSU and Relay, will be the limited ability to place the components in differing locations, in the box and around the socket… but then you run real risk of potential fire hazard.

Consider perhaps buying the Sonoff Touch?

I doubt you can make it smaller yourself, this is based on ESP8285 according to the comments, and should be reprogrammable if you want blynk integration. Bit pricey though.

1x 230V AC -> 3.3V DC $2.67
3.3V Logic relay $1.8
Some type of “housing”? $1-2 ?
All micro components, transistors, diodes, etc. $1-2
ESP device, maybe ESP-12, $2
Time spent assembling it all???

Raw material cost, perhaps $8.5 - 10.5

So is it worth building something that you cant get smaller that Itead has managed, to save $5-6, including all the headache of soldering everything, getting it as minimal as possible with your on hand tools… or not, guess its up to you. I know a wall socket does not fit much on the inside, depending on the amount of cables in it ofc. Choice is ultimately yours. :stuck_out_tongue:

1 Like


Can you explain this once again?
" The only benefit to a DIY merger of ESP, PSU and Relay, will be the limited ability to place the components in differing locations, in the box and around the socket…"

Further can the existing SONOFF be programmed by myselfe with blynk? Easily?

In regards to bold part, yes it should be fairly easy. It has exposed pins/pinout for programming, The red part

Can you fit these three things, all wired together, into the wall, but wrapped around the socket… ?

Or just this… with or without case

Both choices can be programmed with Blynk.

Or you could build your own? Hack an ESP in to one of these:

@Jamin I was thinking of something like that… but because it is an outlet he is describing, it may not be wired to a wall switch.

I will try it, thanks for your support!

Updated: Didnt read the reason in like the 5th post… so yeh my answer before was based on using it as a wall switch… not power it from high voltage…

No problem… and one last suggestion. Forget the complicated and perhaps hazardous wall modification and just take something like this and cut out one or two of the sockets, cover the holes with plastic and install all your ESP/PSU/Relay stuff inside. Then hide the whole thing behind a desk :wink:

1 Like

Nice catch :smile:

@Tom you can use these

these are very cheap and smaller


@Tom you can refer this:

hope it helps.

Although not concealable in a wall, I needed a quick solution for a four way trailing socket.

I used this PSU enclosure:

Along with a NodeMCU, 16A relay and a transformer from a mobile phone charger (£1) I just mounted them in the plug and wired the trailing socket to the relay. I also include a TMP36 Temperature Sensor inside just in case anything got too hot and I would get a nice early warning.

Worked like a dream and has been rock solid ever since.