Project in progress
Smart City Project

Smart City Project © GPL3+

Open source air quality sensor network platform.

  • 3,921 views
  • 1 comment
  • 3 respects

Components and supplies

Necessary tools and machines

09507 01
Soldering iron (generic)

Apps and online services

Snappy%20(1)
Ubuntu Snappy Ubuntu Core
Ide web
Arduino IDE
Digital Ocean
It's a hosting service that provides online space for website
Fritzing
Ide web
Arduino Web Editor

About this project

This project is dedicated to all of victims from Kaosiung gas explosions in Taiwan. When the explosions happen I was in the U.S. I read about the causes from the news. The cause of the explosions due to the leaking of Propene (C3H6). Soon I read of more thing about other causes of the explosions. I realized there is a way to prevent this tragedy if there is a network system to detect this problem at first place. Therefore I started looking for any resource that can help me building a system to archive this goal.

I wasn't able to find a development board with low price from Arduino, Therefore I start looking for other development board. Unfortunately Arduino MKR1000 didn't come out yet. Therefore, I use several different other modules and try to get the data to the Internet. Soon I realized that the connection to several module's will make this project to complicate to get other people involved.

About a year later, I got hired by a company to work on their IoT device prototype. They have Particle Photon as prototype dev board. I successfully help them to build a prototype, however I realized that to use Particle Photon is sent HTTP request to my server will take too much work to do. The work is beyond one man's work. I can't do it along. Therefore I have to temperately put this project always until I can find a simpler solutions to get it done.

When Arduino MKR1000 was published, I see it as a good option to make this project alive therefore I start working on this project from the front-end of the website and the back-end. This is how I get to this contest. This project will be added more functionalities and other sensors in the future. I would like to invite everyone who cares about air quality to join this project. With more people's dedication, this project can help more people's life and make the world a better place.

Code

Smart City Project CodeArduino
#include <ArduinoHttpClient.h>
#include <WiFi101.h>
#include <PMS5003.h>
// MKR1000 Pins setup
const int SLEEP_PIN = 6; // this pin is for setting the sensor to sleep while it is not taking the data.
const String uuid = ""; // This is the place where you should put your UUID 

// method setup
const String content_type = "application/x-www-form-urlencoded";// this is for POST method

// Your WiFi setup
String postData ="";
char serverAddress[] = "107.170.217.4";// This is the website of Smart City Project
int port = 8080;// port number of the website

// WiFi Login Data
String ssid = "Name of Your Wifi";
String password ="Password of Your Wifi";

// initialize your variable value
PMS5003 pms5003;
String PM1 = "N/A";
String PM2_5 = "N/A";
String PM10 = "N/A";
String temperature = "N/A";
String humadity = "N/A";

// HTTP Connection
WiFiClient wifi;
HttpClient client = HttpClient(wifi, serverAddress, port);
int status = WL_IDLE_STATUS;
String response;
int statusCode = 0;

void setup() 
{
  Serial.begin(9600); // Serial for serial monitor. If the sensor is successfully sending data to website, this can be comment out
  Serial1.begin(9600);// Serial1 port for PMS5006
  pinMode(SLEEP_PIN,OUTPUT); // Setup Pin 6 as output pin
  digitalWrite(SLEEP_PIN,HIGH); // Let the sensor start working as default
  while(status != WL_CONNECTED) { // start connection
    Serial.print("Attempting to connect to your wifi: " + ssid + "\n");
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, password);
  }
  // print the SSID of the your WiFi
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());
  
  // print your WiFi Module's IP address:
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");Serial.println(ip);
}

void loop() {
  Serial.println("PMS5003 Data on Process");
  
  //digitalWrite(SLEEP_PIN,HIGH);
  //delay(20000);
  for(;;){
    pms5003.processDataOn(Serial1);
    PM1 = String(pms5003.getPM1(),DEC);
    PM2_5 = String(pms5003.getPM25(),DEC);
    PM10 = String(pms5003.getPM10(),DEC);
    if (PM1 !="-1" && PM2_5 !="-1" && PM10 != "-1"){
      break;
    }
  }
  
  
  postData ="uuid=" + uuid + "&PM1=" + PM1 + "&PM2_5=" + PM2_5 + "&PM10=" + PM10 + "&Temperature=" + temperature + "&Humadity=" + humadity;
  
  Serial.println("making POST request");
  client.post("/",content_type,postData);// the conntent in content_type is for doing POST method.

  statusCode = client.responseStatusCode(); // response code from server
  response = client.responseBody(); // messages that is responed by server

  // Serial Monitor output.(can be comment out when the data is sending to server correctly)
  Serial.print("Status Code: ");Serial.println(statusCode);
  Serial.print("Response: ");Serial.println(response);
  
  Serial.print("PM1:\t");Serial.println(PM1);
  Serial.print("PM2.5:\t");Serial.println(PM2_5);
  Serial.print("PM10:\t");Serial.println(PM10);
}
Smart City Project
This is the files of PMS5003 library and Sketch of Arduino MKR1000
Smart City Project Code on Arduino Web Editor

Schematics

Arduino MKR1000 Air Quality Sensor
This is connection from Arduino MKR1000 to PMS5003 sensor. It the connector that represents the PMS5003 sensor. Once you connect your Arduino MKR1000 board to the connector(the connector can be made by your-self) and then you just need to connect your PMS5003 sensor to the connector.
Arduino mkr1000 smart city project grkhrxrlt8
Arduino MKR1000 with PMS5003
This is prototyping of Smart City Project Set
Img 1034 o1gp6usg67
Arduino MKR1000 + PMS5003 + proto board PCB
When you want to do DIY your device to join Smart City Project.
Img 1033 qqmwlatfed

Comments

Team BYU Smart City Project

Kcml
kcml
  • 1 project
  • 1 follower
10325480
tslator
  • 1 project
  • 0 followers

Additional contributors

  • Providing url of arduinohttpclient library and suggestion of the use of libraries by Sandeep Mistry
  • Being mentor since this project started before the competition by Derek Hansen

Published on

February 1, 2017

Members who respect this project

Default3348134Photo
See similar projects
you might like

Similar projects you might like

Smart IOT Propane Monitoring Pedestal

Project in progress by Team A Bit Gassy

  • 1,282 views
  • 1 comment
  • 12 respects

Smart Thermostat

Project tutorial by Arduino_Genuino

  • 69,289 views
  • 10 comments
  • 83 respects

A DIY Smart Insole to Check Your Pressure Distribution

Project tutorial by Juliette van der Pas

  • 8,944 views
  • 10 comments
  • 31 respects

Smart Plastic Container

Project in progress by Team NoSleep

  • 7,596 views
  • 0 comments
  • 7 respects

Smart Home - Smart Rules using ARTIK Cloud & Photon

Project tutorial by Raghavendra Ponuganti

  • 3,864 views
  • 2 comments
  • 12 respects

Smart Connected Open Source Pot (Scopot)

Project showcase by Hendra Kusumah

  • 3,212 views
  • 1 comment
  • 29 respects
Add projectSign up / Login