I have made an attempt at improving the BH1750 demo sketch and it is available for comment
Posted: 01 Oct 2017 14:55
Motivation
After I've toyed with the Z-Uno demo sketches (see http://z-uno.z-wave.me) for some time, I thought I would show a little ambition and at the same time seek feedback from experienced users. I took the BH1750 sketch and improved the reporting range (from about 13000 to about 79000 Lux), add detection of I2C bus errors and add an algorithm to calculate reporting interval, getting good responsiveness without spamming the Z-Wave network. I would really appreate if you could review it, or even try it. Then give me some comment, criticism or advice! I will use it to refine this sketch and develop other solutions!
Features
- Measures 1 x per second, so you can poll at any time and get a value that is no older than about 1 second.
- Reports 0 - 78642 Lux. Resolution: 1.2 Lux (Original Demo Sketch: max about 13000 Lux).
- Plenty of debugging output via USB (serial emulation). Can be disabled by changing two lines in the sketch.
- Honours minimum 30 second reporting interval for unsollicited reports.
- Automatic reporting interval, ranging from 30 seconds up to 32 minutes. If light level doubles or halves, the sensor reports as soon as possible (honouring the minimum of 30 seconds between unsollicited reports). If changes are smaller, reporting time increases. Tested by me, indoors and outdoors. (Original Demo Sketch: fixed reporting).
- Detects I2C bus errors. LED blinks+ automatic bus reset. Sensor can be hot plugged. (Original Demo Sketch: no detection of bus errors, sketch does not recover from bus errors).
- Plenty of comments in source code.
- Uses timer(s) and avoids delay() to get maximum responsiveness.
- White LED blips when data gets transferred to the controller.
Download and readme:
https://github.com/petergebruers/Z-Uno-BH1750
After I've toyed with the Z-Uno demo sketches (see http://z-uno.z-wave.me) for some time, I thought I would show a little ambition and at the same time seek feedback from experienced users. I took the BH1750 sketch and improved the reporting range (from about 13000 to about 79000 Lux), add detection of I2C bus errors and add an algorithm to calculate reporting interval, getting good responsiveness without spamming the Z-Wave network. I would really appreate if you could review it, or even try it. Then give me some comment, criticism or advice! I will use it to refine this sketch and develop other solutions!
Features
- Measures 1 x per second, so you can poll at any time and get a value that is no older than about 1 second.
- Reports 0 - 78642 Lux. Resolution: 1.2 Lux (Original Demo Sketch: max about 13000 Lux).
- Plenty of debugging output via USB (serial emulation). Can be disabled by changing two lines in the sketch.
- Honours minimum 30 second reporting interval for unsollicited reports.
- Automatic reporting interval, ranging from 30 seconds up to 32 minutes. If light level doubles or halves, the sensor reports as soon as possible (honouring the minimum of 30 seconds between unsollicited reports). If changes are smaller, reporting time increases. Tested by me, indoors and outdoors. (Original Demo Sketch: fixed reporting).
- Detects I2C bus errors. LED blinks+ automatic bus reset. Sensor can be hot plugged. (Original Demo Sketch: no detection of bus errors, sketch does not recover from bus errors).
- Plenty of comments in source code.
- Uses timer(s) and avoids delay() to get maximum responsiveness.
- White LED blips when data gets transferred to the controller.
Download and readme:
https://github.com/petergebruers/Z-Uno-BH1750