In this tutorial we will make a gas leakage detecting system with MQ-2 gas sensor which is sensitive to LPG, i-butane, propane, methane, alcohol, Hydrogen and smoke.
What we need:
Wire module to arduino and upload the sketch.
You can define your own commands by changing the lines below...
After that we will use those values to detect for any king of leakage. We will make a new schedule that will run every 60 seconds and perform evaluation.
As usual please make sure you have properly configure arduino serial port and then enable it.
Let's get dirty
First we need to make a new launcher to retrieve smoke values for this particular example. Go to Instruction Sets menu and press Add New Launcher. Enter a name (handler) and type the following command...
Then our notification launcher using judo mail send API command.
Syntax:
And finally the Instruction Set that handle the evaluation function. Press Add New Instruction Set, type a name and the following command...
Note: Zero value can be changed with one of your choice you consider dangerous.
The above action will call the first launcher and get a value from the sensor, then will evaluate if it's greater than zero, if the statement is true the second launcher will be triggered and send us an email notification. Read more about evaluation function.
Now we are ready to create a 60 seconds schedule for task to be repeated. Click on scheduler and press Add New. In the popup window enter a name, period <Repeat>, interval in milliseconds <60000> and the 'smokeschedule' instruction set we had create in order to call the evaluation procedure.
This is it, once we save the schedule it will be activated. You can do the same way for gas (co) and perform a test with a lighter.
Another approach is to trigger an event from the sketch like this example.
You can accomplish that by change the lines below...
Alternatively use codebender
Open serial monitor and type 'smoke', 'co' or 'lpg'. Each of these commands will return concentrations of smoke, carbon monoxide and liquefied petroleum gas. You can read more details here.You can define your own commands by changing the lines below...
After that we will use those values to detect for any king of leakage. We will make a new schedule that will run every 60 seconds and perform evaluation.
As usual please make sure you have properly configure arduino serial port and then enable it.
Let's get dirty
First we need to make a new launcher to retrieve smoke values for this particular example. Go to Instruction Sets menu and press Add New Launcher. Enter a name (handler) and type the following command...
judo serial send smokeThen our notification launcher using judo mail send API command.
Syntax:
judo mail send <from> <to> `<subject>` `<message>` judo mail send xxx@gmail.com yyy@gmail.com `smoke alert` `Smoke detected *getsmoke ppm`And finally the Instruction Set that handle the evaluation function. Press Add New Instruction Set, type a name and the following command...
{ evalBool(*getsmoke > 0); sendmailonsmoke; ; } Note: Zero value can be changed with one of your choice you consider dangerous.
The above action will call the first launcher and get a value from the sensor, then will evaluate if it's greater than zero, if the statement is true the second launcher will be triggered and send us an email notification. Read more about evaluation function.
Now we are ready to create a 60 seconds schedule for task to be repeated. Click on scheduler and press Add New. In the popup window enter a name, period <Repeat>, interval in milliseconds <60000> and the 'smokeschedule' instruction set we had create in order to call the evaluation procedure.
This is it, once we save the schedule it will be activated. You can do the same way for gas (co) and perform a test with a lighter.
Another approach is to trigger an event from the sketch like this example.
You can accomplish that by change the lines below...
void loop(void) {
if (MQGetGasPercentage(MQRead(MQ_PIN)/Ro,GAS_SMOKE) > 500)
Serial.println("HazardousSmokeDetection");
When the measurement exceeds the value we have set, the 'HazardousSmokeDetection' will be printed to serial port and cause Jubito to execute the corresponding event.








