-->
Notification texts go here Contact Us pelacakan

ESP8266 NodeMCU with BH1750 Ambient Light Sensor

ESP8266 NodeMCU with BH1750 Ambient Light Sensor

ESP8266 NodeMCU with BH1750 Ambient Light Sensor
ESP8266 NodeMCU with BH1750 Ambient Light Sensor

To use the BH1750 Ambient Light Sensor with an ESP8266 NodeMCU using the Arduino IDE, follow these steps:

Components Needed:

ESP8266 NodeMCU

BH1750 Ambient Light Sensor

Jumper wires

Breadboard

Wiring:

Connect the components as follows:

Connect the BH1750 sensor:

Connect the sensor's VCC pin to 3.3V on the NodeMCU.

Connect the sensor's GND pin to GND on the NodeMCU.

Connect the sensor's SDA pin to D2 on the NodeMCU.

Connect the sensor's SCL pin to D1 on the NodeMCU.

Arduino Code:

#include <Wire.h>

#include <BH1750.h>

BH1750 lightMeter;

void setup(){

  Serial.begin(9600);

  // Initialize the I2C bus (BH1750 library doesn't do this automatically)

  Wire.begin();

  // On esp8266 you can select SCL and SDA pins using Wire.begin(D4, D3);

  // For Wemos / Lolin D1 Mini Pro and the Ambient Light shield use Wire.begin(D2, D1);

  lightMeter.begin();

  Serial.println(F("BH1750 Test begin"));

}

void loop() {

  float lux = lightMeter.readLightLevel();

  Serial.print("Light: ");

  Serial.print(lux);

  Serial.println(" lx");

  delay(1000);

}

Instructions:

Copy the code into the Arduino IDE.

Upload the code to your ESP8266 NodeMCU.

Open the Serial Monitor to view the light intensity readings.

This example initializes the BH1750 sensor and reads light intensity from it. Adjust the pin configurations as needed for your specific setup. The BH1750 library simplifies communication with the sensor, making it easy to retrieve ambient light data

ambient light sensor,light sensor,bh1750,ambient light sensor arduino,bh1750 light sensor,sensor,light,bh1750 light sensor arduino,#bh1750 digital light sensor,arduino light lux meter with bh1750 and oled 128x64,ambient light,digital light sensor,bh1750 sensor module,bh1750 sensor,i2c light sensor,home assistant light sensor,hassio light sensor,arduino bh1750 sensor module,home automation light sensor,light intensity meter arduino

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.