Lin OchoaPeter MaMica Wong
Published © LGPL

Air Quality License Plate Holder

Air Quality License Plate Holder uses air quality sensor attaching to the vehicle to monitor the air quality through out the city.

AdvancedFull instructions provided10 hours3,750
Air Quality License Plate Holder

Things used in this project

Hardware components

Arduino 101 & Genuino 101
Arduino 101 & Genuino 101
×1
Seeed Grove Wireless Sensor Node Kit
×1
Seeed Grove Air Quality Sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE
Google Android Studio

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)

Story

Read more

Custom parts and enclosures

3D model

this is the 3D model for the device

Schematics

Arduino 101 with Grove Sensor

Arduino 101 with Grove Sensor
Img 20170727 225700 c39hvf2sfv

Code

Arduino BLE Code

Arduino
Arduino BLE Code, this allows Android and other devices to connect to Air monitor via BLE
#include <CurieBLE.h>
const unsigned char ledPin = 13;              // On-board LED

BLEPeripheral blePeripheral;  
BLEService tempService("fef431b0-51e0-11e7-9598-0800200c9a67"); // Create custom BLE Service
BLEUnsignedIntCharacteristic  tempChar("fef431b0-51e0-11e7-9598-0800200c9a66", BLERead | BLENotify); // allows remote device to get notifications
int oldTemp = 0;          // last temperature reading from analog input
long previousMillis = 0;  // last time the temperature was checked, in ms

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);  // initialize the LED on pin 13 to indicate when a central is connected

  // initialize the BLE hardware
  BLE.begin();
  blePeripheral.setLocalName("Air Monitor");
  blePeripheral.setAdvertisedServiceUuid(tempService.uuid());    // add the service UUID
  blePeripheral.addAttribute(tempService);
  blePeripheral.addAttribute(tempChar);
  tempChar.setValue(oldTemp);               // initial value for this characteristic
//  BLE.advertise();

  Serial.println("BLE Central - LED control");

  blePeripheral.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
  BLEDevice central = BLE.central();

  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: "); Serial.println(central.address());  // print the central's MAC address
    digitalWrite(ledPin, HIGH);  // turn on the LED to indicate the connection

    // check the temperature every 5000ms as long as the central is still connected:
    while (central.connected()) {
      long currentMillis = millis();
      if (currentMillis - previousMillis >= 1000) {
        previousMillis = currentMillis;
          updateAirQual();
      }
    }
    digitalWrite(ledPin, LOW);   // when the central disconnects, turn off the LED.
    Serial.print("Disconnected from central: "); Serial.println(central.address());
  }

}

void updateAirQual() {
  //Set quality from 0 to 255, with one to 100 being normal
  int sensorValue = analogRead(A0);
  int quality = map(sensorValue, 0, 1023, 0, 255);
  Serial.println(quality);
  tempChar.setValue(quality);
}

Android and Arduino code

Smart City Air Monitor uses air quality sensor attaching to the vehicle to monitor the air quality through out the city. Edit Add topics

Credits

Lin Ochoa

Lin Ochoa

1 project • 4 followers
Queens College Computer Science Student
Contact
Peter Ma

Peter Ma

9 projects • 76 followers
Prototype Hacker, Intel Software Innovator, Hackathon Goer, World Traveler, Ecological balancer, integrationist, technologist, futurist.
Contact
Mica Wong

Mica Wong

2 projects • 7 followers
Self taught 3D modeling and printing skills. Work at a grooming salon part time and delve into projects and hackathons as hobby.
Contact

Comments