BH1750 upgrades (#2725)
* BH1750 upgrades Moved the definitions into the main usermods_list.cpp instead of having a section to copy across. Added Home Assistant Discovery topic for light sensor. This is toggleable from the usermod menu. * Configure pin, other enhancements, readme Implemented pin manager Made pins configurable at runtime Improved info screen outputs Added F() around strings Updated readme * Resolve conflict * Merge branch 'main' * Missing comma Co-authored-by: Christian Schwinne <dev.aircoookie@gmail.com> Co-authored-by: Christian Schwinne <cschwinne@gmail.com>
This commit is contained in:
		| @@ -3,22 +3,47 @@ | ||||
| This usermod will read from an ambient light sensor like the BH1750 sensor. | ||||
| The luminance is displayed both in the Info section of the web UI as well as published to the `/luminance` MQTT topic if enabled. | ||||
|  | ||||
| ## Installation | ||||
| ## Dependencies | ||||
| - Libraries | ||||
|   - `claws/BH1750 @^1.2.0` | ||||
|   - This must be added under `lib_deps` in your `platformio.ini` (or `platformio_override.ini`). | ||||
| - Data is published over MQTT - make sure you've enabled the MQTT sync interface. | ||||
|  | ||||
| Copy the example `platformio_override.ini` to the root directory.  This file should be placed in the same directory as `platformio.ini`. | ||||
| ## Compiliation | ||||
|  | ||||
| ### Define Your Options | ||||
| To enable, compile with `USERMOD_BH1750` defined  (e.g. in `platformio_override.ini`) | ||||
| ```ini | ||||
| [env:usermod_BH1750_d1_mini] | ||||
| extends = env:d1_mini | ||||
| build_flags = | ||||
|     ${common.build_flags_esp8266} | ||||
|     -D USERMOD_BH1750 | ||||
| lib_deps =  | ||||
|     ${esp8266.lib_deps} | ||||
|     claws/BH1750 @ ^1.2.0 | ||||
| ``` | ||||
|  | ||||
| *   `USERMOD_BH1750`                                - define this to have this user mod included wled00\usermods_list.cpp | ||||
| *   `USERMOD_BH1750_MAX_MEASUREMENT_INTERVAL`       - the max number of milliseconds between measurements, defaults to 10000ms | ||||
| *   `USERMOD_BH1750_MIN_MEASUREMENT_INTERVAL`       - the min number of milliseconds between measurements, defaults to 500ms | ||||
| *   `USERMOD_BH1750_FIRST_MEASUREMENT_AT`           - the number of milliseconds after boot to take first measurement, defaults to 10 seconds | ||||
| *   `USERMOD_BH1750_OFFSET_VALUE`                   - the offset value to report on, defaults to 1 | ||||
| ### Configuration Options | ||||
| The following settings can be set at compile-time but are configurable on the usermod menu (except First Measurement time): | ||||
| *   `USERMOD_BH1750_MAX_MEASUREMENT_INTERVAL` - the max number of milliseconds between measurements, defaults to 10000ms | ||||
| *   `USERMOD_BH1750_MIN_MEASUREMENT_INTERVAL` - the min number of milliseconds between measurements, defaults to 500ms | ||||
| *   `USERMOD_BH1750_OFFSET_VALUE` - the offset value to report on, defaults to 1 | ||||
| *   `USERMOD_BH1750_FIRST_MEASUREMENT_AT` - the number of milliseconds after boot to take first measurement, defaults to 10 seconds | ||||
|  | ||||
| All parameters can be configured at runtime using Usermods settings page. | ||||
| In addition, on the Usermod screen allows you to: | ||||
| - enable/disable the usermod | ||||
| - Enable Home Assistant Discovery of usermod | ||||
| - Configure the SCL/SDA pins | ||||
|  | ||||
| ### PlatformIO requirements | ||||
|  | ||||
| If you are using `platformio_override.ini`, you should be able to refresh the task list and see your custom task, for example `env:usermod_BH1750_d1_mini`. | ||||
| ## API | ||||
| The following method is available to interact with the usermod from other code modules: | ||||
| - `getIlluminance` read the brightness from the sensor | ||||
|  | ||||
| ## Change Log | ||||
| Jul 2022 | ||||
| - Added Home Assistant Discovery | ||||
| - Implemented PinManager to register pins | ||||
| - Made pins configurable in usermod menu | ||||
| - Added API call to read illuminance from other modules | ||||
| - Enhanced info-screen outputs | ||||
| - Updated `readme.md` | ||||
		Reference in New Issue
	
	Block a user
	 albarlow
					albarlow