Hello. Some time ago I've been helping to my friend with smart home concept and created a mini sensor box with a custom design that could be mounted on the ceiling into the 40x65mm hole. This box helps to:
• measure the light intensity
• measure humidity
• temperature measuring
• it has focusable and eyeball mount construction for PIR sensor, so it can detect motion and turn on the external device (alarm, light), based on the conditions, so it can monitor a tiny area
This sensor box has own web server with font awesome icons, so data could be accessible from any place with internet connection. Overall costs is less than 10 USD, so it's a very cheap solution.
• Wemos D1 mini board, e.g. from aliexpress
• GY-21 (SI7021) humidity sensor, like this one
• GY-302 (BH1750) light intensity sensor, like this one
• HC-SR505 or AS-312 mini infrared motion sensor, both sensors could be found e.g. here
• 4 x M3x4mm screws
• 4 x M3x12mm screws
• 1 x M3x6mm screw to lock the zoom for the PIR sensor
• prototyping PCB board
• hot glue gun
• some wires
• soldering iron with soldering supplies
• 3D printer or access to it
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Models to Print
In order to save some plastic, all parts were designed to be printed with no supports.
Layer height: 0.2 mm
Infill: 15%-20% is enough
Number of shells: ≥2
As this device has no high voltage, it could be printed with any favourite material, e.g. PLA
Step 2: Schematics
Take a piece of the prototyping board 25x35mm and solder the Wemos board on it, that will help to better organise wiring to the sensors, power source and external trigger (relay, in this case). Humidity/temperature and light intensity sensors are connected via I2C bus. My prototype example has lot of wires, but you can connect the modules in parallel with much shorten wires, wiring diagram shows all details.
Step 3: The Code…
With the previous devices I've been using SPIFFS to store the files for the web interface, in this one I've decided to replace the complexity with uploading files to the file system and embossed the whole html code into the sketch.Software part is simple, it reads the data from the sensors and shows it on the web interface. All that you need is to insert your SSID and password in the lines 31 and 32 and upload the sketch to the Wemos board. After uploading the sketch you can access the we interface by typing the http://sensorbox in the address line of your web browser. Web page will be refreshed automatically each 10 seconds, this parameter defined in the line38 "const long interval = 10000;". Lines 51-131 has HTML code for the web interface, so you can customise/change by your own.
Note: In lines 226-236 you can define the conditions what device have to do once motion will be detected. e.g. add condition to trigger the relay, only when lowlights.
Step 4: Assembling…
This step doesn't require much time and simple one.
Take the SensorBall, insert into the BallMount and fix it with BallFrame, by using four M3x12 screws. Do not screw them tightly, let the ball moving inside the frame with some resistance. Put the light intensity and temperature sensors on their places and lock them with the hot glue. Take the 2 parts of the sensor tube and insert the sensor inside of it. Make sure that sensor's head is properly "sitting" in the groves. Insert the sensor inside and slide the tube inside of the ball mount. Connect the wires to the temp and light intensity sensors (if you haven't soldered them before). Connect the power source and make sure that all working fine, adjust the "focus" for the the PIR sensor. Once this done, lock the PIR sensor with M3 screw.
Note: By moving the PIR sensor inside of the ball you'll be reducing the area which sensor will be monitoring, and if you move it outside of the ball, sensor will be able to capture motion in more wide area.
Once all of this done - slide the wemos board into the groves inside of the housing cover. Put the cover on the sensor box base and fix it by using M3x4mm screws. Put the sensor box on previously prepared place and it's done. Now you can point the PIR sensor to the area that have to be monitored, by adjusting the ball position, e.g. to your working table.
Thank you for reading.
Participated in the