Closed Milor123 closed 5 months ago
SOLVEDDDD, know understand it hahahaha, sorry for the issues, it was my firts time try.
I need delete all prints and only keep print with data Serial.println(lux);
, also I've change the type of data of lux variable to FLOAT
like in your example, and change the Serial.begin(9600);
value to 9600
this code works for BH1750 GY310
the author named it as BH1750OneTimePowerMgt
#include <Wire.h>
#include <ErriezBH1750.h>
// ADDR line LOW/open: I2C address 0x23 (0x46 including R/W bit) [default]
// ADDR line HIGH: I2C address 0x5C (0xB8 including R/W bit)
BH1750 sensor(LOW);
void setup()
{
Serial.begin(9600);
while (!Serial) {
;
}
// Initialize I2C bus
Wire.begin();
// Initialize sensor in one-time mode, medium 1 lx resolution
sensor.begin(ModeOneTime, ResolutionMid);
}
void loop()
{
float lux;
// Power on and start conversion
sensor.startConversion();
// Wait for completion (blocking busy-wait delay)
if (sensor.waitForCompletion()) {
// Read light
lux = sensor.read();
// Print light
Serial.println(lux);
} else {
}
// Device is automatically set in power-down after one-time conversion, but
// powerDown() can be explicitly called as well
//sensor.powerDown();
// Implement power management and interrupt support here for low-power
// devices instead of the delay example below
delay(1000);
}
I want add the sketch used for it (download from https://github.com/Erriez/ErriezBH1750?tab=readme-ov-file)
File with codes examples of Erriez. ErriezBH1750-1.1.2.zip
Once again, I would like to express my gratitude for this wonderful application, and once again I would like to give my regards to its author. ❤️
Hey, that's great news that you managed to sort this out. Thanks for taking the time to raise the issue and write up a solution.
I wasn't aware that the GY302/BH1750 differed in the coding required from the GY30. To clarify the situation I'll add some documentation to the Lux-metering.md and refer to this issue.
You're the only other confirmed user of hardware light metering. I suppose there might be a few others lurking out there. It's nice to know at another user actually exists. 👍
I've added a note to Lux-metering.md.
Closing this for now. Although at some point in the future it might be good to put all this kind of stuff in a wiki.
Hey, Brother, how are you? I tell you I accidentally bought a "BH1750" chip but in reference "GY302" and not "30"
However I have read and find the next code to go up in my Nano port.
https://github.com/Erriez/ErriezBH1750?tab=readme-ov-file
I have modified some things, adjusting the following values as your version:
Serial.begin(9600); float lux; delay(1000);
I have made sure to give all the permissions and things as you indicated in your publication for the linux. I also check on the IDE Arduino monitor that everything was working, the print correctly returns the sensor values.
But I don't understand what else I have to change to work with the VDU
VDU always show lux in 0, the tty link is working perfect.
Update: I've tried use the --debug mode and get this
it shows
[Errno 16] could not open port /dev/arduino: [Errno 16] Dispositivo o recurso ocupado
that the device is bussy.Then of try delete all print lines on arduino code, and run python
vdu_controls.py --debug
and it dont shows erros but not works in VDU, lux always shows 0 valueI also try rename /home/noe/.config/vdu_controls to vdu_controls.bak for restore to default and test again, but the result its the same