This IOT project was done for our Instrumentation class of Spring 2017 at UNC Charlotte. For this project, we are going to manage temperature and humidity readings inside a well house and operate a heat lamp to prevent water freezing within the pipes. The first photon will be collecting data through the temperature and humidity sensor and the second will monitor this data and trigger a relay to turn on a heat lamp if the temperature is too low. Particle publish and subscribe coding will be used to communicate the relevant temperature data each other. The first photon is also publishing temperature and humidity data to a ThingSpeak API to see the data change over time and see the effect of the heat lamp on the well temperature.
The circuit shown in the diagram below is for a DHT11 sensor. We used a DHT11 breakout board to simplify wiring. This photon is also responsible for publishing data to the cloud as well as ThingSpeak. The Photon is powered by a spare phone charger we had laying around.
The photon will be set on the floor near the pipes within the well house away from the heat lamp. This could be an issue because the IoT setup is right next to the overflow valve on the well. The chances of the overflow being needed are low but it is still something to think about. Too close to the heat lamp would cause incorrect readings and false powering down of the heat lamp. The photon was placed low on the ground because I didn't have anywhere else to put it in the well house. Due to low numbers of outlets, a power bar plugged into the wall outlet supplies power to all of the devices. Code for the first Photon is labeled as "Data Collection Photon" in the repository below.
The second photon is subscribed to the event data from the first photon. The temperature data is received as a string, and sent to the temperature handler function to translate the received string into an integer for comparison. Temperature data is in degrees Celsius. A relay will be operated by this second photon to turn on and off a heat lamp within the well house. If the temperature falls below 5 °C, the photon will activate the relay, turning on the heat lamp. Above 10 °C, the heat lamp is switched off. The gap is to allow the lamp to heat the room without turning off and on rapidly. These numbers may be changed in the code for different activation/deactivation settings. The relay is a normally closed relay and non-latching so that if the photon loses power or malfunctions the light will turn on. Code for the second Photon is labelled as "Switch Photon."
The two photons is secured onto a single bread board. As stated above from photon 1 description, the setup was placed low on the ground and near the pipes. This will help the sensor measure the most accurate temperature reading of the pipe surroundings. but as mentioned before puts the assembly at a damage risk.
Temperature and Humidity Monitors via ThingSpeak
The IoT device publishes data to the cloud every 30 minutes. Each graph on ThingSpeak is set to show 48 samples or a full days worth of temperature and humidity data at a time to show the data over the course of a full day