BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

BH1750 Widget


#1

Hello Everyone, Im new here in blynk community.
Last night I put together a code for my BH1750 Lightmeter and it works fine but I have some issues with the widget in the blynk app.

It seems that the widgets will not show higher values then 1023 and we all know that a sunny day reads way higher levels then 1023.

Is there any way to set the widgets to reach higher levels then 1023 ?

Below you can se my code (Im not sure if its the right way to post the code like that, I tried to find out but could not find it so if it is wrong please let me know and I will correct it).

As I am a newbie to both the arduino language and blynk I would be happy if your answers are not to complicated.

MY CODE:

#define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <SimpleTimer.h>

#include <Wire.h>
#include <BH1750.h>

BH1750 lightMeter;

char auth[] = "-----------";
char ssid[] = "-----------";
char pass[] = "-----------"

SimpleTimer timer;

/********************************************************************************************/

void sendUptime(){
  
  uint16_t lux = lightMeter.readLightLevel();
  Blynk.virtualWrite(V5, lux);
}

void setup(){

  Serial.begin(9600);
  
  Blynk.begin(auth, ssid, pass);
  
  // 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);

  timer.setInterval(1000L, sendUptime);    // Temperature sensor read interval. 2000 (ms) = 2 seconds.
  
  lightMeter.begin();
  
}

void loop() {
  Blynk.run();
  timer.run();
}

#2

Every forum has a Welcome or Read Me topic… this is ours :wink: I already fixed the formatting.


#3

Thank you Gunner, I will read it !
This is my first time accualy starting a topic in a forum ever so Im sorry for that.


#4

Display type widgets can be set for pretty much whatever reasonable range you want.

image


#5

You don’t seem to have any code for your light meter… so I guess you are reading the analog pin directly with the widget, and not using code and virtual pins… thus the 1023 limit is the range limit of the ESP’s ADC, and not a gauge issue.

EDIT: nope, not the Analog pin… looks like I2C… and I found your code tucked up before the setup() loop :stuck_out_tongue:


#6

Now I feel so stupid :weary:
It was realy that easy, well then my problem is solved and I am a member in the blynk community.
I have been reading alot of posts in the community and it has been very helpful.
Thank you Gunner !


#7

I changed my topic to “solved” now.

Lux goes up too 9999 now and thats enough for me so thanks again.


#8

Yes thats right, its a I2C bus on my wemos D1mini :smiley:
Now I will add some other sensors as well.
DS18B20, BME280 but that should go just fine…I think :wink: