As most this kind of sensor requires 5v to work reliably. In 3.3v it is proven that gives false positives or no detection of movement. So in a setup with esp8266 (or a NodeMCU board like I used) you must have a 5v output just for the PIR sensor.
Thankfully someone has found a solution without modifying the sensor as most propose (this is tested for the sensor working in repeat mode). Studying the schematics it is shown that instead of connecting the 5v power to the standard VDC input you can connect 3.3v directly to the lower pin of the High/Low trigger selection pin. You can read about this in the following blog post https://techgurka.blogspot.gr/2013/05/cheap-pyroelectric-infrared-pir-motion.html
Problem #2: Interference! PIR sensor acts crazy when in close proximity with esp8266/NodeMCU’s WiFi producing a lot of false alarms.
The solution is to put the WiFi of esp8266 to sleep until there is a movement trigger from the sensor with this code:
As mentioned you’ll need an IFTTT account and a webhooks (former maker) key to use in the code. So each time PIR sensor detects motion esp8266 connects to WiFi and fires a webhook event. For example a Pushbullet notification in your phone.
The schematic connecting PIR with a NodeMCU is the following:
An ON/OFF switch is also added to stop sending the alarms when needed.
It was about time to somewhat clean the code, update the README with instructions and also provide a demo Android app for my THE433 Home Automation
It’s a self contained ESP8266 RF433 Interface to control RF sockets from afar (with your personal IP or a DDNS service). No need for external services and servers (no MQTT, right now I prefer it that way..) and its main feature is that you can set RF signals to fire in the future or repeat over time.
You will need your afraid.org subdomain hash which you can get by logging in https://freedns.afraid.org/dynamic/ and checking the URL at the bottom of the page where it says Direct URL.
Oh well someone has to watch over our sewage pump. Which has already a panel that control when to start / stop the pump or when to turn on heat protection when there’s no “water” left.
The problem was that this control panel is two floors down and if we wanted to check its condition (i.e. after a power failure or if the pump has stopped for heat protection) we should make regular passes from the basement.
The good thing about this control panel is that it has its own LEDs showing the status of the pump (Power Supply, Motor On, Motor Protection, Automatic (on/off), Level Alarm and No Water Alarm).
Enter esp8266 / NodeMCU.
With the use of six photoresistors (CdS, LDR) we can read the status of each LED of the control panel and output its status on a web page. Yippee..
The schematics on how to connect LDRs to an esp8266 or a NodeMCU are all over the web if you look. For three LDRs for example is the following:
In the code I’m reading the digital output of each LDR as 0 or 1.
Putting the six LDRs in the correct positions was easy on a 9x15cm prototyping PCB (luckily 9cm was the height of the opening of the control panel).
Reversing the PCB and placing it over the control panel with a breadboard to hold the NodeMCU for testing:
there was some duct tape involved.. (Duct tape is for everything right?)
Aaand we have our output readings in a static IP in our network (where green color is good):
In the code of the NodeMCU (with Arduino IDE) there is also a part that connects with IFTTT Maker channel to notify me for important events.
control 433MHz (compatible with Arduino libs) sockets/devices through web and time rules ESP8266 RF433 Interface
(esp8266 + RF 433 transmitter + Arduino IDE)
This is a sketch for controlling RF remote control sockets or relays that operate at the 433MHz frequency and are compatible with the Arduino/esp8266 RCSwitch libraries.
The main feature is that you can schedule events (up to 10) to turn ON/OFF your devices that repeat daily/weekly or that actuate once only within a week from setting the command.
A web interface is used to control the RF devices directly given a relative command at the main form and also scheduling the time events by giving at the same form a keyword to enter the scheduled events interface.
In the whole sketch these scheduled events are named Time Commands.
Time Commands (up to 10) execute your functions that fire the 433MHz sockets operating devices and can be set:
– Alarm Once
(once when the time next reaches the given hour, minute)
– Daily Alarm Repeat
(every day at the given hour, minute)
– Weekly Alarm Once
(once only on the next DayOfWeek, hour, minute)
– Weekly Alarm Repeat
(every week on the given DayOfWeek, hour, minute)
Here’s a video showing some basic usage of the web interface
Coding is really basic since my knowledge of C++ is minimal but hey.. it works!
– navigate with your browser at this IP
– here you can enter either a command to activate a connected device (you must edit the source code) i.e. SWITCH 1 ON
or you can enter the provided keyword to enter the Time Commands interface i.e. ENTERTIMECOMMANDS
– at the Time Commands interface you can select a function you want to be executed at a specific time
– select the time to activate and submit
– you’ll have to restart your esp8266 and you’ll be informed about this
– after esp8266 restarts and reconnects you’ll find the saved Time Command at the bottom of the web interface (from there you can also delete it)