Powering boards from mains and mq135 air quality sensors

Hi All,

Fairly new to this so apologies if this is simple - I’ve done a fair bit of searching and have some ideas, but wanted to know your thoughts.

Firstly, does anyone power their boards from mains? I don’t mean, using a plug with a USB transformer attached, I mean wired directly into the mains circuit via a transformer. To put this into context, I’ve been playing about and have made a multi-sensor, I’ve also fashioned a reasonable looking plate for it to sit in - much like a blank you’d put over a light switch. But instead of having batteries, or a cable hanging out, I’d like to hook it into mains so it may sit on my wall permanently, without having to be disturbed.

Secondly, does anyone use the mq135 air quality sensor and have it permanently switched on? I really want to, I like the data coming in, but just am a little concerned about the heating element side of things.

Thanks for any help you’re able to offer.

Powering from mains is definitely possible, but I wouldn’t recommend doing that for something that you’re permanently mounting inside a wall (yes, it may be easily accessible, but it’s still in the wall) unless you really know what you’re doing (and even then, not a fan).

I’ve powered some of my projects off of mains (although you’re still gonna need to have a transformer to step down the voltage), but only if I need mains power for the project. Otherwise I use either 12V if it’s needed or most commonly just a USB cable cause I have tons of them and I frequently just need 5V.

Hi thanks for your reply, by in the wall I mean behind a blanking plate, see image

I’m keen to have it permanently installed and batteryless, but yeh totally agree, not hidden in a wall cavity :joy:

Can you recommend any small form factor transformers you’ve used that are reliable, ebay throws the usual imports at me, but really after something that isn’t gonna burn my house down.

1 Like

Yeah, I understood what you meant and am still not really a fan (but to each their own). Obviously it can be done, but I’d look either for something specifically made for install in a junction box or honestly I’d probably mount a transformer elsewhere and run low voltage to where I needed it.

Thinking about it more, depending on how your sensors communicate it might be possible to just use a Shelly. That would kind of solve all your problems if it had enough exposed pins for your sensors. I’ve only used Shelly’s a few times, so I’m not real familiar with all of their offerings.

All of my projects needing mains haven’t been particularly size-restricted. Last one I can think of, I just used a doorbell transformer.

I use standalone transformers.

I have never seen one small enough to fit in a junction box.

In my location, I believe that it would be considered good practice, or even required, to be fused in order that the item was separated from a rings main. Also a lot of stand alone transformers have exposed mains connections and would require separate enclosure to keep the terminals isolated. All in all they don’t save space.

Perhaps there is a dedicated solution out there; worth trawling through Aliexpress. I would focus on running a wire into the location from a remote transformer.

Thanks both for your replies, for now I guess I’ll still to off the shelf transformers

Did you look into Shellys at all like I mentioned? They can run off of mains and have several exposed pins, so it just depends how many you need for your sensors. That’s the path I’d go down.

Thanks again for the suggestion, definately something to look into as I’ve got a load of shellys running the lights here, didn’t know I could tap into them and attach sensors though

Yeah, you can flash ESPHome and treat them pretty much like any other ESP. I know they have 3V, GND, RX & TX exposed as you can serially flash them and I think there’s another pin exposed too? Just Google it; TONS of info out there and on the ESPHome website.

Thanks so much, would’ve never thought of doing that

Be careful if you are using a Shelly 1, when powered by mains the GPIO pins are live.

Not sure if this is true for the newer versions.