This device contains an 'on-air' like light that connects directly to a doorsensor via LoRaWAN. The idea is that the light will blink whenever the door opens. It also indicates when the battery energy is low.
The communication with the doorsensor and the light happens via LoRaWAN. In order to circumvent the need of a gateway, a significant part of the LoRaWAN 1.0.2 stack is implemented into the light. For the doorsensor we need to use Activation By Personalization (ABP) using unconfirmed messages.
As this will be a single channel receiver, ADR is not implemented and disabled by default.
For this light the following
- 1 Dragino LDS02 doorsensor.
- 1 NodeMCU ESP8266 microcontroller. (Any other 3.3v microcontroller will work)
- 1 WS2812B RGB ledstrip. (Above example uses 44 leds)
- 1 HopeRF RFM95W Lora Receiver
- Cables and charger
- Acces to a 3d printer
In the folder /case/prints
there are three models one can print.
The files front.stl
and back.stl
are the enclosure of the light.
Seperately, one needs to find a semi translucent sheet of plastic that act as the front glass plane. One has to glue that plane to the front using super glue. The back and front can be bolted together using m3 bolts. The holes are designed a bit too small, so one can drill them to size.
In the file text.stl
one can find the text Voordeur. These letters van be glued to the front plane using super glue. In order to position them correctly, a placing template is added to the file.
The folder /firmware
contains the source code that one has to flash to the NodeMCU. Using VSCode and PlatformIO one can compile and flash the microcontroller. The main code is inside main.cpp
. In the beginning of the file, there are variables one can change to to ones own preferences.
- Settings w.r.t. the ledstrip
- NUM_LEDS: Number of leds on the RGB strip. Default 44
- Settings w.r.t. LoRaWAN
- FREQUENCY: Frequency the LoRa receiver listens on. Default 868.1MHz.
- SPREADING_FACTOR: Spreading factor the LoRa receiver listens on. Default SF9 or DR3.
- devAddr: Device Address of the door sensor.
- appSKey: AppSKey of the door sensor.
- NwkSKey: NwkSKey key of the door sensor.
- Settings w.r.t. Colors
- COLOR_BOOT: Color to show at boot. Default orange.
- COLOR_DOOR: Color to show when door opens. Default green.
- COLOR_BATTERY: Color to add to the above when battery is running low. Default red.
- Settings w.r.t. pinout
- LORA_CS_PIN: ModeMCU pin that is connected to the Lora chip select pin. Default
D8
. - LORA_RESET_PIN: ModeMCU pin that is connected to the Lora seset pin. Default
D0
. - LORA_IRQ_PIN: ModeMCU pin that is connected to the Lora dio0 pin. Default
D2
. - WS2812B_PIN: ModeMCU pin that is connected to the ledstrip. Default
D3
.
- LORA_CS_PIN: ModeMCU pin that is connected to the Lora chip select pin. Default
- Other settings
- LOW_BATTERY_VOLTAGE: Voltage that is considered low. Default 2200mV.
Unless changed, connect the led strip as follows:
- +5V: Connect to the VIN pin of the NodeMCU
- GND: Connect to one of the GND pins of the NodeMCU
- DIN: Connect to one of the D3/GPIO0 pin of the NodeMCU
Unless changed, connect the LoRa receiver as follows:
- GND: Connect to one of the GND pins of the NodeMCU
- MISO: Connect to one of the D6/GPIO12 pin of the NodeMCU
- MOSI: Connect to one of the D7/GPIO13 pin of the NodeMCU
- SCK: Connect to one of the D5/GPIO14 pin of the NodeMCU
- NSS: Connect to one of the D8/GPIO15 pin of the NodeMCU
- RESET: Connect to one of the D0/GPIO16 pin of the NodeMCU
- DIO0: Connect to one of the D2/GPIO4 pin of the NodeMCU
- 3.3v: Connect to the 3.3V pin of the NodeMCU
- ANA: Connect to the antenna
Leave the rest unconnected.
By default the doorsensor won't work with the light as it will communicates with the all 8 channels while we can only receive one. For this we have to set it into single channel mode. To do this we have to send the configure the device using AT commands. See the Wiki for more information. We run the following commands. Comments should not be send to the doorsensor!
AT+CJOINMODE=1
AT+CDEVADDR=00981359 // Replace this with your own DevAddr
AT+CAPPSKEY=3e3e4c4be1a69112a2a286379ad63414 // Replace this with your own AppSKey
AT+CNWKSKEY=ef9c2a59aa2145eb41ac61f4d321e91f // Replace this with your own NwkSkey
AT+CCONFIRM=0 // Set mode to confimed
AT+DDETECT=0,1440,2880
AT+CADR=0 // Disable ADR
AT+CRX1DELAY=1 // SET RxWindowDelay to 1 second.
AT+TTRIG=0,0 // Disable Alarm
AT+CHS=868100000 // Set single channel mode's frequency
AT+CDATARATE=3 // Set Data rate
AT+CSAVE // Save settings