summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md15
1 files changed, 8 insertions, 7 deletions
diff --git a/README.md b/README.md
index f5c22c8..fc9b78f 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
-# ESP8266 Lua/NodeMCU module for MAX44009 illuminance sensor
+# ESP8266 Lua/NodeMCU module for MAX44009 illuminance sensors
This repository contains an ESP8266 NodeMCU Lua module (`max44009.lua`) as well
as MQTT / HomeAssistant / InfluxDB integration example (`init.lua`) for
-**MAX44009** illuminance sensors.
+**MAX44009** illuminance sensors connected via I²C.
## Dependencies
@@ -41,15 +41,16 @@ Copy **max44009.lua** to your NodeMCU board and set it up as follows.
```lua
max44009 = require("max44009")
-i2c.setup(0, sda_pin, scl_pin, i2c.SLOW)
+i2c.setup(0, 1, 2, i2c.SLOW)
-- can be called with up to 1 Hz
function some_timer_callback()
local lx = max44009.read()
- if lx == nil then
+ if lx ~= nil then
+ -- lx : Illuminance as floating point value [lx]
+ else
print("MAX44009 error")
else
- -- lx contains the illuminance. Note that it is a floating point value.
end
end
```
@@ -60,7 +61,7 @@ end
To use it, you need to create a **config.lua** file with WiFI and MQTT settings:
```lua
-station_cfg = {ssid = "foo", pwd = "bar"}
+station_cfg = {ssid = "...", pwd = "..."}
mqtt_host = "..."
```
@@ -72,5 +73,5 @@ influx_url = "..."
influx_attr = "..."
```
-Readings will be stored as `max44009[influx_attr] illuminance_lx=...`.
+Readings will be stored as `max44009[influx_attr] illuminance_lx=%f`.
So, unless `influx_attr = ''`, it must start with a comma, e.g. `influx_attr = ',device=' .. device_id`.