Elderly Environmental monitoring and automation solution
Automation , Monitoring and Control have been increasingly used in making our lives easier and safer. This project will demonstrate the uses of available technologies and designs to make a low cost and effective monitoring and automation system to help the mobile challenged and elderly navigate their homes and businesses easier.
I will make use of the simple PIR (Motion Sensor) to monitor motion as a signal to operate lighting and important equipment such as door opening activation and Garage doors. I have designed and implemented a simple programmable Relay switch that can be installed in any standard switch box and is powered by regular 120 Volt AC Power. This version does not contain any sensors but is complimentary to a separate Sensor box which is deploy able anywhere that is needed. The Relay shield is designed for use in a standard US/Canada device box which makes the relay shield install able just about anywhere there is a standard light switch or motor control. It can also turn off your security system open gates etc..See Below..
Bringing together environmental sensors and control modules to enable to non mobile to control and monitor their environment effectively.
They can also be combined with my Sensor shield which is powered off of 120/240 VAC converted to DC by a standard 120 to 24 volt Power supply which enables solutions for building monitoring ..VOC ,Temperature ,Humidity , Fire , CO levels and can activate a variety of control situations.
The Above diagram is a House layout with the Particle Mesh sensors in Place and the Particle Switch Board installed in the existing Power Switch Boxes. The Beauty of this setup is that there doesn't need to be an extensive rework of the Existing wiring. Just Install and put a blank cover plate in place of the switches. Note a neutral is required in the Outlet Box. Also the maximum Amperage is (5 AMPS)
The sensor Box has a motion sensor installed so the light will come on when the office is occupied and turn off when it is Vacant. The temperature sensor and Humidity sensor will take care of the Heating and Cooling in the office to the desired set points and will enable the central heating and cooling better control of environmental set points turning off the AC or Heating to the unoccupied room and machine learning can adjust for future applications. Motion sensors can act as Backup to the Security system and send Twilio SMS Alerts to the Owner of late night or un-authorized access to certain office or Rooms. The built in Smoke detector will provide a Secondary Alert system for each office identifying Where a fire has started and send the Proper alerts. A CO detector in the Unit can alert the owner of dangerously high CO levels and VOC in the Air As well.
I am utilizing the Switch to turn on and off various devices ..Like garage door openers/AC units/Lights/Pumps etc. The Device is fused at a pretty low current so you need to add a Secondary set of High current relays in order to switch higher ampacity Loads. The Device is designed to fit into a standard single gang box or switch box ..
Particle Mesh Powered Sensor System
This system makes use of Spark Fun Sensors ( http://www.sparkfun.com) and Particle( http://www.particle.io ) as it is easier to plug in a sensor than it is to solder using re-flow techniques. We are going to sense Air Temperature,Motion ,Humidity ,VOC and CO2 levels as well as Smoke Particulates and Temperature Rise.
.The reading from a normal smokeless room is between 300 and 400 using the IR Reading. if I blow smoke onto the sensor it changes dramatically ...with blowing light smoke across it the IR reading jumps to above 500.. If I cup my hand around the sensor to trap the smoke the reading jumps to over 1000 so I will use that as a basic base line for My alarm set point for smoke.
As for heat ..Fire alarms use 2 different technologies ..Smoke sensing and heat sensing ..With the presence of fire there is sometimes no smoke but intense heat or the temperature in the room rises quickly which means a fire.. Old style heat sensors use a low melting point type solder or heat activated spring to change the switch state from Closed to open indicating a fire. Newer systems actually use temperature sensors and measure the rate of rise .. (Temperature rise over a period of time) usually a couple of seconds to a minute..That will give us a baseline to work from.
The environmental sensors Humidity and Temperature can be used to control heat pumps, Exhaust fans , Furnaces etc quite easily by integrating the relay board into the system.
The Sensors
I get most of my sensors from sparkfun as they have excellent Schematics and programming tips and help ..They continue with the Open source concept which is exactly what Hackster is all about ..
MAX30105 Smoke detector ..This sensor can be used for much more but i am using it for its accuracy in detecting smoke
https://www.sparkfun.com/products/14045 Cost $13.95
Atmospheric Sensor Breakout is the easy way to measure barometric pressure, humidity, and temperature readings all without taking up too much space. Basically, anything you need to know about atmospheric conditions you can find out from this tiny breakout. The BME280 Breakout has been design to be used in indoor/outdoor navigation, weather forecasting, home automation, and even personal health and wellness monitoring.
https://www.sparkfun.com/products/13676 Cost $19.95
https://www.sparkfun.com/products/13763 $7.95
The Si7021 also comes equipped with a hydrophobic PTFE filter covering the inlet on the sensor. This filter blocks contaminants but allows water vapor to pass through, keeping your sensor safe from water damage while still proving accurate sensor readings.
https://www.sparkfun.com/products/9868 $10.95
The amplifier on the breakout has a gain of 67 and more than meets the bandwidth requirements of the mic. The amplifier's AUD output will float at one half VCC when no sound is being picked up. The amplifier produces a peak-to-peak output of about 200 mV when the microphone is held at arms length and is being talked into at normal conversational volume levels. So the AUD output can easily be connected to the ADC of a micro.
PROGRAMMING #1
For Board #1 -- I used a Particle Argon , Sparkfun MAX30105 and a Sparkfun BME280 for sensing Smoke / Temperature , Humidity, Pressure
For Board #2 --I used a Particle Xenon and a Si7021 Temperature Humidity Sensor
There are libraries for the BME280 but the MAX30105 requires a bit of attention see "Library Setup for the MAX30105"
Library Setup for the MAX30105
you have to add the MAX30105.h and MAX30105.cpp files physically by clicking on the (+) sign in the upper top right corner and pasting in the Following Code derived from the Arduino MAX30105 code example.
(Attached) ..
Next is the Test code to make sure that the readings are coming out correct
// This #include statement was automatically added by the Particle IDE.
#include "MAX30105.h"
/***************************************************************************
Written by Limor Fried & Kevin Townsend for Adafruit Industries.
BSD license, all text above must be included in any redistribution
See the LICENSE file for details.
***************************************************************************/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include "MAX30105.h"
#define BME_SCK D4
#define BME_MISO D3
#define BME_MOSI D2
#define BME_CS D5
#include <Wire.h>
MAX30105 particleSensor;
#define debug Serial //Uncomment this line if you're using an Uno or ESP
#define SEALEVELPRESSURE_HPA (1013.25)
Adafruit_BME280 bme; // I2C
//Adafruit_BME280 bme(BME_CS); // hardware SPI
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
//========================
//=======================
unsigned long delayTime;
void setup()
{
Serial.begin(9600);
while (!Serial)
; // time to get serial running
Serial.println(F("BME280 test"));
unsigned status;
// default settings
// (you can also pass in a Wire library object like &Wire2)
status = bme.begin();
if (!status)
{
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
Serial.print("SensorID was: 0x");
Serial.println(bme.sensorID(), 16);
Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
Serial.print(" ID of 0x60 represents a BME 280.\n");
Serial.print(" ID of 0x61 represents a BME 680.\n");
while (1)
;
}
Serial.println("-- Default Test --");
delayTime = 1000;
Serial.println();
//============================
debug.begin(9600);
debug.println("MAX30105 Basic Readings Example");
// Initialize sensor
if (particleSensor.begin() == false)
{
debug.println("MAX30105 was not found. Please check wiring/power. ");
while (1);
}
particleSensor.setup(); //Configure sensor. Use 6.4mA for LED drive
}
void loop() {
char message[128];
char message2[128];
printValues();
delay(delayTime);
sprintf(message,"Temp %.2f, Pressure %.2f, Alt %.2f, Humidity %.2f",(bme.readTemperature()),(bme.readPressure() / 100.0F),(bme.readAltitude(SEALEVELPRESSURE_HPA)),(bme.readHumidity())) ;
sprintf(message2,"Temp %.2f, Pressure %.2f, Alt %.2f, Humidity %.2f",(bme.readTemperature()),(bme.readPressure() / 100.0F),(bme.readAltitude(SEALEVELPRESSURE_HPA)),(bme.readHumidity())) ;
Particle.publish("Sensor_Array1",message,PRIVATE);
//==============================
debug.print(" R[");
debug.print(particleSensor.getRed());
debug.print("] IR[");
debug.print(particleSensor.getIR());
debug.print("] G[");
debug.print(particleSensor.getGreen());
debug.print("]");
debug.println();
//=============================
}
void printValues()
{
Serial.print("Temperature = ");
Serial.print(bme.readTemperature());
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(bme.readPressure() / 100.0F);
Serial.println(" hPa");
Serial.print("Approx. Altitude = ");
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
Serial.println(" m");
Serial.print("Humidity = ");
Serial.print(bme.readHumidity());
Serial.println(" %");
Serial.println();
}
the Output will look something like this in Putty
It will also look like this in Particle Console
It is good practice to Compile your code as often as you can ..I you make a change compile ..It saves a lot of time later when you are trouble shooting your Code. See attached Code Snippet . Copy and Paste it into your Particle sketch.
So now that we have established a base line for our readings we can Add alarm points/Delays/ Message Publishing ..
.The reading from a normal smokeless room is between 300 and 400 using the IR Reading. if I blow smoke onto the sensor it changes dramatically ...with blowing light smoke across it the IR reading jumps to above 500.. If I cup my hand around the sensor to trap the smoke the reading jumps to over 1000 so I will use that as a basic base line for My alarm set point for smoke.
As for heat ..Fire alarms use 2 different technologies ..Smoke sensing and heat sensing ..With the presence of fire there is sometimes no smoke but intense heat or the temperature in the room rises quickly which means a fire.. Old style heat sensors use a low melting point type solder or heat activated spring to change the switch state from Closed to open indicating a fire. Newer systems actually use temperature sensors and measure the rate of rise .. (Temperature rise over a period of time) usually a couple of seconds to a minute..That will give us a baseline to work from.
Node Red Hosted on Amazon
The Node red set up is fairly straight forward ...The data comes in from Particle,publish ..The String is separated..Then redirected ..Then useless data is stripped out ..Then new data is added ..and sent to the thingsboard Site..
The Control is basically the same way ..The data comes in it is analyzed and if it meets the threshold then it either sends a command on or off in the form of a number back to Particle using Particle Function..The Code is Below.
I will explain the various Parts of the Node-Red Nodes to get a proper understanding of the process...
NODE RED
To install node red onto a Linux computer or Raspberry PI Go here https://nodered.org/docs/getting-started/ and follow the installation Instructions
so the First node is to connect to the Particle Cloud ..Install the node by searching for Particle in the manage pallet tab
Next pick the particle SSE Node and configure it to your Account
Account information can be found on the Particle Web IDE in Settings where you will find your token
The CLOUD URL is this https://api.particle.io
Next is your device ID which is found here
The event is the Particle Publish event ..Going to the Cloud
the output come out as a String..example {Temp 28.71, Pressure 1012.09, Alt 9.66, Humidity 63.27} this string is fine for general information but needs to be split apart, modified and sent on to thingsboard as well as using the information to Activate relays,alarms etc
The Next node is a function node which splits apart the message into separate messages for manipulation he function is here copy paste it into a function Node
var OutPutMsgs =[ ];
var words =msg.payload.split(",");
for (var w in words) {
OutPutMsgs.push({payload:words[w]});
}
return [OutPutMsgs];
Next is the Change Node which strips out the Identifier Text which is needed for redirection
The next thing is to configure your set points to activate a trigger to rend a data stream back to Particle to activate a switch or alarm
Using Cloud Function for Alarm
byte ADCvinMSB, ADCvinLSB, curSenseMSB, curSenseLSB, AinVMSB, AinVLSB;
unsigned int ADCvin, ADCcur, AinV;
float inputVoltage1, current10, current1, current0p1, current0p01;
void setup() {
Serial.begin(9600);
Particle.function("ON", SwitchOn);
pinMode(D4, OUTPUT);
pinMode(D3, OUTPUT);
pinMode(D2, OUTPUT);
// digitalWrite(D4,LOW);
// digitalWrite(D3,LOW);
pinMode(D5,OUTPUT);
pinMode(D6,OUTPUT);
pinMode(D7,OUTPUT);
}
void loop() {
char message[120];
char data1[256];
int sensorValue;
int status;
// int8_t result;
char message1[120];
int ADCvoltage;
int house_Current;
}
int SwitchOn(String command) {
if(command =="1") {
digitalWrite(D4 ,HIGH);
Particle.publish("Switch_On", "1",PRIVATE);
return 1;
delay(10000000);
}
else if(command =="2") {
digitalWrite(D4,LOW);
Particle.publish("Switch_Off", "0",PRIVATE);
}
return 1;
}
Particle Switch Code
Now ..Sending Data to your Things Board (ThingsBoard is an open-source IoT platform for data collection, processing, visualization, and device management)
https://github.com/thingsboard/thingsboard
Things_board Dashboard hosted on AMAZON
The Configuration is a little different for thingsboard in Node-Red because you need to add a few things in the Thingsboard format
"Function Node " and HTTP POST Node configurations
Function Node before the HTTP Node :Note this is where you put the topic of your publish... put back what you stripped out earlier.
out=context.data || {}
node.log("start"+ msg.payload);
node.log("start stored" + context.data);
topic=("Temperature");
node.log(topic);
if (msg.payload=="send")
{
msg.payload=context.data;
msg.out="send data to";
msg.topic="";
//context.data=null;
return [msg];
}
else
{
out[topic]=msg.payload;
context.data=out;
node.log("stored"+ msg.topic);
return null;
}
You will also need to add an Inject button "TEST" which allows you to regulate the Post speed ..
Things Board Configuration
My Boron LTE unit wouldn't work where I am as I Live in an area where there is no LTE I tried other Sims but to no avail..It was unusable for here but I included the GPS unit as an example for Fleet tracking Possibilities. Just install a Black Box in your truck or car and the GPS Unit can transmit your location on a map and alerts can be setup in Node Red where you can have your exterior lighting turn on heat or cooling turn up or down security system can turn off ..doors unlock and your ready for your day at work.
https://www.sparkfun.com/products/13740
The Sensor Box
This sensor Box features a few things ..one is the double battery capability powering the unit for a very long time. I haven't tested the Battery drain time but it doubles from the standard time utilizing 2 Lithium Ion Batteries as well as a 24 volt DC input enabling Power Supply plug in for 120 Volt /240 volt usage.
Motion Sensing
GPS Location Input
Temperature & Humidity
Smoke Detection/Rate of Rise Heat detection
Audio Detection
Activation relay for low voltage control
Closed up and operating
In Conclusion
This systems is easily built and implemented with as little code and materials necessary. The overall build cost is less than $60 per control unit which is lower than any devices on the market today. I can be built and implemented with little experience in wiring and programming experience.
Thank you
Comments