Wireless sensor networks using the IEEE 802.15.4 standard
Wednesday, 13 March 2013
Thursday, 7 March 2013
New Codes
So far, we've wanted the readings to be called rather than continuously send data. Therefore, we changed the the codes into a format where the main PC will be able to call the transmitter to send the data being read.
It turned out as so:
float tempK=0, tempC=0, tempF=0;
void setup(){
Serial.begin(9600); //Setup serial to 9600 bps
}
void loop(){
Serial.println("Enter '1' to prompt results");
float reading = analogRead(A0) * 5.0; //Where 5.0V and the Analog (ADC) input
reading /= 1024.0; // is used to determine the voltage reading
tempK = reading * 100; //Read temperature in Kelvins first
tempC = tempK - 273.15; //Convert from Kelvin to Celsius
tempF = ((tempK) * 9 / 5) - 459.67; //Convert from Kelvin to Fahrenheit
while (Serial.available() ==0); //where no value is entered, no data is sent
int val = Serial.read() -'0'; //Set the codes to read 'Char' of the ASCII Table
delay(50);
if(val == 1) //For when the value '1' is given, the data is read
{
//Print all the values to Serial
Serial.print("Voltage: ");
Serial.println(reading);
Serial.println();
Serial.print("Kelvin: ");
Serial.println(tempK);
Serial.print("Celsius: ");
Serial.println(tempC);
Serial.print("Fahrenheit: ");
Serial.println(tempF);
Serial.println(); //Print Blank Line
}
else // For any other data expect for '1', causes an invalid
{
Serial.println("Invalid");
}
while (Serial.available() > 0) Serial.read();
}
Regarding the ASCII Table, if the code was not placed. The value read from pressing '1' will be '49'
It turned out as so:
float tempK=0, tempC=0, tempF=0;
void setup(){
Serial.begin(9600); //Setup serial to 9600 bps
}
void loop(){
Serial.println("Enter '1' to prompt results");
float reading = analogRead(A0) * 5.0; //Where 5.0V and the Analog (ADC) input
reading /= 1024.0; // is used to determine the voltage reading
tempK = reading * 100; //Read temperature in Kelvins first
tempC = tempK - 273.15; //Convert from Kelvin to Celsius
tempF = ((tempK) * 9 / 5) - 459.67; //Convert from Kelvin to Fahrenheit
while (Serial.available() ==0); //where no value is entered, no data is sent
int val = Serial.read() -'0'; //Set the codes to read 'Char' of the ASCII Table
delay(50);
if(val == 1) //For when the value '1' is given, the data is read
{
//Print all the values to Serial
Serial.print("Voltage: ");
Serial.println(reading);
Serial.println();
Serial.print("Kelvin: ");
Serial.println(tempK);
Serial.print("Celsius: ");
Serial.println(tempC);
Serial.print("Fahrenheit: ");
Serial.println(tempF);
Serial.println(); //Print Blank Line
}
else // For any other data expect for '1', causes an invalid
{
Serial.println("Invalid");
}
while (Serial.available() > 0) Serial.read();
}
Regarding the ASCII Table, if the code was not placed. The value read from pressing '1' will be '49'
ASCII Table |
Friday, 1 March 2013
Sunday, 24 February 2013
Arduino UNO
Arduino UNO |
XBEE Shield
Board, Arduino, XBEE Shield, w/o module |
XBEE Module
XB24-BWIT-004 module, ZIGBEE XBEE ZNET 2.5 |
Friday, 15 February 2013
15th Feb 2013
New Software Used:
- X-CTU Software (www.digi.com/support/productdetail?pid=3352)
First up, we would like to connect the Xbee module to the PC. mount the Xbee module onto the Xbee Shield and the Xbee Shield to the Aduino UNO. Take precaution that you will need to remove the ATmega328 from the Arduino UNO. Best advice is to use a screwdriver and slowly pry it off the device. Next, make sure the 2-pin caps on the Xbee Shield are capping the USB side of the 2 out of the 3 pins. Now comes the part where one module receives while the other transmits.
On the X-CTU, under the 'PC settings' tab, set the Baud, Flow Control, Data Bits, Parity and Stop Bits similar to the settings on COM5 (The COM which your Arduino is connected to). Click the 'Test/Query' to see if the componens can communicate and are linked. Sometimes, the outcome would fail. So make sure to check the ATmega328 is out, the caps are capping the right pins, all connections are connected properly and for safe measure, press the 'reset' button on the Arduino UNO. Once successful, click the 'Modem Configuration' tab and under the 'Modem Parameter & Firmware', click 'read'. This will all the XCTU to read what modem is being used currently. Ours would be XB24-B.
Set the 'Function Set' to Coordinator for one of the module and Router/End Device for the other. Here, we are free to change the network settings to however we see fit.
Subscribe to:
Posts (Atom)