Sunday, 9 October 2016

*4 WEEK : SHINYEI Particle Sensor Coding

Now, it time for Particle Sensor. Same as DHT11, i had search the related coding for this sensor. i had found some of the coding. Such like;

/*
Grove - Dust Sensor Demo v1.0
 Interface to Shinyei Model PPD42NS Particle Sensor
 Program by Christopher Nafis
 Written April 2012

 http://www.seeedstudio.com/depot/grove-dust-sensor-p-1050.html
 http://www.sca-shinyei.com/pdf/PPD42NS.pdf

 JST Pin 1 (Black Wire)  => //Arduino GND
 JST Pin 3 (Red wire)    => //Arduino 5VDC
 JST Pin 4 (Yellow wire) => //Arduino Digital Pin 8
 */

int pin = 8;
unsigned long duration;
unsigned long starttime;
unsigned long sampletime_ms = 2000;//sampe 30s ;
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;

void setup() {
  Serial.begin(9600);
  pinMode(8,INPUT);
  starttime = millis();//get the current time;
}

void loop() {
  duration = pulseIn(pin, LOW);
  lowpulseoccupancy = lowpulseoccupancy+duration;

  if ((millis()-starttime) >= sampletime_ms)//if the sampel time = = 30s
  {
    ratio = lowpulseoccupancy/(sampletime_ms*10.0);  // Integer percentage 0=>100
    concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
    Serial.print("concentration = ");
    Serial.print(concentration);
    Serial.println(" pcs/0.01cf");
    Serial.println("\n");
    lowpulseoccupancy = 0;
    starttime = millis();
  }
}



By using this coding, i try to build the circuit of this particle sensor, this is the reading on the Serial Monitor of Arduino.


Insyaallah i will modified the output of the program, so that it is easier for user to understand the reading. There is another program that i had found;
/*
Grove - Dust Sensor Demo v1.0
 Interface to Shinyei Model PPD42NS Particle Sensor
 Program by Christopher Nafis
 Written April 2012

 http://www.seeedstudio.com/depot/grove-dust-sensor-p-1050.html
 http://www.sca-shinyei.com/pdf/PPD42NS.pdf

 JST Pin 1 (Black Wire)  => //Arduino GND
 JST Pin 3 (Red wire)    => //Arduino 5VDC
 JST Pin 4 (Yellow wire) => //Arduino Digital Pin 8
 */

int pin = 8;
unsigned long duration;
unsigned long starttime;
unsigned long sampletime_ms = 2000;//sampe 30s ;
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;

void setup() {
  Serial.begin(9600);
  pinMode(8,INPUT);
  starttime = millis();//get the current time;
}

void loop() {
  duration = pulseIn(pin, LOW);
  lowpulseoccupancy = lowpulseoccupancy+duration;

  if ((millis()-starttime) >= sampletime_ms)//if the sampel time = = 30s
  {
    ratio = lowpulseoccupancy/(sampletime_ms*10.0);  // Integer percentage 0=>100
    concentration = 1.1*pow(ratio,3)-3.8*pow(ratio,2)+520*ratio+0.62; // using spec sheet curve
    Serial.print("concentration = ");
    Serial.print(concentration);
    Serial.println(" pcs/0.01cf");
    Serial.println("\n");
    lowpulseoccupancy = 0;
    starttime = millis();
  }
}

This coding was look more simple compare to the previous one. when i try to get the reading by Serial Monitor, it looks more easier for user to understand.
After this i had to find out the coding and the circuit for displaying the reading on the LCD Display.


*4 WEEK : DHT11 Coding and Circuit

So, for this week, i looking for the basic coding for my DHT11, and there it is;

#include <dht.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

dht DHT;

#define DHT11_PIN 7

void setup(){
  lcd.begin(16, 2);
}

void loop()
{
  int chk = DHT.read11(DHT11_PIN);
  lcd.setCursor(0,0);
  lcd.print("Temp: ");
  lcd.print(DHT.temperature);
  lcd.print((char)223);
  lcd.print("C");
  lcd.setCursor(0,1);
  lcd.print("Humidity: ");
  lcd.print(DHT.humidity);
  lcd.print("%");
  delay(1000);
}


This coding is for displaying the reading of DHT11 sensor to LCD Display. n i had build up the circuit but unfortunately there is wrong connection that i made that cause the damage of sensor, which i connect the GND and VSS in wrong port.



The reading displayed was as shown. To double confirm this damage condition of sensor, i had try to run the system on the Arduino and observe the reading on the Serial Monitor of Arduino software.



The reading was remain the same. So i need to find the new DHT11. But i was satisfied, because at least i had knew the basic coding to displaying the reading data of DHT11.

*3 WEEK : DHT11 Coding

For this 3rd week, i had move to find the coding for my project. I start with the Temperature & Humidity Sensor, DHT11. I search to the internet the basic coding for this sensor. Then i had found this coding, which is displaying the reading of sensor.

#include <DHT11.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
// Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity

int pin = A0;
DHT11 dht11(pin);

double Fahrenheit(double celsius) {
return ((double)(9 / 5) * celsius) + 32;
}

double Kelvin(double celsius) {
return celsius + 273.15;
}

void setup() {
lcd.begin(16, 2);
lcd.backlight();
lcd.clear();
lcd.print("Humidity & temp");
delay(3000);
lcd.clear();
lcd.print("Starting.....");
delay(3000);
}

void loop() {
int err;
float temp, humi;
if ((err = dht11.read(humi, temp)) == 0)
{
lcd.clear();
delay(500);
lcd.setCursor(0, 0);
lcd.print("Temp");
lcd.setCursor(0, 1);
lcd.print("Humidity");
lcd.setCursor(9, 0);
lcd.print(temp);
lcd.print(" C");
lcd.setCursor(9, 1);
lcd.print(humi);
lcd.print(" %");
delay(10000);
}
else
{
lcd.println();
lcd.print("Error No :");
lcd.print(err);
lcd.println();
}
}

But then, when i run this coding, there is an error;


The error show that there is some line that Arduino cannot 'read'. This is because Arduino did not have the library.  
              #include <DHT11.h>
I had tried to solve the error by find the library for that coding, but there is no solution :( :( :(
So i had decided to find another coding and try to modified it.

*2 WEEK : Casing for Prototype

For this week i had thinking about the casing or prototype of my project. I had search at the internet, there are perfect casing;
Datec Mobile Box

This Datec Mobile Box is from OKW Gehause Systeme. It look so perfect for my Air Quality Monitoring System, because the shape, the size and the material is perfectly match with the characteristics for my prototype. Moreover there is a ready space for the LCD Display.
But, i found that the price is extremely expensive, which is almost RM 300. Because of that, i decided to get the usual plastic box that more affordable.. Such like;


*1 WEEK : Basic Circuit

For this week, i start to build up the basic circuit for my project. Which is LCD. The coding for this basic circuit is from Arduino Library.

#Display LCD
/*
  LiquidCrystal Library - display() and noDisplay()

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD and uses the
 display() and noDisplay() functions to turn on and off
 the display.

 The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay

 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("AirQualityMonitor");
}


void loop() {
  // Turn off the display:
  lcd.noDisplay();
  delay(1000);
  // Turn on the display:
  lcd.display();
  delay(3000);
}




#Display LCD 2 Line
/*
  LiquidCrystal Library - display() and noDisplay()

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD and uses the
 display() and noDisplay() functions to turn on and off
 the display.

 The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay

 */

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Air Qlty Monitor");

  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print("  by Adawiyah");
}
void loop() {
  // Turn off the display:
  lcd.noDisplay();
  delay(1000);
  // Turn on the display:
  lcd.display();
  delay(3000);
}




Tuesday, 27 September 2016

*1 COMPONENT

For the beginning of this sem, i choose to complete all my require component and tools. The example of tools is breadboard, jumper and so on. For component, there is 2 component that i had change. Which brand of the sensor and wifi shield.

#AOSONG to DHT11
For temperature and humidity sensor,  i decided to change the brand of the sensor, which is from AOSONG to DHT11. This is because, DHT11 is more familiar compare to AOSONG, so it is more easier for me to get the information for this DHT11, compare to AOSONG. Beside that, the price of DHT 11 is affordable to me.


AOSONG AM2320
DHT 11



          


CHANGE TO









#Arduino WiFi Shield to WiFi Module
Then, for next component is, i had make a decision to change Arduino WiFi Shield to WiFi Module. The main reason i change this component because of the price. The price of the Arduino WiFi Shield is extremely expensive compare to WiFi module. Since the title of my fyp is Development of LOW-COST Air Quality Monitoring, i had consider for this price side. Moreover, the function of WiFi Module and Arduino WiFi module is slightly same.
Arduino WiFi Shield
WiFi Module ESP8266


CHANGE 
TO







#AOSONG DHT11
Product Overview 
DHT11 digital temperature and humidity sensor is a composite Sensor contains a calibrated digital signal output of the temperature and humidity. Application of a dedicated digital modules collection technology and the temperature and humidity sensing technology, to ensure that the product has high reliability and excellent long-term stability. The sensor includes a resistive sense of wet components and an NTC temperature measurement devices, and connected with a high-performance 8-bit microcontroller.

Applications 
HVAC, dehumidifier, testing and inspection equipment, consumer goods, automotive, automatic control, data loggers, weather stations, home appliances, humidity regulator, medical and other humidity measurement and control.

Features 
Low cost, long-term stability, relative humidity and temperature measurement, excellent quality, fast response, strong anti-interference ability, long distance signal transmission, digital signal output, and precise calibration.


#WiFi MODULE ESP8266
Description: The ESP8266 WiFi Module is a self contained SOC with integrated TCP/IP protocol stack that can give any microcontroller access to your WiFi network. The ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor. Each ESP8266 module comes pre-programmed with an AT command set firmware, meaning, you can simply hook this up to your Arduino device and get about as much WiFi-ability as a WiFi Shield offers (and that’s just out of the box)! The ESP8266 module is an extremely cost effective board with a huge, and ever growing, community.
This module has a powerful enough on-board processing and storage capability that allows it to be integrated with the sensors and other application specific devices through its GPIOs with minimal development up-front and minimal loading during runtime. Its high degree of on-chip integration allows for minimal external circuitry, including the front-end module, is designed to occupy minimal PCB area. The ESP8266 supports APSD for VoIP applications and Bluetooth co-existance interfaces, it contains a self-calibrated RF allowing it to work under all operating conditions, and requires no external RF parts.
There is an almost limitless fountain of information available for the ESP8266, all of which has been provided by amazing community support. In the Documents section below you will find many resources to aid you in using the ESP8266, even instructions on how to transforming this module into an IoT (Internet of Things) solution!
Note: The ESP8266 Module is not capable of 5-3V logic shifting and will require an external Logic Level Converter. Please do not power it directly from your 5V dev board.
Note: This new version of the ESP8266 WiFi Module has increased the flash disk size from 512k to 1MB.
Features:
  • 802.11 b/g/n
  • Wi-Fi Direct (P2P), soft-AP
  • Integrated TCP/IP protocol stack
  • Integrated TR switch, balun, LNA, power amplifier and matching network
  • Integrated PLLs, regulators, DCXO and power management units
  • +19.5dBm output power in 802.11b mode
  • Power down leakage current of <10uA
  • 1MB Flash Memory
  • Integrated low power 32-bit CPU could be used as application processor
  • SDIO 1.1 / 2.0, SPI, UART
  • STBC, 1×1 MIMO, 2×1 MIMO
  • A-MPDU & A-MSDU aggregation & 0.4ms guard interval
  • Wake up and transmit packets in < 2ms
  • Standby power consumption of < 1.0mW (DTIM3)

So, this is the current complete component that i will used for my Air Quality Monitoring System;

Monday, 26 September 2016

PSM 2 :P

Assalamualaikum ...
It is the beginning for 4th year sem1, and it is the sem for completing the Projek Sarjana Muda.
Such like the previous sem, i have to update my weekly progress of my project.

Development of a Low-Cost 
Air Quality Monitoring System