This project was born from my tendency to leave my compressor running overnight, wasting power and placing unnecessary wear and tear on the compressor itself. Therefore, I also added an automated shutdown feature to disable the compressor when the lights were turned off, as well as letting me remotely turn off power to the workshop. Linked here are the charts generated from the light monitoring and temperature monitoring.
Light monitoring can be used as a proxy for occupancy - if the light is low, then the room can be assumed to be unoccupied. If the light level is high, someone can be assumed to have been in the room.
The project can be re-purposed for remote control and/or monitoring of any device, should the end user desire.
HardwareRemote Control
First, I set up the remote monitoring and switching board, as it is by far the simpler of the two to build and program, only needing a button and trio of LEDs wired to it. This board uses the following components:
- 1x Particle Photon
- 1x 3mm green LED
- 1x 3mm yellow LED
- 1x Common Cathode RGB LED
- 1x Push Button
- 3x 330 Ohm resistor
- 1x 220 Ohm Resistor
- Jumper Wires
These components are assembled according to the diagram below.
The RGB LED's red and blue modes are utilized, and all three LEDs are protected by 330 Ohm resistors.
Workshop Controller
The Workshop controller uses the following components:
- 1x Particle Photon
- 1x Sparkfun Photoresistor
- 1x 10 kiloOhm Resistor
- 1x 330 Ohm resistor
- 1x 220 Ohm resistor
- 1x Push Button switch
- 1x IoT Switching Relay Power Strip (NOTE: Generic Solid State Relay used as stand-in on circuitry diagram. + pin on actual Relay Power Strip should be connected to D6, - pin on Relay Power Strip connects to Ground.)
- 1x DHT22 (NOTE: This can be replaced with any standalone temperature sensor, but sensors other than DHT11 and DHT21 will require addition of appropriate libraries or independent calibration and alterations to code to maintain functionality)
The Photon draws power from a USB adapter plugged into the "Always On" port of the IOT Power Strip.
SoftwareWorkshop Controller
The workshop controller is the brains of the operation, controlling the power state of the relay and publishing the current workshop temperature, measured from the DHT22. It also has a push button for local relay control.
NOTE: Should the sensor be changed to a DHT11 or DHT 21, all that need be changed is DHT_TYPE to the appropriate sensor type.
It publishes two variables to the cloud, which are monitored and graphed by Google Sheets
- Light Level (Photoresistor readout)
- Temperature (Celsius from DHT22)
It publishes two events:
Workshop Power
- On
- Off
If This Then That and the remote monitor Workshop Power, switching a LED on the remote and sending email and app notifications when the relay powers on and shuts down.
This software requires the Adafruit_DHT_Particle library.
Workshop Temperature
- Cold (Temperature too cold for comfortable work, even with space heater)
- Heat (Temperature low, space heater allows comfortable work conditions)
- Comfortable
- AC (Must run fan to bring felt temperature down to comfortable levels)
- Hot (Too hot for comfort)
Remote Control
The remote control displays the output from the workshop controller, and allows remote activation and deactivation of the workshop controller. This also shows the current state of the workshop relay, based on published events from the controller (Workshop Power and Workshop Temperature).
This software only requires the default libraries be installed.
Sheets Integration
Google Sheets tabulates the illumination and temperature data from the workshop controller at ten-minute intervals. Occupancy time can be inferred from light levels, while the temperature measures temperature trends.
To utilize this feature, set up a Google Sheet with appropriate headers, then copy-paste the code from the Scripts box into the Script Editor (Tools > Script Editor).
Replace DEVICE_ID and AUTH_TOKEN with your device ID and authorization token.
To view the data from this controller, the links are above, and given again here for convenience.
This project uses a "Polling" model, so Google Sheets attempt to collect the data regardless of whether the Photon is online or not to provide the data.
Sample images of chart output:
Note the blank zone in temperature - if the poll fails to collect a temperature reading, the chart will simply be blank at that point.
Video Explanation
Comments