This project was designed for parents and pet owner who have infants, young children or pets that they may need to leave unattended inside a vehicle for a period of time. When places inside a vehicle, the device monitors heat levels and movement to ensure safety from overheating. The device will send text notifications with increasing levels of urgency when heat levels inside a car rise above safe temperatures.
While this does not provide a solution to cool down a child or pet to save them from overheating this does help notify the parents before fatality strikes.
MotivationSince 1998, children especially under the age of 2, have been incredibly vulnerable to the dangers of heatstroke. In the year 2018, 52 children were reported dead after being trapped inside an overheated vehicle. Even with windows left slightly open, the temperature inside a car can increase by 20 degrees in 10 minutes, and 50 degrees in 30 minutes. For a child's body, which heats up to three to five times quicker, this is a serious problem. After reading an article articulating this exact problem, I was at first shocked and horrified. Shocked at how many fatalities there were, and horrified that there wasn’t a solution yet. Hopefully with this project, it will be the stepping stones to creating new safe and reliable devices to help ensure the safety of others and help future children from becoming trapped inside overheated vehicles.
MaterialsSomething
Using the QuickStart guide for the Boron to register the board into the Particle Cloud environment. It took about half a day to get the SIM card register with the local cell network and be able to access it from the Particle console.
The Particle console looks like the image below, listing the Boron device and with the needed information to call thru the API.
In order to use the Particle IDE, WEB or IDE via Visual Studio Code, you need the Personal Access Token string, you can find it by selecting the WEB IDE on the console and the select the Settings gear at the bottom of the IDE, you will see the Personal Access Token on the top. In the below image it has being edited out since it is a personal token.
Once you get your PAT, using the Visual Studio Code environment is as easy as just login into your Particle account.
In order to install and configure your Desktop IDE follow the easy guide here.
Finally, include the following libraries into your project: Adafruit_ILI9341, Adafruit_DHT, and Adafruit_mfGFX. Make sure you use those names since the search is very picky. The program shows Twilio, but it was actually not used so disregard adding that library.
Coding RealityThe coding needs to match the actual events on reality. In this case the internal temperature of a car sitting on a sunny day during summer with temperatures up to 110 degrees Fahrenheit.
The following references were used to find the best temperature ranges, from NBC News: "Death in Hot Cars: Facts, Figures and Prevention", WhatToExpect: "Protecting your Children from Extreme Heat" and "Why Leaving Your Child in the Car is So Dangerous".
First, a set of constants that define the temperature thresholds, the number of messages to send and the time interval between messages.
//Define constants for device status
#define STATUS_UNKNOWN 0
#define STATUS_OK 1
#define STATUS_WARNING 2
#define STATUS_DANGER 3
#define STATUS_PANIC 4
//Define constants for temperature strenght
#define RANGE_OK 81
#define RANGE_WARNING 89
#define RANGE_DANGER 99
#define WARNING_TIME 5 //mins
#define MSG_WARNING_MAX 4 //every 5 mins
#define WARNING_MAX_TIME 15
#define DANGER_TIME 3 //every 3 mins.
#define DANGER_MAX_TIME 15 //after that it becomes panic.
#define MSG_DANGER_MAX 5
#define PANIC_TIME 1 //every minute
unsigned long thresholdTime=5000;
unsigned long warningThreshold = 1000*60*WARNING_MAX_TIME;
unsigned long dangerThreshold = 1000*60*DANGER_MAX_TIME;
unsigned long warningTriggerThrs = 1000*60*WARNING_TIME;
unsigned long dangerTriggerThrs = 1000*60*DANGER_TIME;
unsigned long panicTriggerThrs = 1000*60*PANIC_TIME;
The
first check makes sure that the temperature is below the OK range (82 degrees F); if the temperature is below then reset the environment variables to the normal status.
if (f < RANGE_OK)
{
if (eventStatus != STATUS_OK)
{
eventStatus = STATUS_OK;
msgCounterWarning = 0;
msgCounterDanger = 0;
eventStartTimer = 0;
eventTimer = 0;
}
}
If the temperature reaches the Warning range (82 - 89 degrees F), a warning message is sent to the direct contact, and a timer for 5 mins is started. The system will send a message every 5 mins.
else if (f > RANGE_OK && f <= RANGE_WARNING)
{
if (eventStatus != STATUS_WARNING)
{
eventStatus = STATUS_WARNING;
msgCounterWarning = 0;
msgCounterDanger = 0;
eventStartTimer = millis();
eventTimer = 0;
sendWarning(f);
}
else
{
eventTimer = millis();
if ((eventTimer - eventStartTimer) < warningThreshold)
{
if ((eventTimer - eventLastTimer) > warningTriggerThrs)
{
sendWarning(f);
msgCounterWarning++;
eventLastTimer = eventTimer;
}
}
}
}
If the temperature reaches Danger range (90 to 99 degrees F), a danger message is sent every 3 mins to the direct contact and the first emergency number register in Twilio. The emergency number will receive the location of the device (as long as the GPS has lock on satellite), The emergency number then can contact the direct contact or drive to where the device is located, or contact the emergency authorities. The system will try up-to 15 minutes in total with the Danger status and then it will escalate to Panic status where a third person and second emergency contact will receive a text message, also with the device location.
else if (f > RANGE_WARNING && f < RANGE_DANGER)
{
if (eventStatus == STATUS_PANIC)
{
eventTimer = millis();
if ((eventTimer - eventLastTimer) > panicTriggerThrs)
{
sendPanic(f);
msgCounterDanger++;
eventLastTimer = eventTimer;
}
}
else
{
if (eventStatus != STATUS_DANGER)
{
eventStatus = STATUS_DANGER;
msgCounterWarning = 0;
msgCounterDanger = 0;
eventStartTimer = millis();
eventTimer = 0;
sendDanger(f);
}
else
{
eventTimer = millis();
if ((eventTimer - eventStartTimer) < dangerThreshold)
{
if ((eventTimer - eventLastTimer) > dangerTriggerThrs)
{
sendDanger(f);
msgCounterDanger++;
eventLastTimer = eventTimer;
}
}
else
{
eventStatus = STATUS_PANIC;
sendPanic(f);
}
if (msgCounterDanger > MSG_DANGER_MAX)
{
eventStatus = STATUS_PANIC;
sendPanic(f);
}
}
}
}
If the temperature raises to Panic range (99 degrees F and above), a Panic message is sent to a third person and second emergency contact with the device location. This message will be sent three messages every minute until the temperature lows down to safe ranges.
else if (f > RANGE_DANGER)
{
if (eventStatus != STATUS_PANIC)
{
eventStatus = STATUS_PANIC;
msgCounterWarning = 0;
msgCounterDanger = 0;
eventStartTimer = millis();
eventTimer = 0;
}
else
{
eventTimer = millis();
if ((eventTimer - eventLastTimer) > panicTriggerThrs)
{
sendPanic(f);
msgCounterDanger++;
eventLastTimer = eventTimer;
}
}
}
The creation of the location link use %20 character code which is equal to the space ASCII, in order to properly format the string.
Here is a snapshot of the Visual Studio Code settings.
Webhook is an API that allows you to send data whenever it is available without needing you to send a request for the data. This feature suits our need to send an SMS through Twilio once the temperature sensor has reached a certain value.
Twilio’s Webhook allows us to send text messages to specific contacts.
Particle Dashboard allows to create a Webhook by selecting Integration from the menu. The image below shows the user interface.
Select Webhook and the select New Integration. Below, you can see the three Webhooks created for each contact when the temperature event is triggered.
Selecting New Integration shows the Webhook template, from here you can follow the instructions on "Send SMS and MMS Messages with a Particle Electron" to add the proper parameters to the Webhook.
Using Twilio, an API developer platform for communications accessible via the Cloud, we purchased an SMS enabled number. This number sent the warning messages to the predetermined contacts when the temperature sensor returned certain values in a specified range.
Below is the Twilio Dashboard after registering and purchasing a phone number. Notice on the top right corner you can see a link named "verified numbers", you have to add the numbers Twilio can communicate to in order to send the text messages. Using a number that has not being verified (register) will result on an invalid Webhook execution.
The verified numbers have being removed due to privacy, but after you verify the numbers by entering a verification code sent by SMS message, you will see the below list showing these numbers.
Now let's put it all together.
Putting all togetherSomething
The following snapshots shows the installation of the sensors on an old baby seat for testing purposes.
The pressure sensors are attached to the bottom of the seat and the back, the calibration of these sensors is necessary, although not possible since we only have our furry testing subject.
The following video shows a testing of the system by using a hair dryer to increase the temperature.
You can notice the registered numbers get the SMS text messages in a timely matter as the status change from Warning-->Danger-->Panic-->OK status.
Here is a SMS message on a Panic status with the location of the device linked to google maps, by means of the link.
Besides being used as a system to ensure the safety of babies, toddlers and pets in cars, it is also possible to use this device for elders or pets left alone at home for long periods of time. The device could monitor temperatures inside homes and ensure that heat levels don’t reach dangerous levels. While heat strokes within homes are not as deadly compared to infants trapped in an overheating car, it is still important to be cautious and knowledgeable.
Comments