Hey there. Finding a parking spot near your office is a big hassle, isn't it ? Well let me tell you a more annoying problem. Parking your car in the sun for long hours. We all know what it's like to park your car in the sun, but when you have no other option, this is what you are forced to do.
Now, you have parked your car in the scorching heat and went about your business for a couple of hours. When you get back to your car and open the doors to get in, a hot blast hits you. We all are annoyed by that heat and that is probably the only reason why we refrain from parking our cars in hot sun. But "my car turned into a hot oven" shouldn't be your only concern.
It is not just the heat that has gotten into your car. When your car is closed for a long time in the sun, it turns into a greenhouse. Don't know what a Greenhouse is? It's basically a container that traps gases like Carbon Dioxide, Carbon Monoxide, water vapor, etc.
Alright thanks for the science lesson, but why should I care ? This is what a lot of people think when they are in a hurry to reach someplace and just get into their cars and put their air conditioners on full throttle and roll up their window panes and drive off in a potential greenhouse.
Concerned?
Relax, we got this. Just follow through.
Step OneGet all the required components and assemble your circuit. Take a look at the provided schematic as a guide to assembling the circuit.
Here, the Arduino is connected to the Bolt Wifi Module via, UART (Universal Asynchronous Receiver Transmitter).
Take a look at this amazing documentation regarding the communication between Bolt and Arduino over UART, before you go any further.
Note: If you are using these sensors with a breakout board or sensor module, than Vcc goes to 5v and GND to Ground, and you can connect the OUT pin to any of the desired Analog pins of your Arduino.Step Two
Now, it's time to make the Arduino talk to the sensors and the Bolt WiFi Module. Checkout this firmware which allows you to do so.
#include <BoltIoT-Arduino-Helper.h>
#include "MQ135.h"
#include "MQ2Lib.h"
#define RZERO 206.85
int mq135_pin = A0;
int mq2_pin = A1;
float co_value = 0;
float co2_value = 0;
MQ2 mq2(mq2_pin,true);
MQ135 mq135(mq135_pin);
String pushData(String *data){
co_value = mq2.readCO();
co2_value = mq135.getPPM();
return String(co2_value)+","+String(co_value);
}
void setup(){
mq2.begin();
boltiot.Begin(Serial);
boltiot.setCommandString("RD\r",pushData);
boltiot.setCommandString("GetData",pushData);
pinMode(mq135_pin,INPUT);
pinMode(mq2_pin,INPUT);
}
void loop(){
boltiot.handleCommand();
}
There are three libraries used in this sketch. Here are the links to them.
1. Library for MQ-2 sensor to monitor Carbon Monoxide
2. Library for MQ-135 sensor to monitor Carbon Dioxide
3. Bolt Arduino Helper Library
Note: Hobby sensors such as the MQ sensors are difficult to calibrate hence the mentioned libraries do that for you.Step Three
It's time to harness the power of the cloud and get a step closer to completing your application. So far you have assembled your hardware and uploaded the firmware to your Arduino, now it's time for things to get real. See this awesome tutorial on how to connect your Bolt WiFi Module to the Bolt Cloud and access various Bolt APIs.
Now we have all the parts ready for assembly, so let's move towards the final step of the application.
Step FourFor this final step, we will be writing a simple python script to notify us whenever the condition in our parked car worsens and what steps we should take. First of all let's install the Bolt Python API to help us easily communicate with the Bolt Cloud and our Bolt WiFi Module. To do so, open up your terminal and type in the following commands:
pip install boltiot
After doing this, the Bolt Python API is installed onto your system.
Now simply paste the following code into any blank python file (blank file with.py extension).
from boltiot import Bolt,Sms
from time import time
# Setup communication to Bolt by supplying your API key and Bolt ID
bolt = Bolt('your-api-key','your-bolt-id')
# Setup communication to your Twilio account and APIs
ssid = 'You can find SSID in your Twilio Dashboard'
auth_token = 'You can find your auth token on your Twilio Dashboard'
from_number = 'This is the no. generated by Twilio. You can find this on your Twilio Dashboard'
to_number = 'number to send the sms to'
sms = Sms(ssid, auth_token, to_number, from_number)
while(1):
bolt.serialWrite('RD\r')
received_data = bolt.serialRead(10).split(',')
# Check if the values of Carbon Monoxide or Carbon Dioxide
# exceed the given threshold.
if(float(received_data[0]) > 5.0 or float(received_data[1] > 40.0)):
sms.send_sms("
Mayday! Mayday! Hey your cars turning into a Greenhouse. Here are a few suggestions to help you.
1. Park your car in a shade or,
2. Roll down your windows for a few minutes and turn your AC on full swing or,
3. If you can't do any of that right now, before getting into the car, open all the gates for a few minutes and drive with your windows rolled down to avoid any kind of troubles.
Commander Car-e-OK Over and Out !
")
# Let's loop this and monitor values every 5 minutes
time.sleep(300)
Now executing this script will bring things to life. To execute this script run the following command on the terminal:
python <the_name_of_the_file>.py
Now let the script run in the background while you go about your work.
Congratulations! If you have came this far, you receive an amazing Fist Bump. Now, you are safe from any sort of threats.
And, don't worry, if in future any such threats should arise, you could always summon me and we will fight it together. Cheers!
Comments