Because my first idea for this project was the presence controlled light, it is time to implement this feature.
I have several rooms to integrate, so I wanted a cheap solution. Simple PIR Sensors are cheap, but they can't detect the presence of a person, just the movements. This makes it a good choice for hallways, but won't work for other rooms, where you don't move significantly for some time.
To bypass this problem, I will place one sensor in each room, so that a sensor will trigger, when I enter a room. Consequently, the system will know in which room I am, on the basis of the last triggered sensor. When the current room is changed, events like switching on/off lights are fired.
Because the sensors need to observe the doors for this, I designed a simple mount for them and screwed them to the door frame. Currently only my office has this mount, but the other rooms will follow.
I also want to have some other sensors in all rooms (currently light and temperature), so I attached them to the PIR mount.
As light sensor I use a photoresistor combined with an 1M Ohm resistor, working as a light dependent voltage divider. This voltage is read by the ESP8266, so it needs to be between 0 and 1 Volts, which is the reason for the 1M resistor. The temperature sensor is a ds18b20, which can be addressed via the 1-Wire protocol.
All data is saved in a central database and be available for me to generate nice diagrams. The values of the light sensors are also used to determine whether it is necessary to turn on the lights.
This prevents the system from wasting energy.
Each Sensorboard will get its own ESP8266, which I program with nodemcu.
I expect that I will have to change the programs on them quite often, so the standard upload method via a USB Serial Adapter would not be very practical.
To address this discomfort, I made a simple combined http and telnet server, which adds a telnet backdoor to the single nodemcu server. With this, I am able to connect to the nodemcu shell via putty and upload code with the luatool. The code for this server is available on github: https://github.com/Malte-D/nodemcu-http-telnet
I also integrated my remote controlled curtains in my bedroom (see link on the left), by connecting an ESP to it. The ESP is also connected to the sensors mentioned above.
As mentioned in the previous update, the ceiling light is controlled by a modified remote controlled outlet. I removed the power plug and attached it directly to the lamp.
Here is an image of the original outlet:
The commands are sent by the raspberry pi through the corridor arduino. To replace the wall switch, I used an of the shelve 433Mhz switch, which I attached to the wall where the old switch was.
It uses a different protocol than the remote outlets, but this is no problem, because the arduino can receive the commands and forward them to the outlet.