Mqtt with esp8266 (NODE MCU) And arduino IDE

HI ,sorry if i’m annoying

I am like really new with this openhab stuff but i have managed to make it this far and even connected to mqtt. I am able to suscribe to a topic and see the value go from. 1 to 0 and 0 to 1 when i push a button on the app.

Thing is, i want to se it physically, i want to see a led light up when I push on that same button.
I have a node mcu, a red led, a breadboard , resistor and some wires.
I feel like i should be able to do this before doing crazy stuff. but It’s been 3 days now and no success. Downloaded numerous codes none where doing what i want but i tried to modify a little bit but still no success

Funny enough i was able to do this with adafruit in no time thanks to the many easy tuturials the adafruit communty provides. With openhab, people seem just too smart. (Only high end programms with sonoff etc)


Thanks in advance .

I would call this an advanced project when it comes to home automation. DIY electronics is a whole area of skills unto itself.

Well, here’s the thing. This is an openHAB forum, not an Arduino forum. Once you have openHAB publishing and receiving the messages over MQTT then your problem lies outside of openHAB.

So my question is, why not just use the Adafruit libraries and tutorials for how to make the NodeMCU turn on and off the led when it receives a 1 or 0 message over MQTT? You said you already figured out how to get OH to publish/subscribe the messages and you figured out how to control the light using Adafruit libraries. So you have basically done it. Just hook what you have already accomplished together.

If you need more help with the NodeMCU stuff than Adafruit provides, you will have much better feedback and help from an Arduino forum. Only a tiny minority of OH users also include DIY electrnoics like this.

1 Like

I would suggest to flash tasmota to the ESP. With this you can configure the pins on a web based application. For this there are plenty tutorials online.
It also includes a mqtt service, which you can use to publish or control states to/from openhab. For that you need a third component the mqtt broker like mosquito can be installed with sudo openhabian-config and follow the installation guide when you use openhabian.

Maybe this is a good entry point. But that’s said, this is a lot of stuff which has to be understand and getting to work so you will need some time setting everything up and understand basic principles.

similar to tasmota is espeasy - all web configured. very easy to use etc

1 Like

Unless I’m off base, I thought he wanted to send an MQTT message from OpenHab back to the ESP8266 telling it if the LED should be on or not. I did this once just for fun. You just need to subscribe to OpenHab’s state MQTT topic and set the LED as needed when you get a state change on the button. I actually did it with a motion sensor rather than a button but, other than for educational purposes, its rather pointless when you can just set the LED locally without a network round trip.

Unless the whole point is to control the light from OH in the first place.

1 Like

Not sure how different Node MCU is to basic, but this topic I post some simple arduino code I use to get/set pins/rssi/vcc etc. Then you’d just have to step the voltage correctly for the led.

Sorry if this looks odd ; typing on a phone.

yep . the goal is to control it from OH.

thanks to everyone who took the time to respond
.It suddenly works !! I, myself, am not really sure why since i have litterally changed nothing. Just rewrote the codes (both on arduino IDE and OPenhabian Items and sitemap files) but it works somehow.

Kuddos to y’all . i’ll try to figure out ESPEasy

ESPEasy, is not that easy… But that’s my take on it… I guess we all get used to what we know.


I’ve got some Tasmota Sonoff devices and some EasyESPs running on NodeMCU and I found them both pretty equivalent when it comes to ease of use.

What part did you find challenging? I’ll admit, figuring out how to hook up a Photoresistor as a device in EasyESP took a little bit of research, but it would have taken just as much research for Tasmota for me.

Luckily there are all sorts of options.

does it mean you use tasmota more ?

It’s not that challenging. The MQTT messaging is a bit more obscure but that only due to the docs being unclear (I think)
I agree they are equivalent in term of useability. We get used to what we know… That’s all

I use tasmota on sonoffs, never used it for anything more. to me espeasy is insanely easy. if you’re new to it yeah, its a little hard cause the documentation isn’t great and a lot of it was made and is maintained by people whose first language isn’t english. once you get passed that and understand it (honestly, it’s not hard, it’s all web driven) its stupid easy. i’m happy to help if you want to pm me. their forums are decent as well. you can’t go wrong with either. I do some pretty complex stuff with mine, you really don’t know what it’s capable of until you start doing stuff with it. then you will be amazed. for instance, I have a single ESP(wemos) with 2 channel expanders (32 i/o plus the 10 or so on ESP) that’s hooked into my 1980s garage door openers. I can see the position of all 4 reed switches, trigger things based on whether someone crossed on of the IR beams (yeah, i found retro kits for 1980s genies…) ultra sonic sensors for garage bay occupancy and I control 6 vents via L293Ds (from the channel expanders). as well as light sensors and stuff like that and it’s all done via MQTT messages sent from and to the ESPEasy.

1 Like

Related to this. I just found and more specifically This looks like a great integration for using esps. Would be nice to have something similar in openHAB I think. Does anybody have any experience with esphome? And is that something worth working on for openHAB (I mean by me :smile:)?

No but the set-up looks easy for the nodes
They seem to publish to mqtt so the integration with OH is straightforward.
From that point the world is yours.