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:
https://www.aliexpress.com/item/40pcs-lot-10cm-2-54mm-1pin-Male-to-Male-jumper-wire-Dupont-cable-for-WAVGAT/32821448523.html
https://www.aliexpress.com/item/1-Pcs-New-400-Tie-Points-Solderless-PCB-Breadboard-Mini-Universal-Test-Protoboard-DIY-Bread-Board/32517894271.html
https://www.aliexpress.com/item/New-Wireless-module-CH340-NodeMcu-V3-Lua-WIFI-Internet-of-Things-development-board-based-ESP8266/32266751149.html
and
https://www.aliexpress.com/item/1PCS-BH1750-BH1750FVI-light-intensity-illumination-module-3V-5V-for-Arduino/32834931142.html

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)

Yes.

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, https://forum.arduino.cc 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

Karl