NodeMCU based MQTT multi-sensor with OLED display

@tinkernut - do you have the PubSubClient library installed in Arduino?

Also - see my post above - I’m switching the project over to ESPEasy. It makes the setup much easier, and allows the use of more sensors than what I was able to support with my code.

Thanks Bartus,

I managed to get Espeasy up and running but need the exact settings you used for the Lines/GPIO Pins. Can you send me screen shots of your set up since I bought one of your devices off Tindie? Thanks for your help. Looking forward to getting this operational.

@tinkernut - Sure thing (and thanks! :slight_smile: ) - but, since I sent that box to you before I made the switch to ESPEasy, and because I used D9/D10 as the OLED I2C pins, you’ll have to go through a few more steps to disable the serial port so that the OLED works.

First, open up the “Tools” tab and click on “Advanced Settings”. Scroll down to “Enable Serial Port” and UNCHECK that box, then hit “Submit”. This will open up the GPIO pins used by the serial port, and enable them for the OLED I2C data.

Next, open the “Hardware” tab, and under the “I2C Interface” select “GPIO 3 (D9)” for the “GPIO<->SDA” setting and “GPIO 1 (D10)” for the “GPIO<-> SCL” setting. Again, hit Submit, but also reset the device (power cycle it) so the settings take effect.

After you reset, go to “Tools” again, and click on “I2C Scan”. Now, you should see something like this:

If you don’t see any devices, stop and get in touch with me via PM…If you do, you’re ready to start setting up the OLED/DHT sensors.

Click on Devices, and edit a new task. For the DHT sensor, your entries should look like this:

(The formulas on the bottom do conversion, but also allow you to put in offsets, like the ones I talk about in my Configuration/Calibration video).

After that, add an “OLED Framed” device, and make the settings look like below:

That’s pretty much it - let me know if that works, or if you run across any other issues. We’ll get this thing up and running!

Thank you so much for all your advice! I was able to get it up and running now!

1 Like

Hi @bartus I got everything up and running hab-panel! I am using the sensor in my Cigar Humidor I would like to create a rule to alert me when the humidity goes below a certain percentage via text message.
Here are the values I am thinking:
If the temperature goes over 75 degrees and the Humidity drops below 62% humidity.

Do you know what the Rule would look like? Thanks for your help.

@tinkernut - I think you best option would be to use the Mail action (, because I don’t really see a way to send SMS messages easily (though, I guess you could send a message to your phone number @ your provider if they allow that).

I see you already have the sensor sending via MQTT (i.e. you have Temperature and Humidity items you update and display on your Habpanel) so the rule would be very simple:

rule "Send Email"
    Temperature > 75 or Humidity < 62
    sendMail("", "Alarm", "Humidor Alarm.")

Of course, you’ll need to make sure your Mail action is configured correctly (smtp server, user/password settings in the services/mail.cfg configuration file.

Thanks I will give that a try and let you know how it goes.

Dear Sir,

I am working on the same project. Could you please help me in the sitemaps and binding files as well.
I need that.

@Neelam_Rani - the only binding you should need for this is the MQTT binding (I still use version 1).

For the sitemap, you only need to add the Number item to your sitemap - the easiest is to add it using a Text element:

Text item=Temperature_Kitchen
Text item=Humidity_Kitchen

All your formatting is taken care of at the Item level, so it should display just the way you want it this way…

Hi BK,

Thank you for your help.I had done that. Its showing the right Temp and Hum values. But I am facing the problem in graphs.Can you please help in to the sitemaps and bindings file for the graphs?

Thanks and Regards

Its showing the empty graphs.Don’t know where i am doing mistake.

Make sure you’re using the correct persistence service (I’ve been using rrd4j, which can store a series of values over time) and not something like mapDB persistence (which can only save a single point - the last value).

Also, make sure you add the chart group to your Temp/Humidity item definitions, so they’re actually tied to the Chart element.

Thank you sir. Yes i have installed mapDB. I am just installing rrd4j.

Sir I have installed rrd4j and uninstall mapDB but not getting any results on my graph.
Can you please suggest how you wrote in this?

Strategies {
// for rrd charts, we need a cron strategy
everyMinute : “0 0/1 * * ?”

    default = everyChange


Items {
// additionally persist weather info every minute
gHistory* : strategy = everyUpdate, everyMinute

Will it be same or i have to do some changes in it?

Sir i need your help in one more thing. We are doing hard coding of our esp8266 and writing the ssid and password into the code. But if the ssid and password of our network changes after some months or years then we have only one option. We have to hard code it again.
I read regarding a concept Access point below one of your video. I want to do something like that so that we can change that from our phone or PC.
Please help in that as well.

Use code fences around all your posted code, so we can read it easier :wink:

Here’s my persistence strategy for the Temp_Chart group (all my sensors items belong to this group):

Items {
Temp_Chart* : strategy = everyMinute, restoreOnStartup
Temp_Chart_Period : strategy = everyChange, restoreOnStartup

Please post your items & sitemap definition files so we can take a look and see what’s wrong.

For this, I have started to use ESPEasy with these sensors. ESPEasy makes it easy to create an access point, but also allows me to change the configuration of the sensor using webpages, and add new sensors very easily too :slight_smile:

I haven’t made a full video about setting these up with ESP Easy, but I did show how to do it during my last live stream. You can watch it (it’s towards the end of the video where I show how I load/use ESPEasy), and hopefully it helps you!

Thank you BK for your help and yes i will try to use code fences:grinning: Actually i am new to these things. Here are my bindings and sitemaps files:-


Text label="Temperature Chart" icon="line"
       Switch item=Temp_Chart_Period label="Temp Chart Period" mappings=[0="Hour", 1="Day", 2="Week", 3="Off"] icon="line"
       Chart item=Temp_Chart period=h refresh=6000 visibility=[Temp_Chart_Period==0, Temp_Chart_Period=="Uninitialized"]
       Chart item=Temp_Chart period=D refresh=30000 visibility=[Temp_Chart_Period==1]
       Chart item=Temp_Chart period=W refresh=30000 visibility=[Temp_Chart_Period==2]

Text label="Humidity Chart" icon="line"
      Switch item=Hum_Chart_Period label="Hum Chart Period" mappings=[0="Hour", 1="Day", 2="Week", 3="Off"] icon="line"
      Chart item=Hum_Chart period=h refresh=6000 visibility=[Hum_Chart_Period==0, Hum_Chart_Period=="Uninitialized"]
      Chart item=Hum_Chart period=D refresh=30000 visibility=[Hum_Chart_Period==1]
      Chart item=Hum_Chart period=W refresh=30000 visibility=[Hum_Chart_Period==2]



Group Temp_Chart(all)
Number Temp_Chart_period "Temp Chart Period"
//Group Temp_Chart_2 (all)
//Number Temp_Chart_Period_2 "Temp Chart Second Floor Period"
Group Hum_Chart (all)
Number Hum_Chart_period "Hum Chart Period"

Number Temperature_kube "kube Temp [%.1f °C]" <temperature> (FF_kube,Temp_Chart) {mqtt="<[broker:home/kube/temperature:state:default]"}
Number Humidity_kube "kube Hum [%.1f %%]" <humidity> (FF_kube,Hum_Chart) {mqtt="<[broker:home/kube/humidity:state:default]"}

I have changed the persistence strategy but still not getting any results on my graph.

Thanks a lot BK. Learning many things from you.
Finally i learned how to use code fences.:grinning:

Ok - so your sitemaps/items look alright, but there’s one thing missing from teh Chart line in the sitemap -the “service” option. Add it so that your Chart knows which persistence service to use. It’s described here: and you need it for your specific case when running more than one persistence service (mapdb and rrd4j). Just add a service=“rrd4j” to your Chart line and see what happens!

Also - are you definitely getting good values in your items from the Kube sensor? I.e. if you add those Number items to your sitemap - do you see temperature/humidity values?

BK do you have a PDF instructions for this? I think I want to try this but instead of using a case designing it to fit into a wall box with wall plate so its less noticeable in a room. Is there any way to dim or turn off the screen at night?