-
Notifications
You must be signed in to change notification settings - Fork 631
Description
Device
D1mini with soldered on bh1750 and the mmwave sensor
Version
Current dev branch (3a34f06)
Question
Hi all :)
My usage of espurna in this case is to detect if a room is occupied and get a normalized lux reading to then trigger lights. The espurna device is only reporting everything to MQTT, all the logic is done within node red.
I used almost the same setup for years with old PIR sensors, but the PIR sensors are triggering every ~30 seconds if movement is detected. The mmwave module on the other hand has complex outputs which can detect a lot of different things, but I am only interested in the simple output on pin S1: high level - occupied, low level - unoccupied.
It works like my following configuration somewhat, but I am sure the configuration can be done better. Only the bh1750 and the mmwave sensor are connected to the D1 mini. I started with the example on the buttons and switches page.
My questions are:
- Do I need a relay configuration at all for this usecase? I tried it without, but it did not seem to work. But maybe I changed something else I am not aware of or I don't understand the relation between relay and switch. 🤷♂️
- I get a "pressed" event when the sensor detects a person, but I did not get "released" events without setting
BUTTON_MQTT_SEND_ALL_EVENTSto1. I am pretty sure my switch config is not as it should be. - Since node red can lose its state of the presence sensor, is there a way to query the button state or to re-transmit the current state regularly? I get the keep alive messages, but they don't contain the switch state.
Also I created a 3d printed case for this whole setup and I am gladly sharing everything, if somebody is interested. Once it works as expected I can make a PR with my settings here, or document it all on printables.com where I will upload the case.
code/espurna/config/hardware.h
#elif defined(WEMOS_D1_MINI_PRESENCE_BH1750)
// Info
#define MANUFACTURER "WEMOS"
#define DEVICE "WEMOS_D1_MINI_PRESENCE_BH1750"
// Buttons
// No buttons on the D1 MINI alone, but defining it without adding a button
// dosn't create problems
#define BUTTON1_PIN 0 // Connect a pushbutton between D3 and GND,
// it's the same as using a Wemos one button shield
#define BUTTON1_MODE BUTTON_SWITCH | BUTTON_DEFAULT_LOW
#define BUTTON1_RELAY 1
// The switch should send pressed and released, but i did not get released to work without this:
#define BUTTON_MQTT_SEND_ALL_EVENTS 1
// Relays
#define BUTTON2_PIN 5
#define BUTTON2_RELAY 0
#define BUTTON2_MODE BUTTON_SWITCH
#define BUTTON2_PRESS BUTTON_MODE_ON
#define BUTTON2_CLICK BUTTON_MODE_OFF
#define BUTTON2_DBLCLICK BUTTON_MODE_NONE
#define BUTTON2_LNGCLICK BUTTON_MODE_NONE
#define BUTTON2_LNGLNGCLICK BUTTON_MODE_NONE
// LEDs
#define LED1_PIN 2
#define LED1_PIN_INVERSE 1
// When Wemos relay shield is connected GPIO5 (D1) is used for relay,
// so I2C must be remapped to other pins
#define I2C_SDA_PIN 12 // D6
#define I2C_SCL_PIN 14 // D5code/platformio.ini
[env:wemos-d1mini-presence-bh1750]
board = d1_mini
build_flags = -DWEMOS_D1_MINI_PRESENCE_BH1750 -DDEBUG_FAUXMO=Serial -DNOWSAUTH -DBH1750_SUPPORT=1connection table
- Using the seedstudio mmwave static pressure sensor
- The Mmwave sensor has a 8 and a 6 pin plug. We use the 6 pin Plug for connection.
| Wemos D1 Mini | Connected to |
|---|---|
| 5V | Mmwave 5V (top left) |
| GND | Mmwave GND (top right) |
| D1 | Mmwave S1 (bottom left) |
| 3.3V | BH1750 VCC |
| GND | BH1750 GND |
| D5 | BH1750 SCL |
| D6 | BH1750 SDA |