You are on page 1of 27

(Work In Progress)

.. , Ph.D. ... , Ph.D. .. . .


1 WUNCA24 2011: CRMA Sensor Network (Work-inProgress) 2

Wireless Sensor Network (SL) CRMA Sensor Network sensor network Sensor Nodes MCU sensor network (SS) ARM-based Linux Subnode Portal/Display Servers Power Consumption

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Prof. Surat

Preferred Audience Background


Internetworking, TCP/IP C Programming Windows 7 Experiences, Terminal, PuTTY Digital Fundamentals Electronics Wiring, Soldering Tools: cut, drill, glue $$$
WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Wireless Sensor Network


Sensors? Environment Data Temperature/Humidity Wind Speed/Direction Light, Object movement Motion/Tilt Sound, Image, Video patterns, time series data Wireless?

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

CRMA Sensor Network


Conceptual Design

CRMA Sensor Network


Conceptual Design
Sensor Nodes
Serial, LAN, Xbee, Bluetooth Serial, I2C, I 1-Wire, SPI

Intermediate Nodes

Serial, LAN, Xbee, Bluetooth

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor Nodes
Nodes Level Portal Server Linux Subnodes MCUs Functions
User level: display information in graph, numbers; OS=Linux, Windows Intermediate level: process data from MCUs, reformat, backup, recalculate; OS=Linux, Windows Lowest level: collect digital/analog data from various sensors, perform basic calculation, data logger; OS: MCU level
8

Sensors
RS232 RS232 serial communication LAN TCP/IP stack Xbee serial over wireless Bluetooth Edge/GPRS modem WiFi OffOff-Line via SD data logger

Microcontrollers

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

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

Linux JrMX

Skipped

Linux Hard Disk SD card Universal USB Installer ( www.pendrivelinux.com) persistent

www.norhtec.com
http://www.norhtec.com/products/mcjrmx/index.html
9 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress) 10

, , , ,

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

ARM-based Linux Subnode


Mini2440/6410 Embedded Linux Mini6410 MCU Linux

Mini2440/6410

FriendlyArm

11

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

12

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Mini2440/6410
2440
400 MHz Samsung S3C2440 ARM9 64 MB RAM 128 MB / 256 MB / 1GB NAND SD-Card RS232 THB 5,580.-

FriendlyArm

Mini2440/6410

FriendlyArm

6410
533 MHz Samsung S3C6410 ARM11 128 MB / 256 MB 256 MB / 1GB NAND SD-Card/SDIO socket RS232 THB 6,000.-

13

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

14

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Mini2440/6410
RS RS232 232 USB DVD Video J-Tag Display AC USB Serial

FriendlyArm

Mini2440/6410
Linux kernel 2.6 QT (Xwindows) interface Touch screen Serial Port Video (on 6410) Audio USB SD card

FriendlyArm

15

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

16

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Linux 2440
1. Image andahammer 2.

Linux 2440
6. 7. 8. 9. 10. 11. 12. 13.

3. 4. 5.

Board USB Serial (RS-232) Mini2440 serial USB-Serial converter ( driver ) dwn ( Windows Tools/dwn) S2 NOR Reset

DWN Serial, USB, Config terminal serial flash Mini2440 upload/download USB ( ) bootloader (supervivi) zImage (Linux kernel) FS S2 OS serial terminal

17

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

18

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Linux 6410
OS SD card 1. SD 4 GB 2. SD-Flasher Administrator, SD-Flasher (tools/SD-Flasher) 3. images/superboot-20100917.bin Image File to Fuse 4. Scan removable SD SD Drive(s) 5. Available Yes No ReLayout (1 Succeeded)
19 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress) 20

Linux 6410
OS SD card () 6. ReLayout format SD ( Quick format ) Scan Available Yes 7. Available Yes Fuse SuperBoot SD 8. File Explorer SD images 9. OS Ubuntu, Linux, Android images/ DVD images SD 10. FriendlyARM.ini images images SD 11. FriendlyARM.ini OS boot
WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Linux 6410
SD Mini6410 1. eject SD SD 2. S2 SD - beep LED beep beep ( ) beep 3. S2 NAND boot 4. Terminal, Putty DWN serial

FriendlyARM.ini
#This line cannot be removed. by FriendlyARM(www.arm9.net) CheckOneButton=No #Action=install Action=run OS=Linux VerifyNandWrite=No StatusType = Beeper| LED ############# Linux ##### Linux-BootLoader = Linux/u-boot_nand-ram128.bin Linux-Kernel = Linux/zImage_A70 Linux-CommandLine = root=/dev/mtdblock2 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200 Linux-RootFs-InstallImage = linux/rootfs_qtopia_qt4-s.img Linux-RootFs-RunImage = linux/rootfs_qtopia_qt4-s.ext3
22 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

21

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

FriendlyARM.ini
################### WindowsCE6 ################# WindowsCE6-Bootloader= WindowsCE6\NBOOT_A70-RAM128.nb0 WindowsCE6-BootLogo = WindowsCE6\bootlogo.bmp WindowsCE6-InstallImage = WindowsCE6\NK_A70-s.bin WindowsCE6-RunImage = WindowsCE6\NK_A70-s.bin ################### Android #################### Android-BootLoader = Android/u-boot_nand-ram128.bin #Android-Kernel = Android/azImage_a70 Android-Kernel = Android/azImage_n43 Android-CommandLine = root=ubi0:FriendlyARM-root ubi.mtd=2 rootfstype=ubifs init=/linuxrc console=ttySAC0,115200 Android-RootFs-InstallImage = Android/rootfs_android-s.ubi Android-RootFs-RunImage = Android/rootfs_android-s.ext3
23 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress) 24

FriendlyARM.ini
################### Ubuntu ##################### #Ubuntu-BootLoader = Ubuntu/u-boot_nand-ram128.bin #Ubuntu-BootLoader = Ubuntu/u-boot_nand-ram256.bin Ubuntu-BootLoader = Ubuntu/u-boot_sd-ram256.bin #Ubuntu-Kernel = Ubuntu/uzImage_a70 Ubuntu-Kernel = Ubuntu/uzImage_n43 Ubuntu-CommandLine = root=ubi0:FriendlyARM-root ubi.mtd=2 rootfstype=ubifs init=/linuxrc console=ttySAC0,115200 Ubuntu-RootFs-InstallImage = Ubuntu/rootfs_ubuntu-s.ubi Ubuntu-RootFs-RunImage = Ubuntu/rootfs_ubuntu-s.ext3 ############### UserBin part ################# UserBin-Image=WindowsCE/NK.nb0 userBin-StartAddress=50100000
WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Arduino MCUs

Microcontrollers

Arduino MCUs
Duemilano ve 2009 Uno 328 14 8 32K/2K 2K 1K 16MHz Yes $25.00 762.50 Mega atmega1280 1280 54 26 128K/4K 8K 4K 16MHz Yes $28.98 883.89 Mega atmega2560 2560 54 (14 PWM) 16 256K/8K 8K 4K 16MHz Yes $44.00 1,342.00 Nano 168/328 168/328 14 8 32K/2K 2K 1K 16MHz Mini 17.99 548.70

Arduino MCU (Duemilanove, Mega, Nano) sensor MCU


DS18S20 Temperature sensor SHT1x Temperature & Humidity sensor Analog light sensor Distance sensor Wind Speed

uCon 168-328 Atmega Digital I/O 14 Analog 6 Inputs Flash/Bootlo 16-32K/2K ad SRAM 1K EPROM 512-1K Clock 16MHz USB Yes Cost $ $18.75 THB 571.88

25

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

26

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Arduino MCUs
Mega Duemilanove Nano

Duemilanove

27

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

28

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Arduino MCUs
MCU Arduino IDE (SS) LCD
LCD 1602, 1604 Nokia LCD

LCD 1602/1604
LiquidCrystal.h LCD (210 THB) HD44780-based Backlight

Serial MCU EtherShield

29

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

30

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

LCD 1602/1604

LCD Hello World!

31

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

32

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

LCD: Nokia 5110


, , 6 82 3.3 V Backlight

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"

33

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

34

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

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); } }

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Serial
COM1 COM1COM? COM? Serial Port USBUSB-toto-Serial Adapter Hyperterm, PuTTY Arduino serial via USB Arduino Commands Serial.begin Serial.begin( begin(9600); 9600); Serial.println Serial.println( println(sensorValue, sensorValue, DEC);

MCU
Serial SPI Serial Peripheral Interface I2C OneWire UART Universal asynchronous receiver/transmitter

37

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

38

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor Network Comm.


GPRS Mobile Network Long Range Wi-Fi X-Bee, Bluetooth Serial Communication 1-Wire Network I2C

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-tomultipoint 1mW Xbee 100mW XBee-PRO Freq: 868, 900 MHz, 2.4GHz
40 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

39

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Xbee Wireless Comm.

X-CTU

Xbee

41

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

42

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

sensor

Xbee
void setup() { Serial.begin(9600 Serial.begin(9600); 9600); } void loop() { int sensorValue = analogRead(A0 analogRead(A0); Serial.println(sensorValue, DEC); delay(500 delay(500); 500); }

43

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

44

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Ongoing Prototypes
Sensor 1: LAN, 2 x Temp, Humi, Light, Range Sensor 2: Temp/Humi x 2, Xbee Sensor 3: Anemometer, Serial

Sensor-1
Arduino Mega128 SHT1x: Temperature/Humidity Light Sensor (analog) Ultrasonic Ranging (2 analog) DS18s20: Digital Temperature (OneWire) LCD 1604 Weather-proof Case (not in this prototype)

45

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

46

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-2
Duemilanove 2009 (328) 2 DHT11 (digital humidity/temperature) Xbee wireless LCD 1602 Custom indoor box Custom Xbee/USB switch

Sensor-3
Duemilanove Recycled rotary encoder from old mouse 2 analog pins input LCD Nokia Custom box Proprietary Wind Cups

47

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

48

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-1: light, H/T x2, Range

Look Inside Each Sensor

49

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

50

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

LCD 1604

Light Sensor

51

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

52

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

53

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

54

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

55

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

56

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

57

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-1: Code->setup
// LCD==================================== #define LCD_WIDTH 20 #define LCD_HEIGHT 4 #define LD4 11 #define LD5 10 #define LD6 9 #define LD7 8 #define LEN 12 // LCD Enable #define LRS 13 // LCD RS /*=================+======+ LCD 16x2 Mega 1 (Vss/Ground) GND 2 VCC +5V 3 Vo(contrast) VR 4 RS 13 5 R/W GND 6 Enable 12 Pin 11-14 (D4-D7) 11-8 */
WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-1: Code->setup
static uint8_t mymac[6] = { 0x54,0x55,0x58,0x10,0x00,0x24}; static uint8_t myip[4] = { 192,168,1,15}; static char baseurl[]="http://192.168.1.15/"; // listen port for tcp/www (max range 1-254) static uint16_t mywwwport =80; static uint8_t buf[BUFFER_SIZE+1]; static char strbuf[STR_BUFFER_SIZE+1];

59

60

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

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);

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-1: Code->Ranging
cm = microsecondsToCentimeters(duration); lcd.setCursor(0,2); lcd.print(" "); lcd.setCursor(0,2); lcd.print("Distance(cm): "); lcd.print(cm);

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; }

63

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

64

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

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;

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)

65

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

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

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)

67

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

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 } } }

Sensor-2: Xbee, DHT11

69

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

70

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

DHT11

Box, Xbee

71

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

72

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Switch for Upload

Sensor-2: Code

setup

#include <LiquidCrystal.h> #define LCD_Print(x,y,t) lcd.setCursor(x,y);lcd.print(t) // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); .. void printSerial(void); void printSerial2(void); #include <dht11.h> dht11 DHT11,DHT11B; #define DHT11PIN 6 #define DHT11BPIN 7

73

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

74

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-2: Code

setup

Sensor-2: Code

loop

void setup() { Serial.begin(9600); Serial.println("DHT11 TEST PROGRAM "); Serial.print("LIBRARY VERSION: "); Serial.println(DHT11LIB_VERSION); Serial.println(); pinMode(DHT11BPIN,INPUT); pinMode(DHT11PIN,INPUT); lcd.begin(16, 2); LCD_Print(0,1,"CRMA SenseNet"); }

void loop() { Serial.println("\n"); int chk = DHT11.read(DHT11PIN); Serial.print("____Read sensor: 0 ->"); delay(1000); switch (chk) { case 0: { Serial.println("OK"); printSerial(); break; } case -1: Serial.println("Checksum error"); break; case -2: Serial.println("Time out error"); break; default: Serial.println("Unknown error"); break; }

75

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

76

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-2: Code

loop

Sensor-3: Anemometer

chk = DHT11B.read(DHT11BPIN); // read another DHT11 Serial.println("\n"); Serial.print("____Read sensor: 1 ->"); delay(1000); switch (chk) { case 0: { Serial.println("OK"); printSerial2(); break; } case -1: Serial.println("Checksum error"); break; case -2: Serial.println("Time out error"); break; default: Serial.println("Unknown error"); break; } } **** NOTE **** See sensor data sent via Xbee We didnt do anything for Xbee (but dont forget the jumper)
WUNCA24 2011: CRMA Sensor Network (Work-in-Progress) WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

77

78

Wind Cups

79

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

80

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Nokia LCD Test

81

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

82

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

LCD, Arduino in box

Connected to Arduino

83

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

84

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Calibration

85

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

86

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-3: Code

Setup

Sensor-3: Code

Setup

#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 // 6 lines (0 to 5) // 83 H_dots (0 to 82) //#include "DS18S20.h" // Change pin number in this file accordingly #define THRESHOLD 120 ////////////// S E T U P /////////////////
87 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress) 88

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"); }
WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-3: Code

Loop

Sensor-3: Code

Loop

String tempStr; char tempC[16]; char *gstr=&tempC[0]; unsigned int a,b,ax=0,bx=0,adiv=0,bdiv=0,aprev,bprev; unsigned long at=0,bt=0,ac=0,bc=0,tprev=0,t=0; unsigned int astate=1, bstate=1; float rpm; /////////////// L O O P /////////////////////// void loop(void) { int t; a=analogRead(0); b=analogRead(1);
89 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress) 90

String tempStr; char tempC[16]; char *gstr=&tempC[0]; unsigned int a,b,ax=0,bx=0,adiv=0,bdiv=0,aprev,bprev; unsigned long at=0,bt=0,ac=0,bc=0,tprev=0,t=0; unsigned int astate=1, bstate=1; float rpm; /////////////// L O O P /////////////////////// void loop(void) { int t; a=analogRead(0); b=analogRead(1);
WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-3: Code
gotoXY(0,2); if(a>THRESHOLD) { if (astate==0) { LcdString(" 1 "); ac++; t=millis()-tprev; rpm=(60000/(40*t)); sprintf(gstr,"RPM: %d.%d gotoXY(0,4); LcdString(gstr); tprev=millis(); } astate=1; }
91

Loop

Sensor-3: Code
gotoXY(0,2); if(a>THRESHOLD) { if (astate==0) { LcdString(" 1 "); ac++; t=millis()-tprev; rpm=(60000/(40*t)); sprintf(gstr,"RPM: %d.%d gotoXY(0,4); LcdString(gstr); tprev=millis(); } astate=1; }
92

Loop

",(int)rpm,(rpm-(int)rpm)*100);

",(int)rpm,(rpm-(int)rpm)*100);

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-3: Code
else { LcdString(" 0 "); astate=0; } gotoXY(15,2); sprintf(gstr," %d ",ac); LcdString(gstr); gotoXY(0,3); if(b>THRESHOLD) { if (bstate==0){ LcdString(" 1 "); bc++; } bstate=1; }

Loop

Sensor-3: Code
else { LcdString(" 0 "); astate=0; } gotoXY(15,2); sprintf(gstr," %d ",ac); LcdString(gstr); gotoXY(0,3); if(b>THRESHOLD) { if (bstate==0){ LcdString(" 1 "); bc++; } bstate=1; }

Loop

93

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

94

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Sensor-3: Code

Loop

Sensor Nodes
Nodes Level Functions
User level: display information in graph, numbers; OS=Linux, Windows Intermediate level: process data from MCUs, reformat, backup, recalculate; OS=Linux, Windows Lowest level: collect digital/analog data from various sensors, perform basic calculation, data logger; OS: MCU level

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

Portal Server
Linux Subnodes MCUs

Microcontrollers

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Portal Server
Alternative Displaying Methods: Processing MRTG

Processing IDE

Google Chart
TimeSeriesGraph() TimeSeriesGraph()

97

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

98

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

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 doubleclickable (apps)

Processing www.processing.org

serial Processing pachube

99

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

100

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

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) 102

MRTG
Time series, historical data

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

Google Chart

Google Chart
Example HTML

Display live data Rich tools Free Customizable


103 WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

<html> <head> <script type='text/javascript' src='https://www.google.com/jsapi'></script> <script type='text/javascript'> google.load('visualization', '1', {'packages':['annotatedtimeline']}); google.setOnLoadCallback(drawChart); function drawChart() { var data = new google.visualization.DataTable(); data.addColumn('date', 'Date'); data.addColumn('number', 'Sold Pencils'); data.addColumn('string', 'title1'); data.addColumn('string', 'text1'); data.addColumn('number', 'Sold Pens'); data.addColumn('string', 'title2'); data.addColumn('string', 'text2'); data.addRows([ [new Date(2008, 1 ,1), 30000, undefined, undefined, 40645, undefined, undefined], [new Date(2008, 1 ,2), 14045, undefined, undefined, 20374, undefined, undefined], [new Date(2008, 1 ,3), 55022, undefined, undefined, 50766, undefined, undefined], [new Date(2008, 1 ,4), 75284, undefined, undefined, 14334, 'Out of Stock','Ran out of stock on pens at 4pm'], [new Date(2008, 1 ,5), 41476, 'Bought Pens','Bought 200k pens', 66467, undefined, undefined], [new Date(2008, 1 ,6), 33322, undefined, undefined, 39463, undefined, undefined] ]); var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div')); chart.draw(data, {displayAnnotations: true}); } </script> </head> <body> // Note how you must specify the size of the container element explicitly! <div id='chart_div' style='width: 700px; height: 240px;'></div> </body> </html>

Power Consideration
Sensors Grid Power Solar, Wind, Hybrid Stand-alone Battery Pack Others (waterfall, Hydrogen, etc.)

?? ??
surat@crma.ac.th prachya@crma.ac.th pyavinci@gmail.com http://code.google.com/p/crmahttp://code.google.com/p/crma sensorsensor -networknetwork-projectproject-2011/ 2011/

105

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

106

WUNCA24 2011: CRMA Sensor Network (Work-in-Progress)

You might also like