ESP8266 Based Multisensor
by enesbcs in Circuits > Microcontrollers
5137 Views, 11 Favorites, 0 Comments
ESP8266 Based Multisensor
The ESP8266 is a handy little device which can be programmed and used easily, but we have to use the available GPIO pins wisely because there are not too many of them.
In this short summary I will show you how to attach multiple different sensors to it.
Parts
The most important part of this device is the casing, as i do not have a 3D printer, I used an existing motion sensor lighting casing. Luckily the hole on it is exactly the size of the SR501 motion sensors dome!
- Donwei Motion Sensor (ebay) (aliexpress)
- D1 Mini ESP8266 development board
- Prototype Paper PCB For DIY 5x7cm
- USB Port 5V 1A Wall Charger
- HC-SR501 Infrared PIR Motion Sensor Module
- RCWL-0516 Microwave Radar Sensor Module
- 1 x 10V 100uF Electrolytic capacitor (optional, just to minimize false alarms)
- 2 x 10K resistor (optional, just to minimize false alarms)
- MICRO USB To DIP Adapter 5pins
- DHT22 Temperature Humidity Sensor
- 4.7K resistor BH1750 Digital Light Intensity Sensor Module
- Piezo buzzer 3V
- 330 ohm resistor
- WS2812 1-Bit RGB Module
Scrap the inside panel from the casing, also cut off the battery holder, as it is takes up too much space.
Cut the prototype paper until it fits nicely into the casing, and try to arrange the components.
Wiring
Wire and solder the parts according to the fritzing diagram. The DHT22 is perhaps not so nice looking in that direction, but generally is not a good idea to place a temperature sensor into the casing as the active components inside are affecting the measured values. (and for the record: placing temperature sensor above active components is one of the worst ideas)
So i placed it on the right side of the casing, as the power supply arrives from down to the microUSB->DIP adapter. (it is below the RCWL)
Why i am using microwave RCWL and SR501 PIR motion sensors at the same time? Simply to filter out false positives: if both sensors says that there are something happening than it is almost 100% that a human motion triggered it. (the optional pull-down resistors may not needed, the capacitor may help more but also optional)
The BH1750 is placed behind the casing, but it is semi-transparent, so if there are light outside, it will sense it. (altough it will sense less, the casing can be drilled for letting more light to arrive to the sensor) For the same reason the WS2812 is also inside the casing and its emitted light will be visible through the plastic without a hole.
The RCWL is at the bottom (the opposite side where the D1 Mini is located) and the largest possible distance from the ESP8266's antenna as they are interfering slightly if they are too close to each other.
Firmware
If we wants to setup and use an ESP8266 based multisensor in the fastest possible way, it is a good idea to use ESPEasy! If you've never heared about it, you may missed the Smart Water Controller instructable.
Anyway, ESPEasy is a swiss-army-knife firmware that has many controllers and device plugins inside it, which can be easily set up with just a few clicks by anyone who has already seen the menu of a router. The firmware can be uploaded after plugging into an USB port, my personal favourite program for uploading is the nodemcu-pyflasher (multiplatform) but the downloadable ESPEasy also includes a (Windows-only) ESPEasy Flasher application.
After the first upload and restart, a new AP named "ESP_Easy_0" will appear, the default password is configesp.
( Read more about it here ) Then you can setup your own WiFi AP name and password through a browser visiting 192.168.4.1, and with a few clicks the necessary Controllers (Domoticz, Nodo, ThingSpeak, Home Assistant, PiDome, Emoncms, FHEM, Blynk, Homie, Zabbix) and Devices (more than 70 different, but 12 at the same time) can be added.
Do not forget to disable serial port usage at Tools->Advanced menu, and enable the Rules usage.
Rules are running locally, the semantics is not so complicated. (The rules i've used in this project is in rules1.txt )
There are a lot more possibility, the WS2812 LED may be controlled by the NeoPixel,[led nr],[red 0-255],[green 0-255],[blue 0-255] command, and the buzzer can be used either with simple tone or rtttl (Nokia Ringtone Player) commands.