7. Sensor Nodes
Nodes Level Functions
Portal User level: display information
in graph, numbers; OS=Linux,
Server Windows
Linux Sub- Intermediate level: process data
from MCUs, reformat, backup,
nodes recalculate; OS=Linux,
Windows
MCUs Lowest level: collect
Microcontrollers digital/analog data from various
sensors, perform basic
calculation, data logger; OS:
MCU level
7 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
8. การสือสารกับ Sensors
่
RS232 – serial communication
LAN – TCP/IP stack
Xbee – serial over wireless
Bluetooth
Edge/GPRS modem
WiFi
Off-Line via SD data logger
8 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
9. MicroClient JrMx
• 1Ghz Xcore86 CPU (x586 CPU with
MMX compatible extensions)
• RAM 512 MB (1GB possible)
• 3 USB 2.0 ports
• RS232
• SATA Hard Disk option
• WIFI available $25.00
• 8 GB SD card slot
• THB 6,600
www.norhtec.com
http://www.norhtec.com/products/mcjrmx/index.html
9 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
10. ติดตั้ง Linux บน JrMX Skipped
เช่นเดียวกับการติดตั้ง Linux ทัวไป ในกรณีที่มี Hard Disk
่
ในกรณีที่ใช้ SD card สามารถใช้เครื่องมือ Universal USB
Installer (ที่ www.pendrivelinux.com) โดยติดตั้งแบบ
persistent
การทางานเช่นเดียวกับไมโครคอมพิวเตอร์ทวไป
ั่
ข้อดี เสียงเงียบ, กินไฟน้อย, ทนอุณภูมิได้สูง, ราคาถูก, มีพอร์ต
ต่างๆ ให้ใช้งานสมบูรณ์
10 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
11. ARM-based Linux Subnode
แนะนา Mini2440/6410 บอร์ด Embedded
การติดตั้ง Linux ลงในบอร์ด Mini6410
การสือสารระหว่าง MCU กับ Linux
่
11 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
34. NokiaLCD.h
#include <OneWire.h> // for DS18S20
// For NOKIA LCD 5110
// The pins to use on the arduino
#define PIN_SCLK 3 // NKLCD-7 --> D3
#define PIN_SDIN 4 // NKLCD-6 --> D4
#define PIN_DC 5 // NKLCD-5 --> D5
#define PIN_RESET 6 // NKLCD-4 --> D6
#define PIN_SCE 7 // NKLCD-3 --> D7
// NKLCD-8 -->Backlight
// NKLCD-2 -->GND
// NKLCD-1 -->V3.3 !!!BE CAREFUL
#include "NokiaLCD.h" // This must be here!! do not move to top
#include "DS18S20.h"
34 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
35. Nokia.h
////////////// S E T U P /////////////////
void setup(void)
{
LcdInitialise();
LcdClear();
//For DS1820
digitalWrite(TEMP_PIN, LOW);
pinMode(TEMP_PIN, INPUT); // sets the digital pin as input (logic 1)
gotoXY(0,0); // ln=0
LcdString("CRMA SensNet");
// gotoXY(0,1); // ln=1
// LcdString("by pyavinci");
ds18s20_setup();
}
35 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
36. Nokia.h
String tempStr;
char *tempC;
/////////////// L O O P ///////////////////////
void loop(void)
{
byte sensor;
// For multiple DS18S20 sensors
for (sensor=0;sensor<MAX_DS1820_SENSORS;sensor++)
{
tempStr = get_ds18s20_temp(sensor);
tempC = &tempStr[0];
// Now display it on the LCD Nokia5110
gotoXY(0,2+sensor);
LcdString(tempC);
}
}
36 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
37. การส่งข้อมูลผ่าน Serial
คอมพิวเตอร์ COM1……COM?
Serial Port
USB-to-Serial Adapter
Hyperterm, PuTTY
Arduino serial via USB
Arduino Commands
Serial.begin(9600);
Serial.println(sensorValue, DEC);
37 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
39. Sensor Network Comm.
GPRS Mobile Network
Long Range Wi-Fi
X-Bee, Bluetooth
Serial Communication
1-Wire Network
I2C
39 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
40. About Xbee
brand name from Digi
International
based on the 802.15.4-2003
over-the-air baud rates of
250kbps
point-to-point and point-to-
multipoint
1mW Xbee
100mW XBee-PRO
Freq: 868, 900 MHz, 2.4GHz
40 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
61. Sensor-1: Code->setup
////// O B J E C T S ///////
LiquidCrystal lcd(LRS, LEN, LD4, LD5, LD6, LD7);
EtherShield es=EtherShield();
OneWire ds(TEMP_PIN); // pin that DS18S20 attached to
SHT1x sht1x(dataPin, clockPin); // Temp-Humid
///// GLOBAL VARIABLES
int reliaCount=0;
long prevMil=0;
int HighByte, LowByte, TReading, SignBit, Tc_100, Whole,
Fract;
char tbuf[20];
byte addr[MAX_DS1820_SENSORS][8];
61 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
62. Sensor-1: Code->Ranging
////// FOR HC-SR04 Ultrasonic Ranging
// The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
// Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
pinMode(USPING, OUTPUT);
digitalWrite(USPING, LOW);
delayMicroseconds(2);
digitalWrite(USPING, HIGH);
delayMicroseconds(10);
digitalWrite(USPING, LOW);
// The same pin is used to read the signal from the PING))): a HIGH
// pulse whose duration is the time (in microseconds) from the sending
// of the ping to the reception of its echo off of an object.
pinMode(USPONG, INPUT);
duration = pulseIn(USPONG, HIGH);
// convert the time into a distance
//inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
62 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
64. Sensor-1: Code->DS18S20
// LOOP FOR MULTIPLE DS18S20(s)
for (sensor=0;sensor<MAX_DS1820_SENSORS;sensor++)
{ if ( OneWire::crc8( addr[sensor], 7) != addr[sensor][7])
{ Serial.print("CRC is not valid");
return;
}
if ( addr[sensor][0] != 0x10)
{ Serial.println("Device is not a DS18S20 family device.");
return;
}
64 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
65. Sensor-1: Code->DS18S20
ds.reset();
ds.select(addr[sensor]);
ds.write(0x44,1); // start conversion, with parasite power on at the end
delay(50); // maybe 750ms is enough, maybe not
// Note(by PC) Originally set to 750
// But I found here 50 or less is OK
// Due to delay from other processing
// we might do a ds.depower() here, but the reset will take care of it.
present = ds.reset();
ds.select(addr[sensor]);
ds.write(0xBE); // Read Scratchpad
for ( i = 0; i < 9; i++) { // we need 9 bytes
data[i] = ds.read();
}
LowByte = data[0];
HighByte = data[1];
TReading = (HighByte << 8) + LowByte;
65 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
66. Sensor-1: Code->DS18S20
SignBit = TReading & 0x8000; // test most sig bit
if (SignBit) // negative
{ TReading = (TReading ^ 0xffff) + 1; // 2's comp
}
Tc_100 = (TReading*100/2);
Whole = Tc_100 / 100; // separate off the whole and
fractional portions
Fract = Tc_100 % 100;
sprintf(tbuf, "%d.%d",Whole, Fract < 10 ? 0 : Fract);
} // EndFor loop for DS18S20
66 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
67. Sensor-1: Code->Light
lcd.print("T2 L ");
long ls=analogRead(0);
lcd.setCursor(3,1);
lcd.print(tbuf); // Temperature from DS18S20
lcd.setCursor(11,1);
lcd.print(ls); // Light Sensor data
67 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
68. Sensor-1: Code->EN28J60
///////// TCP/IP PART
plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);
// plen will ne unequal to zero if there is a valid packet
(without crc error)
if(plen!=0){
// arp is broadcast if unknown but a host may also verify the
mac address by sending it to a unicast address.
if(es.ES_eth_type_is_arp_and_my_ip(buf,plen)){
es.ES_make_arp_answer_from_request(buf);
return;
}
……… CUT ……………
68 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
69. Sensor-1: Code->EN28J60
……… CUT ……………
SENDTCP:
es.ES_make_tcp_ack_from_any(buf); // send ack for
http get
es.ES_make_tcp_ack_with_data(buf,plen); // send
data
}
}
}
69 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
95. Sensor-3: Code Loop
else {
LcdString(" 0 ");
bstate=0;
}
gotoXY(15,3);
sprintf(gstr," %d ",bc);
LcdString(gstr);
}
/* for (sensor=0;sensor<MAX_DS1820_SENSORS;sensor++) {
tempStr = get_ds18s20_temp(sensor);
tempC = &tempStr[0];
// Now display it on the LCD Nokia5110
gotoXY(0,2+sensor);
LcdString(tempC);
} */
95 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
96. Sensor Nodes
Nodes Level Functions
Portal User level: display information
in graph, numbers; OS=Linux,
Server Windows
Linux Sub- Intermediate level: process data
from MCUs, reformat, backup,
nodes recalculate; OS=Linux,
Windows
MCUs Lowest level: collect
Microcontrollers digital/analog data from various
sensors, perform basic
calculation, data logger; OS:
MCU level
96 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
97. Portal Server
Alternative Displaying Methods:
Processing
MRTG
Google Chart –
TimeSeriesGraph()
97 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
98. Processing IDE
98 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
99. Processing
www.processing.org
open source programming
language and environment for
people who want to create
images, animations, and
interactions.
Over 100 libraries
run online or as double-
clickable (apps)
99 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)
101. pachube
www.pachube.com
access anywhere
environment data
visualization service
a clearinghouse for sensor
data
Ultimate data storage
platform independent of
sensor itself
A platform to access global
sensor user generated
content
101 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)