Tweet and Text Message an Arduino air quality reading
This little app tweets and texts notifications to your phone from a Node.js server when the Arduino air quality sensor detects high levels of natural gasses which we normally associate with bad smell.
I used the cheap MQ-2 natural gas sensor I bought from eBay. It’s sensitive to Methane, Butane, LPG, smoke and many other flammable or combustible gasses. It’s really easy to connect the sensor to the Arduino: first we need to power it up from the board so we connect it to the 5V and GND pins then its analog output pin to the analog input pin on the Arduino (A0).
The sensor reading is then sent to the serial port (USB) for the Node.js server once every second.
This message coming through the USB port from the Arduino is something we wouldn’t be able to read from a regular browser. Due to security reasons this is only available for the server which is why we use Node.js along with the serial library. I did something very similar with my Arduino RC Car so have a look for the serial communication logic there.
Once it’s initialised you can tweet with the
For text messages to your phone we use Twilio. Twilio also needs to be initialised with the tokens before using it:
After this you can easily send text messages to any mobile number with the
This project shows a lot of potential. You can see that as soon as the sensor reading arrives in Node.js the possibilities are infinite. You can start saving these values into a database or a google spreadsheet or simply send it to the browser through web sockets and the socketIO library. The air quality sensor could also be swapped out to any other analog sensor like temperature, light or sound without modifying the code.