Somehow I don’t know where to go. For about 4 years my light sensor (BH1750) worked without problems. Since about half a year it does not work anymore. And I cannot find the cause of the problem. The sensor is obviously not found from time to time. And that changes apparently in a second.
My setup:
Raspberry, Cat5 cable (about 25m), sensor (BH1750 GY30), without pull-up resistor, operated with 3.3V.
This setup ran for 4 years without problems.
A few months ago I had the first dropouts. The sensor delivered a false value every few minutes. First I thought about a defect on the sensor, but it wasn’t, as I found out later. A new sensor showed the same behavior. In the meantime I get these dropouts every second.
Then I thought it was a problem with the wiring. But another, new sensor, much closer to the Raspberry (so also with a different, shorter cable, about 4m) has the same problems. Without the long cable and without some connections.
I regularly do Udgrads on the Raspberry. Has anything changed in the drivers for I2C?
When I run “i2cdetect -y 1” I only get the address of the sensor after a few tries. So the sensor is always absent.
Nothing has been changed in the wiring. Nobody has touched it. So where does this problem come from after more than 4 years without problems?
Can someone help me or give me a hint what I have to test, test to find the cause of the error.
-
Error with i2c, BH1750 Error after about 4 years
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." 09-28-2003, LINUS TORVALDS (http://www.nytimes.com)
-
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." 09-28-2003, LINUS TORVALDS (http://www.nytimes.com)
-
Okay, it’s a long line, but it’s worked for four years. And the test with a shorter line failed too.
What size should the capacitors be? In the nF range? Between SCL / GND and SDA / GND?
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." 09-28-2003, LINUS TORVALDS (http://www.nytimes.com)
-
The capacitor must be placed between the 3.3V (capacitor +) and ground. Not the data pins!
Value is a bit depending on power consumption of the sensor. 10 uF to max 100 uFThis is just to solve or rule this type of problem.
-
When power was not the problem you could do the following before going to the software.
- Add pull-up resistors on SDA and SCL
- Use another BH1750 GY30. If this works the old sensor is broken or unreliable
-
So to stabilize the tension.
I tried this once with 47 uF. Doesn’t work either.I think the sensor should be intact. I had it for some time to test on a Sonoff 4CH (with tasmota) and it ran.
Pull-up I have also tested with 3k3. Also without success.Something else is funny. If it detects the sensor (0x23), it still finds an address (0x03). There is only one i2c device on the bus.
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." 09-28-2003, LINUS TORVALDS (http://www.nytimes.com)
-
Yes, that’s it. If the sensor is not attached, i2cdetect will not show any output.
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." 09-28-2003, LINUS TORVALDS (http://www.nytimes.com)
-
Is it possible that the Raspberry has a defect at I2C?
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." 09-28-2003, LINUS TORVALDS (http://www.nytimes.com)
-
Yes that could be, to rule you need to use another rpi. If you got another exactly the same type of rpi you just could use the flash card or usb drive of your current rpi (or use a backup, thats a bit saver)
If you want to test the sensor an arduino is also doing i2c and easy to do a test with.
Because i2cdetect is also using the rpi i2c functions, the readings could be wrongTo be sure is would suggest you do the ‘Sonoff 4CH (with tasmota)’ test again.
Debugging hardware and ‘firmware’ asks for endurance
-
I have now changed the RPi. After some trouble with the internal IP addresses it ran after some time. The test with i2cdetect unfortunately gave the same result as I had before with the first RPi. So the problem is probably not the RPi.
Only with my i2c problem I am no further 😬."Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." 09-28-2003, LINUS TORVALDS (http://www.nytimes.com)
-
After further trouble to swap back the IP addresses of the second and first RPi I swapped the sensor from outside with the one on the Sonoff again. (The sensor on the Sonoff currently takes over the tasks of the other sensor)
With the result as before. On Sonoff, he’s giving me realistic readings. He’s working.
And now the strangest thing, the sensor that was plugged into the Sonoff, this sensor on the long cable, outside, suddenly shows me realistic values over a few minutes at least. I2Cdetect shows me the 0x23 with every call, and the 0x03 I don’t see anymore.
But I don’t believe the sudden healing. I’m afraid it starts again after a while with the problems. I did not find an error after all. Exactly in this constellation I had it already a few times. Apart from the fact that the capacitors are still connected to the long cable."Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." 09-28-2003, LINUS TORVALDS (http://www.nytimes.com)
-
The sensor on the Sonoff currently sticks to a window with adhesive tape.
I had tried (as an alternative to my long working, long cable RPi sensor) to solve my brightness system with the Sonoff. But if I connect the sensor to the Sonoff with a longer cable, the sensor won’t work on it either. With “longer” I mean in this case more than 10cm cable.
1m cable still works, but with dropouts.
4m cable does not work at all.
Unfortunately I need to have some cable length between Sonoff and sensor."Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." 09-28-2003, LINUS TORVALDS (http://www.nytimes.com)
-
I looked into the plugin and the underlaying BH1750 lib.
The most recent BH1750 lib version is 0.0.5 but the plugin is sticked to 0.0.3.
You could update to version 0.0.5.Did you try the option to run the command ‘npm test’ in the pimatic-bh1750 directory?
It uses the underlaying lib directly.npm test # light value is: 20 lx
-
@thrusty said in Error with i2c, BH1750 Error after about 4 years:
The sensor on the Sonoff currently sticks to a window with adhesive tape.
I had tried (as an alternative to my long working, long cable RPi sensor) to solve my brightness system with the Sonoff. But if I connect the sensor to the Sonoff with a longer cable, the sensor won’t work on it either. With “longer” I mean in this case more than 10cm cable.
1m cable still works, but with dropouts.
4m cable does not work at all.
Unfortunately I need to have some cable length between Sonoff and sensor.Do i read it right that the cable length is an issue?
You are using a cat5 cable with 4 twisted pairs. Are you using the 1 twisted pair for power and 1 twisted pair for SDA/SCL?
I keep saying use the pull-up resistors, otherwise you get floating inputs and thats bad if there’s noise. -
Here is my issue on npm test
pi@rpi_strech:~/pimatic-app/node_modules/pimatic-bh1750 $ npm test > pimatic-bh1750@0.2.0 test /home/pi/pimatic-app/node_modules/pimatic-bh1750 > echo "Error: no test specified" Error: no test specified
"Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." 09-28-2003, LINUS TORVALDS (http://www.nytimes.com)
-
Is there a subdirectory example with the file index.js?
If not just add it manual (i used text editor nano in this example)
The command line command are:
mkdir example
cd example
nano index.jsText to cut&paste
var console = require('console'); var BH1750 = require('../bh1750'); var light = new BH1750(); light.readLight(function(err, value){ if (err) { console.log("light error: " + err); throw err; } else { console.log("light value is: ", value, "lx"); } });
save the file, exit nano, cd … and npm test should work