The idea is to monitor via several sensors the status of the house and to have some kind of control. We will also have a gesture sensor attached to a relay, we can then swipe to turn on and of the lights. The sensors will post their data to a MySQL server running on a raspberry pi 3.
Per room I have decided:
- 1 x ESP8266 NodeMcu (the micocontroller with WiFi) EUR 3,15 China.
- 1 x relay (the relay allows you to control house mains power turning it on and of) EUR 1,00 China.
- 1 x DHT22 (the DHT22 allows monitoring of temperature and humidity) EUR 2,89 China.
- 1 x Door Or Window Contact Magnetic Reed Switch (apply to windows, detects if windows is open or closed) EUR 2,48.
- 1 x PIR Motion Human Sensor (detects movement, my idea is to position near the door not to monitor the room itself) EUR 4,65.
- 1 x Apds-9960 (this is a gesture sensor, we will use this to turn the relay on and off using hand gestures) EUR 2,01.
Total price = 16.18 (price is estimate just made random ebay searches, no doubt could get cheaper buy buying packs of 5 ect. I estimate Euro 12.50 per room).
The main challenge i have had so far is controlling how the data is inserted into the MySQL database. I am learning as i am going and thus may not be using best practises but my aim is “get it to work”.
Even if i have to rewrite all of the code for security / reliablity or even debugging thats fine, but for now I will be just getting the system linked together and working.
The second challange i have is PHP iv never used PHP so scrapping the internet of database controll has been a real mission.
So how far have i got?
I have added the gesture sensor and realy to the NodeMcu, i am able to controll the relay via hand movement.
I have managed to get the NodeMcu to post the status either “light on” and Light off” to a MySQL database, i have done this via posting the paramater 0 or 1 to a PHP page. The PHP page then updates the database.
Geture On -> Relay turns on -> URL post to PHP Page -> PHP Page updates database.
I have also created a website that can show the current status 0 = off 1 = on, it got a little complicated here. I needed a way to change the status via a webpage. I knew the NodeMcu will accept paramerters aswell so after a little googling i found Curl was a best approach.
Website posts 1 or 0 to Curl page -> Curl creates the url post to NodeMcu -> NodeMcu turns light on or off -> NodeMcu then posts new status back to MySQL.
I agree to accept feedback, but please provide feedback on your ideas or even how i can make this better. Any comments like “left open to MySQL injection” ect ect without how to actually fix it, is not feedback and such will not be approved for commenting