Air Pressure IoT Air Pressure IoT

Instructables Instructables

    Check some projects published on Instructables website

Basic Security with ESP8266

Temperature Monitor with ESP8266

Illuminance Monitor with ESP8266

 

More details here...

   Air Pressure IoT

 

        This project allows you to check the atmospheric pressure from a BMP183 pressure sensor on a mobile App.

 

    Complexity

Project  Air Pressure Monitor
Time to build  1 hour
Cost $35
Arduino Code download
Cloud Device Code N/A
Mobile App Code download

 

    Hardware

        Here you have the list of the components required to build the hardware. We assume you have a computer, a router and a network cable. If you purchase the Arduino board from the specified source it comes with the USB cable. Otherwise you might need to provide a USB cable too. You can find better options for hardware. Be careful what components you buy. For Ethernet boards there are many versions with different chip sets but only the standard Arduino Shield or equivalent works with the software provided here. The prices are just a guide. These are the values we found when we created this project.

        Please be aware that you have to solder the pins on the BMP183 air pressure sensor.

  
Picture Name Price Source

Arduino Uno

 $13 Link
Arduino Ethernet Shield $10 Link
Pressure Sensor (BMP183) $10 Link
Single Port Female to Female Jumper Wires $3 Link
Single Port Male to Male Jumper Wires $2 Link

 

        We recommend to buy an Arduino board with a smaller USB connector (mini or micro USB) because the Ethernet Shield will not insert properly most of the time if you do not use original Arduino boards.

        Here you have a picture with the components we used:

 

 

     Specifications

       This section shows the pinout of the components or provide a link to the specifications of the component.

 

Component Name Pins
Arduino Uno See: http://arduino.cc/en/Main/arduinoBoardUno
Arduino Ethernet See: http://arduino.cc/en/Main/ArduinoEthernetShield
Pressure Sensor
Pin Description
1 Vcc
2 3.3V
3 GND
4 SCLK
5 MISO
6 MOSI
7 CS

 

     Wiring

        This section shows you how to connect the components together. First you have a pin-out connection and below there are pictures showing how it's done on the real boards.

 

Pressure Sensor Pin ArduinoUno
GND GND
Vcc +5V
SCLK D7
MISO D6
MOSI D5
CS D4

 

Arduino Ethernet ArduinoUno
Just insert the Ethernet Shield into Arduino Uno
 

       Here you have pictures with the wiring

 

 

 

 

        The schematic is

 

 

    Software

        To run the system you need two software components. One is the software to run the hardware (Arduino Software) and the other one is the mobile App (Mobile App).

 

     Arduino Software

        To run the software you need the Arduino development environment. You need an external Library that is not included by default with Arduino IDE.

Library Location Author Comments
Adafruit BMP183 Link Adafruit They provide a basic tutorial how to use the sensor

 

        You have to load the software provided here and configure it. There is only one value you need to change in the code.

 

Field Description
device_id

This is a unique id you have to create for your hardware device to identify it from others in the cloud. Use this www.guidgenerator.com to generate GUID (Global Unique ID)

String devId      = "b5ebf7a7-e63a-4660-8f83-cf1e5d39cf5b";
auth

This is the authentication string required for basic authentication of the http requests. Create a string from <email_address>:<API_Password> and encode it base64. The sample here "dXNlcjpwYXNzd29yZA==" is the encoding for "user:password"

String auth    = "dXNlcjpwYXNzd29yZA==";

 

       And here you have the sketch (download)

 

#include <SPI.h>
#include <Ethernet.h>
#include <Adafruit_BMP183.h>

byte mac[] = { 0xDE, 0xED, 0xBE, 0xEF, 0xFE, 0xD1 };        // mac address for ethernet board
EthernetClient eth;                                         // the Ethernet client

char server[]  = "www.ic2pro.com";                          // Wiring Cloud host name
int port       = 80;
String devId   = "111-222-333";                             // Device ID. CREATE YOUR OWN GUID; Use this http://www.guidgenerator.com/
String auth    = "dXNlcjpwYXNzd29yZA==";                    // Authentication credentials Create a string from <email_address>:<API_Password> and encode it base64
                                                            // The sample here "dXNlcjpwYXNzd29yZA==" is the encoding for "user:password"


// Use software SPI for pressure sensore because the ethernet shield uses standard SPI 
#define BMP183_CLK  7  // CLK
#define BMP183_SDO  6  // MISO
#define BMP183_SDI  5  // MOSI
#define BMP183_CS   4  // CS

Adafruit_BMP183 bmp = Adafruit_BMP183(BMP183_CLK, BMP183_SDO, BMP183_SDI, BMP183_CS);

// Update Pressure signal on the Wiring Cloud
void sendPressure(String pressure)
{
  Serial.println("Pressure = " + pressure);
  if (eth.connect(server, port)) {                                                          // initialize HTTP connection on port 80
    eth.println("GET http://" + String(server) + ":" + String(port) + "/Wire/connector/set?id=" + devId + "&AIRPRESSURE=" + pressure + " HTTP/1.1");   // submit HTTP request
    eth.println("Authorization: Basic " + auth);
    eth.println("Connection: close");
    eth.println();
    Serial.println("Pressure sent to server.");
  }
  else {
    Serial.println("Connection Error");
  }
  eth.stop();
}


void setup() {
  Serial.begin(115200);
  Serial.println("Start...");
  Ethernet.begin(mac);                                           // start the Ethernet connection:
  delay(1000);                                                   // give the Ethernet shield a second to initialize:
  bmp.begin();                                                   // Start sensor
}

void loop() {
    sendPressure(String(bmp.getPressure() / 100));
    delay(2000);                                                  // send pressure only every 2 seconds
}

    

Mobile App

 

        The mobile application to control the security system is built with "App Inventor" (ai2.appinventor.mit.edu). If you just want to import the .aia file you can download it here. Otherwise you have to create next components.

 

Component Name Description
Label PressureMsg A text that shows the pressure.
Clock Timer A timer that will send regular requests to get the pressure from the Wiring Cloud.
Web APIGetPressure

The HTTP request that will be sent to retrieve the pressure value. Set Url to:

http://www.ic2pro.com/Wire/connector/get?id=<device_id>&AIRPRESSURE

don't forget to put the device_id you set in the Arduino Code

 

        In the code you have to set a proper authentication string. Replace the string "Basic dXNlcjpwYXNzd29yZA==" with your authentication string. Create a string from <email_address>:<API_Password> and encode it base64. The sample here "dXNlcjpwYXNzd29yZA==" is the encoding for "user:password". Make sure you append "Basic " at the beginning of it.

        And this is the logic you have to create in App Inventor. Once that is done you just build the APK and install it on your Android phone.

 

    Final Product

       Here you have a picture of the "final" product, hardware and screenshots from App.