ESP8266 with BH1750 lux sensor

Follow up on:

It depends on the ESP you want to use: I’m using nodemcu, setup is like (see hardware picture NodeMCU+BH1750):

I bought this:

Anything else might be missing ? Probably a case (but not important for now). I assume NodeMCU allows me to power it with a standard phone charger (miniUSB)


Just need to wait for delivery now

1 Like

Sorry to come back on this, especially after so long…
I restarted this little project, connected everything, got Arduino IDE connected and some loops running, but I think I don’t have the right librairy or sketch
Would you be able to help ?
My cabling is exactly as per the link you provided
Thank you for any help

I never programmed the ESP8266 with the IDE.
I strongly recommend to use an alternative firmware, this is a lot easier to manage, either Tasmota or ESPEasy. With that you would be using MQTT between the sensor and openHAB to get the data.
Tasmota support in this forum is slightly higher than support for ESPEasy. Good luck.

This can be done via MQTT or the REST API for communication of measured values to openHAB. MQTT gives more flexibility but you will need to set up a mosquitto server.
Libraries can be installed via the library manager in the Arduino IDE,

#include <Wire.h>
#include <BH1750.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <Arduino.h>
#include <ArduinoJson.h>
#include <PubSubClient.h>
#include <i2cdetect.h>

i2cdetect is optional but helps at first as you can check whether the physical connection to the sensor works.

I think it is a nice project to start with ESP8266 and Arduino but more detailled support is beyond the scope of this forum.
A web search on “ESP8266 BH1750 arduino” finds you plenty of helpful sites, among them.

Thank you for that.

I indeed started working with REST which is lot simpler than MGTT (in terms of code and configuration) and I now have informations coming in openhab

Just need to tune it