An Internet Based Interactive Data Acquisition System


Published on

This is my Report of My Engineering final year project , I made an internet based data acquisition system using microcontroller Atmel168 (Arduino)

Published in: Design, Business, Technology
1 Comment
No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

An Internet Based Interactive Data Acquisition System

  1. 1. An Internet BasedInteractive Real –TimeData AcquisitionSystemA Data Acquisition Sytem with Internetconnectivity for better Connectivity andControllability on a Move
  2. 2. Index .........1.Introduction.................................................................................. 1 Embedded systems Data Acquisition System Internet Enabled Embedded Systems Internet Data Acquisition System Benefits Limitations2. An Internet Based Data Acquisition System for Real Time Applications....... 2 Tools and Components Microcontroller ATMEGA168 ENC28J60 Ethernet Controller MAC PHY RJ45 MagJack LM35 Temperature Sensor Power Supply Motor Driver L293D3.Softwares Used ............................................................................................. 13 Arduino Processing4. External third-party server used .................................................................. 14 Google :Google Docs Pachube5. Methods of Building a Data Acquisition System............................................166. Using the ENC28J60 Ethernet Controller Node connected to a router toupload the sensor value .................................................................... 17 2
  3. 3. MethodologyProgram’s structure7. using PC to save sensor data in Google Spreadsheet ............................... 26 Methodology Program’s structure8. A Full Duplex communication over the internet , between the third partyserver (Pachube) and an Embedded device connected to PC directly............30 Methodology Program’s structure9. Conclusion .................................................................................................................................... 3410. Reference ....................................................................................................................................34 3
  4. 4. The Entire Setup of my the Internet Based Data Acquisition System 4
  5. 5. IntroductionEmbedded SystemsEmbedded systems is a computer system designed for specific control functions within a largersystem often with real time computing constraints .It is embedded as part of a complete deviceoften including hardware and mechanical parts whereas a desktop PC is designed to be a general-purpose computer, such as a personal computer (PC), is designed to be flexible and to meet a widerange of end-user needs but are quite expensive . Embedded systems control many devices incommon use today and are usually build dedicated to perform a specific task . Design engineers canoptimize it to reduce the size and cost of the product and increase the reliability and performance.Some embedded systems are mass-produced and reducing the cost still further. Embedded systemsare especially suited for use in transportation, fire safety, military, security, medical applications inform of alarm system monitoring abnormal activity or Data acquisition system monitoring a patient’sheart beat for further analysing of the patient’s health. Other consumer electronics like handheldcomputer , Personal Digital Assistant (PDA) , GPS , Home automation system ,Temperaturemonitoring system in homes etcData Acquisition system A typical Data acquisition system (DAS) consists of individual sensors with the necessary signalconditioning , data conversion , data processing , multiplexing , data handling and associatedtransmission , storage and display data. DAS is very useful in keeping track of data from sensorsrecording values from the environment in real time .In order to optimise the characteristics of thesystem in terms of handling capacity and cost .Analog data is generally acquired and converted itodigital form for the purpose of processing , transmission , display and storage. The data collected from the sensor may be transmitted over long distances fromthe test center to the controlling authority , Some of the main objective of data acquisition systemare : Use of all data efficiency to inform the operator to inform the operator about the state of the plant. It must monitor the complete plant operation to maintain on-line optimum and safe operation. It must be flexible and capable of being expanded for future requirements. It must be able to compute unit performance indices using on-line , real time data. It must be able to collect , summarise and store data for diagonosis of operation and record purpose. It must provide an effective human communication system and be able to identify problem areas , thereby minimising unit availability and maximising unit through point at minimum cost. 5
  6. 6. Processing may consist of a large variety of operations , ranging from simple comparison tocomplicated mathematical manipulations. It can be for such a purpose as collection ofinformation(averages,satistics) ,converting the data into useful forms (eg calculations of efficiency ofmotor speed , torque and power input developed), using data for controlling a process ,performingrepeated calculation to separate signals buried in the noise , generating information for display ,andvarious other purpose.Data may be transmitted over long distances or short distance . Both wired or wireless transmissionis used for transmission of data from test centre to a nearby PC , display panel or CRO .In wirelesstransmission the data is send from test centre to the display unit either through infrared , Bluetoothor Zigbee protocol . Wireless transmission tends to be more flexible , but expensive and complex asthere is a need for connecting external transmission/receiver modules between the test centre anddisplay unit and then to provide necessary calibration between them.Internet Enabled Embedded Systems Industry analysts see embedded Internet systems as poised for rapid growth in the manufacturingsector in the next few years. To date, much of the research work pertaining to the Internet inconstruction, has focused on person to person, or computer to computer communication.Embedded Internet systems allow users to communicate with other items such as plant, machinery,and manufactured components delivered to site. This communication may range from passiveremote monitoring to direct control or resetting. Intel terms this as the fourth phase in the evolutionof internet ; The first being connection to main frames (external server ; Primary example on whatthis project is based on ) , The second being e- commerce and e-mail revolution , and the third beingsocial networking . With Embedded systems getting more advanced and so many devices waiting tobe connected to the internet Generally used embedded systems like PDA, MP3 Players , Mobile phones havealready started to get connected to the internet for reasons like accessing the social networking sites, Mobile banking (also known as M-Banking, mbanking, SMS Banking) is a term used forperforming balance checks, account transactions, payments, credit applications and other bankingtransactions through a mobile device such as a mobile phone or Personal Digital Assistant (PDA),Downloading media files like songs and video through internet to be played on PDA or MP3 players.Popular digital camera manufacturers like Canon and Samsung are developing Cameras that canhave direct internet access using a WI-Fi connection , and directly upload images to popular photosharing websites like Flickr , Picasa or social networking websites like facebook .Televisions too arealso getting connected to internet . Some modern day television also have a Ethernet port to accessand play content from the internet like videos from popular video sharing websites like Youtube ,Metacafe , Other consumer goods like Home thermostat could also be able to get connected to theinternet so that the consumer may set it to start cooling or heating the room moments beforeleaving for home from their workplace .Other examples of general consumer electronics productsneeded to be connected to the internet for either of the three reasons mentioned above are just toomany to be mentioned .Internet Based Data Acquisition SystemThe Primary goal of building a Internet connected Data Acquisition system is to build a DAS whichwould be able to acquire the necessary data from sensors , at correct speed and at a correct timeand upload and record the values up on an external server through internet . So that a system valuescan be monitored from anywhere without the need of special equipments to receive and displayinformation in condensed , understandable and legible manner. A user may also be able to diagnose 6
  7. 7. the problem and could even set it right .The information can easily be accesed and controlled by PCor PDA with internet access , which in turn can be connected to a local low cost local area network(LAN) to transfer sensor values directly to a data logger or computer. The accessibility of thisinformation is significantly curtailed by this need for proximity. However, developments in theInternet protocol, TCP/IP, which is the universal communication standard, looks set to change all ofthis. In order to allow communications to be directed, every physical location on the Internet (serveror client) requires an IP address. Softwares have been designed to run in PDA or PC that passesmessages received on an IP network to the logger hardware via a serial port or USB.Or through GPRS , Bluetooth , Zigbee etc.Benefits : The Benefits of an internet based DAS are Display information instantly in condensed , understandable and legible manner so that it can be easily assimilated. Provide a series of recorded event saved in the server , to the operator’s PDA on demand Send an e-mail or SMS to the operator’s PC or mobile phone in case an emergency occurs Provide the operator with necessary guidance message and options to perform secure operation of control systems remotely in case an emergency occurs eg switching on a cooler in case the temperature rises to an alarming level , switch on a pump to water the plants when the moisture in soil has dropped to a very low value etc Produce a hard copy record of all plant operationg events and various plant logs on demand. Internet based DAS provide the flexibility for handling embedded systems which requires real time demands like traffic monitoring , precision agriculture , water resources management etcLimitation: Although few of the biggest drawback in building Internet based DAS (IDAS) are The biggest limitation is “Security” , An IDAS with internet connectivity and an external server acting as primary memory , Crucial information of plant operation and real-time sensor reading might fall in wrong hands (Hackers), which could led to disastrous result both financially and to Human life. Power Management: Current internet enabled embedded devices (IEED)employ high end peripherals and heavy software stacks leading to the increased consumption of power and consequent reduction in battery life. Full usage of Channel: Most of the Internet enabled embedded devices (IEED) available are capable of supporting communication over fast Ethernet or even gigabit Ethernet , Though the communication is over the internet , they are not capable of using the channels to the full extent. On an average , most of the IEED are capable of transferring only a few bytes of data . Current Internet technologies do not feature predictable delays in data delivery .Most IEED are real time and hence predictable time delay is a basic requirement . eg In case of A/D conversion an IDAS need some time delay (conversion time), any packets of data through internet to the IDAS during this time interval demanding the real-time sensor reading from IDAS could disturb the entire apparatus set-up. 7
  8. 8. An Internet Based Interactive Data Acquisition System for Real-timeApplicationsThe primary aim of building this project is to build an Microcontroller ATMega168 enabledembedded system which could able to read analog values from temperature sensors Processes it ,connects to a web server, and submits the values through as arguments in the URL to be stored orprocessed by a script on the server. And can be accesed on demand by internet enabled PC ,PDA andmobile phones , A application would also be running in the PDA or PC which would be able to displaythe reading from the sensors in a legible and understandable manner along with the time variations.The application should also provide options for operating other peripherals that is connected to theembedded device like LCD, Motor ,Pump etc. Fig 1: System Architecture of the Internet Based Data Acquisition systemThe System consists of two nodes one is the microcontroller board which consists of microcontrollerATmega168 , Temperature sensor LM35 , Potentiometer (for testing purpose) ,Motor Driver L293D(for operating actuators like pump, fan) 3v3 volt regulator for powering the Ethernet module andThe second node is the Ethernet controller which consists of Ethernet Controller ENC28j60 fromMicrochip and RJ45 Jack with Integrated magnetic and integrated LEDS (LEDA and LEDB : DepictingTransmission and Reception of Packets through the cable)The Microcontroller board node communicates with the Ethernet controller node using the SPI(Serial peripheral Interface) protocol. Hence , Four cables are used for Chip Select (CS), ShiftClock(SCLK) , SDI (Din) and SDO (Dout) to maintain SPI communication between the two nodes. 8
  9. 9. Tools and ComponentsThe Major off the shelf component used in the project has been listed below. The Microcontroller ,Temperature sensors were available from hobbyist store , The Ethernet controller and RJ45 jack withinternal magnetic however were not typically available from ordinary hobbyist stores . But areobtained from international online stores. Atmega168 Microcontroller Microchip’s Ethernet controller ENC28J60 LM35 (Temperature Sensor) RJ45 Jack RJ45 Plug/Cable L293D Motor Driver LM7805 (5V regulator) 3.3V voltage regulatorMicrocontroller Atmega168 Fig 2 : Pin Diagram of Microcontroller ATMEGA168Microcontroller ATMEGA 168 is a 8 bit 28 pin microcontroller from ATMEL corporation , Some of theprime feature of this Microcontroller because of which this microcontroller has been selected forthis project are :- Memory Details  1K bytes of internal SRAM  512 bytes of EEPROM 9
  10. 10.  32x8 general purpose resistors (GPRs)  Write/ Erase Cycles : 10,000 flash / 100,000 EEPROM Peripheral Features  8 channel 10 bit ADC  6 PWM channels  Two 8 bit timer/counter with separate prescaler and compare mode  Dual programmable Serial USART  On chip analog Comparator  Master Slave SPI Serial Interface  Programmable Watch Dog Timer with separate On chip OscillatorAll these features are sufficient , for building the IDAS . Pheripheral features like 8 channel ADC canbe used for reading the sensor values , PWM channels are used for operating external peripheralslike servo motors , motor etc , Serial USART is used to serially transfer data like sensor reading ,Unexpected errors etc , On chip Analog comparator is used for comparing the sensor reading with areference voltage (and then to take necessary operation) , SPI Serial interface : to communicatewith the ENC28j60 ethernet controller and Watch Dog Timer to reset itself in case of unexpectederror in absence of the operator, Small size and low cost gives an extra advantage.ENC28J60 Ethernet ControllerENC28J60 Ethernet controller from Microchip Corporation. The ENC28J60 is a stand-alone Ethernetcontroller with an industry standard Serial Peripheral Interface (SPI). It is designed to serve as anEthernet network interface for any controller equipped with SPI. The ENC28J60 meets all of the IEEE802.3 specifications.It incorporates a number of packet filtering schemes to limit incoming packets. It also provides aninternal DMA module for fast data throughput. Communication with the host controller isimplemented via two interrupt pins and the SPI, with data rates of up to 10 Mb/s. Two dedicatedpins are used for LED link and network activity indication.Fig 3: A pin diagram of the ENC28j60 IC is shown below : 10
  11. 11. The Ethernet controller may be a separate, standalone device, or it may be integrated with the hostmicrocontroller (MCU). The Ethernet controller transmits and receives data from the Ethernet cableand manages Ethernet protocol. Ethernet controllers are often separated into two pieces, the MediaAccess Control (MAC) and the Physical Layer (PHY).Media Access Control (MAC)The MAC provides addressing and channel access control mechanisms for several terminals ornetwork nodes to communicate within a multi-point network, typical a local area network (LAN). Aspart of the channel access control, it provides multiple access protocol that allows for an automaticretransmission when a collision occurs. It also emulates a full-duplex logical communication channelin a multi-point network. This channel may provide unicast, multicast or broadcast communicationservice.Physical Layer (PHY)The PHY provides the means of transmitting raw bits over a physical data link (i.e. twisted paircable). The PHY module interfaces to a signal transformer, which in turn connects to the RJ-45Ethernet socket. The host controller receives data from the Ethernet controller and applies thenecessary protocol rules. The host controller also formats outgoing data and places it into theEthernet controller transmit buffer.Fig 4: ENC28J60 Interface with MCU and RJ45 jackThe ENC28J60 is designed to operate at 25 MHz with a crystal connected to the OSC1 and OSC2 pins.The ENC28J60 design requires the use of a parallel cut crystal. Use of a series cut crystal may give afrequency out of the crystal manufacturer specifications. Thus the crystal, has to be 25.000 MHz, not24 not 26, 25 MHz no more or no less and as specified in the datasheet . This has to do with thetiming specifications of the IEEE 802.3 (Ethernet) standard, if the ENC28J60 oscillator is running at adifferent frequency, it will have a very hard time to communicate with other IEEE 802.3 compliantdevices. 11
  12. 12. RJ45 Ethernet MAGJACKMAGJACK is a RJ45 cable jack with an in built Ethernet transformer , Status LEDs and Sheilding Fig 5 : RJ45 MagjackThe Yellow and the Green LEDs in the figure above indicates the Reception and Transmission ofPackets respectively.LM35 temperature sensorThe LM35 series are precision integrated-circuit temperature sensors, whose output voltage islinearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage overlinear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a largeconstant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not requireany external calibration or trimming to provide typical accuracies of ±¼°C at room temperature and±¾°C over a full -55 to +150°C temperature range. Low cost is assured by trimming and calibration atthe wafer level. The LM35s low output impedance, linear output, and precise inherent calibrationmake interfacing to readout or control circuitry especially easy. It can be used with single powersupplies, or with plus and minus supplies. As it draws only 60 µA from its supply, it has very low self-heating, less than 0.1°C in still air. The LM35 is rated to operate over a -55° to +150°C temperaturerange Fig 6 : LM35 temperature sensor pin details 12
  13. 13. Power SupplyThe apparatus requires dual power supply of 5V and 3.3V for powering Microcontroller andENC28J60 respectively , The microcontroller is powered by a 5V voltage regulator LM7805 and aZener diode is used to regulate power provided to the ENC28J60.Motor Driver L293DL293D is a dual H-Bridge motor driver, So with one IC we can interface two DC motors which can becontrolled in both clockwise and counter clockwise direction. Thishelps in controlling actuators likepump , cooler etc and if you have motor with fix direction of motion the you can make use of all thefour I/Os to connect up to four DC motors. L293D has output current of 600mA and peak outputcurrent of 1.2A per channel. Moreover for protection of circuit from back EMF ouput diodes areincluded within the IC. The output supply (VCC2) has a wide range from 4.5V to 36V, which hasmade L293D a best choice for DC motor driver. Motor driver is used in the DAS to control actuatorslike pump,lever,cooler etc.A simple schematic for interfacing a DC motor using L293D is shown below. Fig 7: L293D connection with Microcontroller 13
  14. 14. Fig 8: The Microcontroller Board’s schemetic with serial port, motor driver and voltage regulator 14
  15. 15. Fig 9: Ethernet controller ENC28J60 and MAGJACK interface Schematic 15
  16. 16. Fig 10 (a): The Microcontroller module with sensor(potentiometer) , motor driver and power regulator Fig 10(b): the Ethernet module with ENC28J60 and MagJack 16
  17. 17. Software usedThe System requires two different set of different computer Programs one for generating a .hex filewhich is to be burned inside the microcontroller ROM And the second is a interactive program withGraphical User interface (GUI) running in PC /PDA. The program built for this project would only runon PC. The microcontroller on the board is programmed using the Arduino programminglanguage (based on Wiring) and the Arduino development environment (GUI program running in PC: Processing).ArduinoArduino is an open-source single-board AVR microcontroller programming software , descendant ofthe open-source Wiring platform, designed to make the process of using electronics inmultidisciplinary projects more accessible. The hardware consists of a simple open hardware designfor the Arduino board with an Atmel AVR processor and on-board input/output support. Thesoftware consists of a standard programming language compiler and the boot loader that runs onthe board. Arduino (or Wiring) programming instructions are much like that of C++ , it even supportsobject oriented programming and have several pre defined library functions including for interfacingwith Ethernet modulus like Wiznet and ENC28j60 , The arduino library for ENC28J60 used in thisproject was developed by Andy Lindsay and was downloaded from his blog.Arduino has a different view of the AVR microcontroller ATMEGA168 as shown Fig 11 : Pin’s function of AVR ATMEGA168 when used with Arduino softwareProcessingProcessing too is an open source programming language and integrated developmentenvironment (IDE) built for the electronic arts and visual design communities with the purpose ofteaching the basics of computer programming in a visual context, and to serve as the foundation forelectronic sketchbooks. The project was initiated in 2001 by Casey Reas and Benjamin Fry, bothformerly of the Aesthetics and Computation Group at the MIT Media Lab. One of the stated aims of 17
  18. 18. “Processing” is to act as a tool to get non-programmers started with programming, through theinstant gratification of visual feedback. The language builds on the Java programming language, butuses a simplified syntax and supports rich graphics. Other features of processing like its platformindependent and takes low memory space makes it an ideal programming tool to built GUI forinterfacing with microcontroller (sending sensor value ) , PC and external server (where the sensorvalues are being recorded)A mobile version of “processing” is available called “Mobile Processing” allows software writtenusing the Processing language and environment to run on Java powered mobile devices. Which canbe used to build IDAS software for mobile devices also. The Processing serial library allows for easilyreading and writing data to and from external machines. It allows two computers to send andreceive data and gives the flexibility to communicate with custom microcontroller devices, usingthem as the input or output to Processing programs.FirmataFirmata is a generic protocol for communicating with microcontrollers from software on a hostcomputer. It is intended to work with any host computer software package. Right now there is amatching object in a number of languages. It is easy to add objects for other software to use thisprotocol. Basically, this firmware establishes a protocol for talking to the Arduino from the hostsoftware , Firmata can also be used with other microcontroller like PIC microcontroller series ofMicrochip . The aim is to allow people to completely control the Embedded device from softwarerunning on the host computer. The Firmata acts as a bridge between the AVR ATMEGA168microcontroller and the host software running on PC or PDA.Third Party Server SevicesWhen we are planning to build an embedded device which is able to collect a sensor data andupload the sensor values in to that remotely located server. And should also be able to display thereading back on demand by any internet enabled PC/PDA , in a legible and understandable format.So that the sensor reading could be browsed from any geographical location or else the sensorreading will only be available to the local clints in the LAN in which the IEED is connected. The twothird party Server used in this project are of Google and Pachube.Google : Google DocsGoogle Docs is a free, Web-based office suite, and data storage service offered by Google. It allowsusers to create and edit documents online while collaborating in real-time with other users. GoogleDocs originated from two separate products, Writely and Google Spreadsheets. Writely was a webbased word processor created by the software company Upstartle and launched in August2005. Spreadsheets, launched as Google Labs Spreadsheets on June 6, 2006, originated from theacquisition of the XL2Web product by 2Web Technologies. We would only be using the GoogleSpreadsheet in our project. Where the sensor readings from the Microcontroller to PC through 18
  19. 19. USART protocol would be uploaded to the Google Spreadsheet feature of the user or operator’sGoogle Account directly.PachubePachube is an on-line database service provider especially designed for allowing embedded systemdevelopers to connect sensor data (energy and environment data from objects, devices & buildings)to the Web[1] and to build their own applications on it.It was created in 2007 by architect Usman HaquePachube is a realtime data infrastructure platform for the , Internet of Things (A network ofInternet enabled embedded devices )managing millions of datapoints per day from thousands ofindividuals, organisations & companies around the world. Pachubes powerful and scalableinfrastructure enables you to build Internet of Things products and services, and store, share &discover realtime sensor, energy and environment data from objects, devices & buildings around theworld. Pachube enables things to "plug-in" to other things in real time so that, for example,buildings, weather stations, interactive environments, air quality monitors, networked energymonitors, virtual worlds and mobile sensor devices can all "talk" and "respond" to each other inrealtimePachubes scalable infrastructure helps you... Manage realtime sensor & environment data: Pachube is a data brokerage platform for the IEED, managing millions of datapoints per day from thousands of individuals, organisations & companies around the world. Convenient, secure & economical, Pachube stores, converts & serves data in multiple data formats, which makes it interoperable with both established web protocols & existing construction industry standards. All feeds include contextual metadata (timestamps, geolocation, units, tags) that actually make datastreams valuable. Graph, monitor & control remote environments: Embed realtime graphs & widgets in your own website. Analyse & process historical data pulled from any public Pachube feed. Send realtime alerts from any datastream to control scripts, devices & environments. Out-of-the-box configurable tools include a zoomable graph, a mapping/tracking widget, anaugmented reality viewer, SMS alerts & apps for various smartphones. As soon as something is plugged into Pachube, youre ready to monitor & control it. Fig 12: Pachube’s Infrastructure Architecture 19
  20. 20. Build mobile & web apps that create value: With a rapid development cycle & dozens of code examples & libraries, Pachubes simple yet sophisticatedphysical-to-virtual API makes it quick & easy to build applications that add value to networked objects & environments. Thats because real value-creation comes from the applications that are built on top of sensor systems. Pachube handles the scalability & high- availability required for complex data management, so as to develop applications that make decision-making more sophisticated.Methods of building an Internet Enabled EmbeddedSystemsThere are many method of building internet enabled embedded systems (IEED). Only threemethods of building an IEED has been demonstrated in this project :- Connect the Ethernet node (already communicating with a Microcontroller) to the Router through RJ45 cable, Assign an IP address to that Ethernet node. And then enter that IP address in the web browser of a PC connected in the same LAN in which the Ethernet node is connected. Use a Internet Enabled Desktop PC (running a “Processing” code) to communicate with a embedded device through USART protocol and uploading the sensor values to Google Spreadsheet Maintain a Full Duplex communication over the internet , between the third party server (Pachube) and the Embedded device connected to PC directly. To drive actuators like cooler and pump ; After sending the request to do so by the operator through the server. 20
  21. 21. Using the ENC28J60 Ethernet Controller Node connected to arouter to upload the sensor valueAs already mentioned the entire hardware is divided into two parts the microcontroller Sensorboard and the Ethernet node with the Ethernet router and MAGJACK. The Microcontroller and theEthernet node communicates through SPI protocol. And Ethernet node sends over those valuesreceived from microcontroller to the internet by using the Ethernet (IEEE 802.3). Fig 13: Mode 1: Ethernet controller and Router SetupMethodologyIn this method the Microcontroller works as a simple web server that responds to web requests witha page containing the current sensor readings. The program can be modified to change the format ofthe web page that is sent, but before getting into the details of the code there are a few limitationsof this method .Because this program is based on the etherShield library , it doesn’t implement a full TCP/IP stack.One of the major limitations is that the etherShield library doesn’t support packet fragmentation,which means the size of the response that can be sent is strictly limited. A full TCP/IPimplementation breaks up large messages into packets, each of which is transmitted independentlyacross the network and reassembled at the other end to reconstruct the complete message. Packetsare, as a major generalization, limited to between 64 and 1518 bytes in size including all the headers.Because the TCP/IP header and the checksum eat into that you actually end up with somewhat lessthan 1518 bytes as the upper size. Another and the biggest limitation of this method is The otherlimitation is that the etherShield library doesn’t have any provision for specifying a gateway ornetmask, so it has no concept of routing. You can’t configure a gateway address in your program andhave it initiate a TCP/IP connection to a host outside your network because it simply won’tunderstand where to send the packet. Note, however, that you can have it respond to requests fromoutside your network if your gateway does source-NAT (network address translation).Program’s structureIn the C program written in Arduino Programming tool for microcontroller ATMEGA168, First weneed to download the EtherSheild library from the developer’s website (The EtherSheild library is 21
  22. 22. not available by default in the Pre defined arduino library). After which we have to call the libraryfrom the program using the header file#include "etherShield.h"We then have to define a MAC address which has to be an unique in your network. Usually the MACaddress is hard programmed into the equipments firmware. However with the Arduinoprogramming tool we can define the MAC address ourselves. Likewise, the IP address needs to beunique on your network, and you need to enter it twice: once as the four elements in the myIp arrayand then as a string in baseurl. These values are different because the TCP/IP stack needs to use theactual local IP address in the headers, but the web page that is created also needs to display a formthat submits to itself, and the address used in your browser may be different to the actual IP addressif your device is behind a NAT (network address translation) device such as as firewall.#include "etherShield.h"// configuration. The MAC and IP address have to be unique on your LAN:static uint8_t myMac[6] = {0x54,0x55,0x58,0x10,0x00,0x24};static uint8_t myIp[4] = {192,168,1,15};static char baseurl[] = "";static uint16_t myPort = 80; // Listen to values coming from port 80 by defaultwhere unit8_t is an unsigned integer of length 8 bits and unit16_t is an unsigned integer of length 16bits. The myPort value can be changed if you want your device to listen on a port other than thedefault port 80. However, if you change it make sure you also change the baseurl variable to includethe port number or the form won’t work. For example, if you wanted to listen on port 81, you couldchange those lines to the following:static char baseurl[] = "";static uint16_t myPort = 81; // Listen port for tcp/www The program then creates two buffers used in creating the TCP/IP packet, and creates an instance of the EtherShieldobject called “es” as follows:// Set up variables for the TCP/IP buffer#define BUFFER_SIZE 500static uint8_t buf[BUFFER_SIZE+1];#define STR_BUFFER_SIZE 22static char strbuf[STR_BUFFER_SIZE+1]; // Create an instance of the EtherShield object named "es" //EtherShield es=EtherShield(); // Prepare the web page by writing the data to the TCP send bufferuint16_t print_webpage(uint8_t *buf);int8_t analyse_cmd(char *str);After which we define the pin to which the Sensor is connected which is pin 26 of the controller andwhich is pin 3 if viewed from Arduino environment. Thus we define -> #define SENSOR 3.The setup function does some setup of the Ethernet connection, and then sets the sensor data pinsto be inputs. SFR’s of ENC28J60 used for initialization the Ethernet connections arevoid setup(){/*initialize enc28j60*/ 22
  23. 23. es.ES_enc28j60Init(myMac); // Change clkout from 6.25MHz to 12.5MHzes.ES_enc28j60clkout(2);delay(10); // Magjack leds configuration // LEDA=green LEDB=yellow // 0x880 is PHLCON LEDB=on, LEDA=ones.ES_enc28j60PhyWrite(PHLCON, 0x880); // Values taken from the ENC28J60 datasheetdelay(500); // 0x990 is PHLCON LEDB=off, LEDA=offes.ES_enc28j60PhyWrite(PHLCON, 0x990);delay(500); // 0x880 is PHLCON LEDB=on, LEDA=ones.ES_enc28j60PhyWrite(PHLCON, 0x880);delay(500); // 0x990 is PHLCON LEDB=off, LEDA=offes.ES_enc28j60PhyWrite(PHLCON, 0x990);delay(500); // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmites.ES_enc28j60PhyWrite(PHLCON, 0x476);delay(100); //init the ethernet/ip layer:es.ES_init_ip_arp_udp_tcp(myMac, myIp, myPort); //init the ethernet/ip layer:// Set up the data pins from LM35 sensordigitalWrite(SENSOR, LOW);pinMode(SENSOR , INPUT);After which the ENC28j60 would monitor the RJ45 cable to check for valid packets , using theinstructionplen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);After which we need to check the “plen” contains a valid packet, by using the instructionsif(plen!=0) { // arp is broadcast if unknown but a host may also verify the mac address bysending it to a unicast address( the sending of messages to a single network destination identified by aunique address. )if (es.ES_eth_type_is_arp_and_my_ip (buf,plen)) {es.ES_make_arp_answer_from_request (buf);return;}After these instructions we need to check where the received wether the ip address are for us , Bycomparing the destination ip address in the packet with our ip address defined in the beginning ofthe program which is (es.ES_eth_type_is_ip_and_my_ip (buf,plen) == 0)andif (buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V)if both the ip address match either one of the above instructions would be a valid one .Hence the complete code to check if the ip address match :-// check if ip packets are for us:if (es.ES_eth_type_is_ip_and_my_ip (buf,plen) == 0) {return; 23
  24. 24. }if (buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){es.ES_make_echo_reply_from_request (buf,plen);return;}The main program loop is quite complex because it checks the Ethernet receive buffer each timethrough and manages the appropriate responses. // tcp port www start, compare only the lower byteif (buf[IP_PROTO_P] == IP_PROTO_TCP_V && buf[TCP_DST_PORT_H_P] == 0 &&buf[TCP_DST_PORT_L_P] == myPort) {if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V) {es.ES_make_tcp_synack_from_syn (buf); // make_tcp_synack_from_syn does alreadysend the syn,ackreturn;}if (buf[TCP_FLAGS_P] & TCP_FLAGS_ACK_V) {es.ES_init_len_info (buf); // init some data structuresdat_p = es.ES_get_tcp_data_pointer();if (dat_p==0) { // we can possibly have no data, just ack:if (buf[TCP_FLAGS_P] & TCP_FLAGS_FIN_V) {es.ES_make_tcp_ack_from_any (buf);} checks are both done using a call to analyse_cmd(), which processes the request header to findthe value of the cmd (content management database) variable passed through in the request. If thevalue is 1 it responds with the default page , if the cmd value is 2 it goes into the About page and likewise. This check is not strictly necessary because if you only want your program to return the pagewith the sensor data on it. This is one of the two most important functions in the program here we can analyse thevalue of cmd and point to the web page we want to display in the browser of the local client.if (cmd==1){ .... became if ((cmd==1)||(cmd==2)){ if (cmd==1) {Goto Webpage 1 //Run Function “uint16_t print_webpage (uint8_t *buf)”} else { Goto Webpage 2 // Run Function “uint16_t print_webpage_2(uint8_t *buf)” };}if (strncmp ("GET ", (char *) & (buf[dat_p]), 4) != 0) { // head, post for possible status codesplen = es.ES_fill_tcp_data_p (buf,0,PSTR ("HTTP/1.0 200 OKrnContent-Type:text/htmlrnrn<h1>200 OK</h1>"));goto SENDTCP;} 24
  25. 25. if (strncmp("/ ", (char *) & (buf[dat_p+4]), 2) == 0){plen = print_webpage (buf);goto SENDTCP;}cmd = analyse_cmd ((char *) & (buf[dat_p+5]));if (cmd == 1){plen = print_webpage (buf); // Send the "Data" page}if (cmd == 2){plen = print_webpage_2 (buf); // Send a different page (if Needed )}SENDTCP: es.ES_make_tcp_ack_from_any(buf); // send acknowledge for httpes.ES_make_tcp_ack_with_data(buf,plen); // send data}}}The next function is a subroutine program , used to find the memory address of the The returnedvalue which is stored in the global var strbufuint8_t find_key_val(char *str,char *key){ uint8_t found=0; uint8_t i=0; char *kp; kp=key; while(*str && *str!= && found==0){ if (*str == *kp){ kp++; if (*kp == 0){ str++; kp=key; if (*str == =){ found=1; } } }else{ kp=key; } str++; } if (found==1){ // copy the value to a buffer and terminate it with 0 while(*str && *str!= && *str!=& && i<STR_BUFFER_SIZE){ strbuf[i]=*str; i++; str++; } strbuf[i]=0; } return(found);}The analyse_cmd() function looks specifically for a request argument called “cmd,” and returns thevalue if it’s a number.int8_t analyse_cmd (char *str){int8_t r = -1; 25
  26. 26. if (find_key_val (str,"cmd")) {if (*strbuf < 0x3a && *strbuf > 0x2f) {// is a ASCII number, return itr = (*strbuf-0x30);}}return r;}The next function is the main function which is to be used by the arduino code to make a HTML webpage in the local clients browseruint16_t print_webpage (uint8_t *buf){// Arrays to hold the temperature reading from each sensorchar temp_sensor[10];float tempC;tempC=AnalogRead(sensor);tempC=(5.0 * tempC*100.0)/1024.0 // this equation converts the analog value from lm35 into the temperature reading// and store the value in variable TEMPCplen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>Arduino ENC28J60 Ethernet Shield : Made by SaptarshiNag : Mem no:193965</title></head><body>")); plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<center><h1> ENC28j60 Ethernet controller </h1>"));plen = es.ES_fill_tcp_data_p (buf, plen, PSTR ("Temprature value is"));for (i=0;i<10;i++) {buf[TCP_CHECKSUM_L_P+3+plen]=temp_sensor[i++];plen++; }return plen;}There is a need to convert your data to a string, and then use of instructionbuf[TCP_CHECKSUM_L_P+3+plen]=temp_sensor[i++];to add those characters on to the buffer.The main program to be burned in the microcontroller for interface with the Ethernet controllerconnected to a Router :-/* Web based Temperature monitoring system Created by Saptarshi – Dec 2011 */#include "etherShield.h" 26
  27. 27. #define SENSOR 0 // pin 28 of ATMEGA is pin 0 when programmed in Arduino//Programming Environmentstatic uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x24};static uint8_t myip[4] = {192,168,0,77};static char baseurl[] = "";static uint16_t mywwwport = 80; // listen port 80 by default for tcp/www(max range 1-254)#define BUFFER_SIZE 500static uint8_t buf[BUFFER_SIZE+1];#define STR_BUFFER_SIZE 22static char strbuf[STR_BUFFER_SIZE+1];EtherShield es=EtherShield();// prepare the webpage by writing the data to the tcp send bufferuint16_t print_webpage(uint8_t *buf, byte* on_off);int8_t analyse_cmd(char *str);void setup(){ /*initialize enc28j60*/ es.ES_enc28j60Init(mymac); es.ES_enc28j60clkout(2); // change clkout from 6.25MHz to 12.5MHz delay(10); /* Magjack leds configuration, from enc28j60 datasheet // LEDA=greed LEDB=yellow // 0x880 is PHLCON LEDB=on, LEDA=on // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00); es.ES_enc28j60PhyWrite(PHLCON,0x880); delay(500); // // 0x990 is PHLCON LEDB=off, LEDA=off // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00); es.ES_enc28j60PhyWrite(PHLCON,0x990); delay(500); // // 0x880 is PHLCON LEDB=on, LEDA=on // enc28j60PhyWrite(PHLCON,0b0000 1000 1000 00 00); es.ES_enc28j60PhyWrite(PHLCON,0x880); delay(500); // // 0x990 is PHLCON LEDB=off, LEDA=off // enc28j60PhyWrite(PHLCON,0b0000 1001 1001 00 00); es.ES_enc28j60PhyWrite(PHLCON,0x990); delay(500); // // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit // enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10); es.ES_enc28j60PhyWrite(PHLCON,0x476); delay(100); //init the ethernet/ip layer: es.ES_init_ip_arp_udp_tcp(mymac,myip,80); uint16_t plen, dat_p; int8_t cmd; char buft[64]; char dbg[64]; 27
  28. 28. plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf); /*plen will ne unequal to zero if there is a valid packet (without crcerror) */ if(plen!=0){ // arp is broadcast if unknown but a host may also verify the macaddress 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; } // check if ip packets are for us: if(es.ES_eth_type_is_ip_and_my_ip(buf,plen)==0){ return; } if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V &&buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){ es.ES_make_echo_reply_from_request(buf,plen); return; } // tcp port www start, compare only the lower byte if(buf[IP_PROTO_P]==IP_PROTO_TCP_V&&buf[TCP_DST_PORT_H_P]==0&&buf[TCP_DST_PORT_L_P]==mywwwport){ if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V){ es.ES_make_tcp_synack_from_syn(buf); // make_tcp_synack_from_syndoes already send the syn,ack return; } if (buf[TCP_FLAGS_P] & TCP_FLAGS_ACK_V){ es.ES_init_len_info(buf); // init some data structures dat_p=es.ES_get_tcp_data_pointer(); if (dat_p==0){ // we can possibly have no data, just ack: if (buf[TCP_FLAGS_P] & TCP_FLAGS_FIN_V){ es.ES_make_tcp_ack_from_any(buf); } return; } if (strncmp("GET ",(char *)&(buf[dat_p]),4)!=0){ // head, post and other methods for possible status codes plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200OKrnContent-Type: text/htmlrnrn<h1>200 OK</h1>")); goto SENDTCP; } if (strncmp("/ ",(char *)&(buf[dat_p+4]),2)==0){ plen=print_webpage(buf, on_off); goto SENDTCP; } cmd = analyse_cmd ((char *) & (buf[dat_p+5]));if (cmd == 1){plen = print_webpage (buf); // Send the "Data" page}if (cmd == 2){plen = print_webpage_2 (buf); // Send a different page (if Needed )}SEND TCP: es.ES_make_tcp_ack_from_any(buf); // send ack for httpes.ES_make_tcp_ack_with_data(buf,plen); // send data}} 28
  29. 29. // The returned value is stored in the global var strbufuint8_t find_key_val(char *str,char *key){ uint8_t found=0; uint8_t i=0; char *kp; kp=key; while(*str && *str!= && found==0){ if (*str == *kp){ kp++; if (*kp == 0){ str++; kp=key; if (*str == =){ found=1; } } }else{ kp=key; } str++; } if (found==1){ // copy the value to a buffer and terminate it with 0 while(*str && *str!= && *str!=& &&i<STR_BUFFER_SIZE){ strbuf[i]=*str; i++; str++; } strbuf[i]=0; } return(found);}int8_t analyse_cmd(char *str){ int8_t r=-1; if (find_key_val(str,"cmd")){ if (*strbuf < 0x3a && *strbuf > 0x2f){ // is a ASCII number, return it r=(*strbuf-0x30); } } return r;}uint16_t print_webpage (uint8_t *buf){// Arrays to hold the temperature reading from each sensorchar temp_sensor[10];float tempC;tempC=AnalogRead(sensor);tempC=(5.0 * tempC*100.0)/1024.0 // this equation converts the analog value from lm35 into the temperature reading// and store the value in variable TEMPC 29
  30. 30. plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>Arduino ENC28J60 Ethernet Shield : Made by SaptarshiNag : Mem no:193965</title></head><body>")); plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<center><h1> ENC28j60 Ethernet controller </h1>"));plen = es.ES_fill_tcp_data_p (buf, plen, PSTR ("Temprature value is"));for (i=0;i<10;i++) {buf[TCP_CHECKSUM_L_P+3+plen]=temp_sensor[i++];plen++; }return plen;}}The program above has been made to build a simple webserver to put up the sensor values up onthe internet. This is a Half Duplex communication.Mode 2 : using PC to save sensor data in GoogleSpreadsheetThis method only needs the microcontroller /Sensor module Connected to a PC with internetconnectivity through USART protocol , no need of the Ethernet controller. The microcontrollercontinuously sends the sensor data to the computer through the serial port. A software clientportion of this project runs on PC and is written in processing Processing is a computer language anddevelopment environment similar to Arduino and created for creating virtual effect program . Weuse Processing to build a computer program which would be running on the computer which wouldserialy accept the data being transmitted by the Microcontroller, Directly to the Google Server. The best thing is that you can then use any of the goodies that Google provides (charts, gadgets,maps, etc) directly with your data. While the Temperature sensor LM35 is pretty basic, you can usethis basic setup to record data from more sophisticated sensors, such as a Parallax GPS receivermodule into Google Spreadsheets. And use Google maps to point to the latitude/longitude you arelocated in. The sketch (Processing’s code) relies on the Google API Client Library for Java, which is a set of codelibraries for interacting with various Google’s services (not just Spreadsheets).MethodologyCreate a SpreadsheetThe first step in the project is to set up a Google Spreadsheet. To do this, we first need to sign in toour Google account . Sign in, and then go into documents to create a new spreadsheet named“sensor log.” Then, add the following columns in first row: “date,” “time,” and “reading, thesecolumn headers are used in the code to interact with the data in the spreadsheet. Then save thespreadsheet.Loading the Program on the host Computer 30
  31. 31. We first download the “Java client library” and “ Google Collection Library” nicknamed “Guava” tothe “Processing” library. After downloading the required libraries. We built the Processing codewhich reads the serial port for sensor values and upload the code to the spreadsheet service of theGoogle account assigned in the code .In the beginning we need to import the library whose functions( predefined ) we would be using inour programimport*;import*;import*;import*;The four instructions above imports from the Google API client library depending on the applicationwe are working on (Google Spreadsheet). The above four imported packages also have beenrecommended for spreadsheet related application in Google Developers Guide (v3.0). the lastimported package gdata.util is the most important among all the four gdata.util contains a wideassortments of classes and interfaces throughout the core Google Api client library .import processing.serial.*;This instruction is used for importing the Processing’s serial library. The Processing serial libraryallows for easily reading and writing data to and from external machines. In this case theATMEGA168 microcontroller.The next few instructions are used to uniquely identify your Google Account and the spreadsheet wewant to record our temperature sensor data.// Variables structures for google spreadsheet APISpreadsheetService service; //Holds link to all my spreadsheetsWorksheetEntry worksheet; //Holds link to the sensor log spreadsheetString uname = "[Saptarshi.nag99]";//My Google user nameString pwd = "[--- My Google Password ---]";String spreadsheet_name = "sensor log"; //Name of the spreadsheet we wantto want to write the sensor data spreadsheet_idx = 0; //Index for the "sensor log spreadsheetNext we define the variables we need for writing sensor data ...Serial port; // Create object from Serial classint oldTime; //timer variableint reportingInterval = 2000; //Number of miliiseconds between when sensor data is recorded ; This is the Sampling rate which may differ fordiffent sensorsAfter this declaration, our main program starts, We use the predefined library of the Google APIclent within the user defined function“ transmitData(<value to be written>)” which passes values tothe Google spreadsheet.void transmitData(float val) { 31
  32. 32. String date = day() + "/" + month() + "/" + year(); //Build the currentdate,from Google server String time = hour() + ":" + minute() + ":" + second(); //Build thecurrent time,from Google server try { //Create a new row with the name value pairs ListEntry newEntry = new ListEntry(); //Creates an object “newEntry” newEntry.getCustomElements().setValueLocal("date", date); newEntry.getCustomElements().setValueLocal("time", time);newEntry.getCustomElements().setValueLocal("reading",Float.toString(val)); //Write it out to the google doc URL listFeedUrl = worksheet.getListFeedUrl(); ListEntry insertedRow = service.insert(listFeedUrl, newEntry); } catch (Exception e) { println(e.getStackTrace()); }}In the above lines of code the instructions : newEntry.getCustomElements().setValueLocal("date", date); newEntry.getCustomElements().setValueLocal("time", time);newEntry.getCustomElements().setValueLocal("reading",Float.toString(val));Are the ones which actually upload values up on the Google Server. transmitdata() is where most ofthe work happens. It starts by creating a number of strings that hold the current date and the time,and then creates a new ListEntry, which is the primary data class used to interact with worksheets.The class method getCustomElements().setValueLocal() is used to map the Processing variables tothe column names in the worksheet.The codes have been enclosed between the try – catch block which is a Java programminginstruction for exceptional handling. An exception is an event, which occurs during the executionof a program, that disrupts the normal flow of the programs instructions. The catch block containscode that is executed if and when the exception handler is invoked.The next codes set up the processing to start receiving serial dataPrintln(Serial.list);String arduinoPort = Serial.list()[<the port number controller isconnected>]; port = new Serial(this, arduinoPort, 9600);The first instruction , list the number of available serial ports in your PC , In the second instructionwe assign the name of the port “arduinoPort” and in the third line of the instruction we define thebaudrate in this case by the rate of 9600 baud rate data would be transmitted/Received between PCand microcontrollerThe Main Processing Program:-import*; 32
  33. 33. import*;import*;import*;import processing.serial.*;// Variables structures for google spreadsheet APISpreadsheetService service; //Holds link to all your spreadsheetsWorksheetEntry worksheet; //Holds link to the sensor log spreadsheetString uname = "[Saptarshi.nag99]"; //Your google account user nameString pwd = "[--- My Google Password ---]";String spreadsheet_name = "sensor log";int spreadsheet_idx = 0; //Index for the "sensor log spreadsheet//Variables for writing sensor dataSerial port; // Create object from Serial classint oldTime; //timer variableint reportingInterval = 2000; //Number of miliiseconds between when sensordata is recorded// Sends the data to the spreadsheetvoid transmitData(float val) { String date = day() + "/" + month() + "/" + year(); //Build the currentdate String time = hour() + ":" + minute() + ":" + second(); //Build thecurrent time try { //Create a new row with the name value pairs ListEntry newEntry = new ListEntry(); newEntry.getCustomElements().setValueLocal("date", date); newEntry.getCustomElements().setValueLocal("time", time); newEntry.getCustomElements().setValueLocal("reading",Float.toString(val)); //Write it out to the google doc URL listFeedUrl = worksheet.getListFeedUrl();//URL of the resource is set ListEntry insertedRow = service.insert(listFeedUrl, newEntry); } catch (Exception e) { println(e.getStackTrace()); }}void setup() { //Set up the serial port to read data Println(Serial.list) String arduinoPort = Serial.list()[3]; port = new Serial(this, arduinoPort, 9600); oldTime = millis(); //Set up the google spreadsheet try { service.setUserCredentials(uname, pwd); // Search for the spreadsheet named were looking for // this code pulls a list of all the Spreadheets inthe acocunt andsearches for the // one with the matching name.URL feedURL = newURL(""); 33
  34. 34. SpreadsheetFeed feed = service.getFeed(feedURL,SpreadsheetFeed.class); for (SpreadsheetEntry entry: feed.getEntries()) { if (entry.getTitle().getPlainText().equals(spreadsheet_name) ) { break; } spreadsheet_idx += 1; } //Fetch the correct spreadsheet SpreadsheetEntry se = feed.getEntries().get(spreadsheet_idx); //Fetchthe spreadsheet we want worksheet = se.getWorksheets().get(0); //Fetch the first worksheetfrom that spreadsheet println("Found worksheet " + se.getTitle().getPlainText()); } catch (Exception e) { println(e.toString()); }}//Reads the port every few seconds and sends the data back to Googlevoid draw() { float val = 0; if (port.available() > 0) { // If data is available, val =; // read it and store it in val transmitData(val); // Send the val as argument in the function//transmitData(float)} }Mode 3:A Full Duplex communication over the internet , between thethird party server (Pachube) and an Embedded deviceconnected to PC directly.Pachube is an on-line database service provider allowing developers to connect sensor data (energyand environment data from objects, devices & buildings) to the Web and to build their ownapplications on it. This method uses a internet enabled PC connected through a serial port to theembedded device. The microcontroller sends the sensor values to the PC through the serial port . Aprocessing code is used in this method too to run on the host PC collect the data being send by themicrocontroller through serial port and this time uses Pachube services to host the sensor data in agraphical and legible order. Pachube also provides application of dial and push button to send datato the embedded device.MethodologyCreate an account in Pachube 34
  35. 35. First we need to make an account in by filling in a form and select a username andpassword. Then go to Homepage > My feeds and The browser will redirect you to another page,where you have to fill in an another form where you mention the:  Title of the Feed  Description of the Feed  Select Tags (optional)  Geographical Location name  Select your location in the Map or mention your latitude/longitude  Select the Domain your sensors are working at (Indoor or outdoor), (Fixed/Mobile)  Select the privacy settings (Public or Private)  Add a Datastream (variable whose values will be displayed and stored)Screenshot of the generated Pachube Datastream form page :Immediately after filling up the form , We request the Pachube service to generate an API keyfor the Datastream ( Which we would be using in our Processing program )After we set up the following configuration details in our Pachube account. Its time to startsending data . We connect the Microcontroller board with the host PC.In Processing we have to install New libraries of Pachuino Library (v 005), EEML library( Extended Environments Markup Language (EEML)) for link processing codes to Pachube. 35
  36. 36. After which we compile the processing code (given below), in the host PC :import processing.serial.*;import cc.arduino.*;import eeml.*;import pachuino.*;Pachuino p; // Create an object ‘p’void setup(){ p = new Pachuino(this, Arduino.list()[2],9600); // where 9600 is the baud rate//and [2] is the serial port were the microcontroller is connected p.setPort(5230);p.setKey("cI2AMoDhJj1RDuiTXi9kTsmLMegU90G8Gw8hZaXjlOvuMROxqHh9fezUT6sBR5sZWTjDe4KyKAQgYEybQrHMyKnBDL5HKdWYOPQ4yMmntWWhgdUFw0Nyhy2i9Q6fDfMH"); // MY API KEY ; Provided to me by // local sensors p.addLocalSensor("analog", 0,"Temperature");}void draw(){ float tempVal1 = p.localSensor[0].value; p.digitalWrite(15, 1); // Make the enable pin of l293D high} 36
  37. 37. void onReceiveRequest(DataOut d){ p.updateLocalSensors(d);}OutPut ScreenshotOn Entering the URL in a web browser (Google Chrome, in mycase) the present sensor reading along with other information like Geographical location and otherdetails will be displayed in a graphical and legible manner. 37
  38. 38. Other Pachube Plugins and appsBesides the online database management services provided by the Pachube , providesits user with wide range of graphical apps to its users, One of them is the use of graphical VirtualSwitch and Rotary Dial which could be used to controlling and manipulate actuators from a also provides option on how to display the data in other various graphical formats likedial clock , graphs with preferred color settings etc. 38
  39. 39. Conclusion  This is a prototype of an Internet Enabled Data Acquisition system , which demonstrates how to upload the sensor value to a remote server through internet.  It demonstrates the application of ENC28j60 Ethernet module developed by Microchip  It demonstrates how to use the service of third-party external server of Pachube to collect and categorise data in legible and graphical order  The complexity of the program increases with functionality , Protocols and Embedded systems are designed to minimise the complexity so that even a non technical operator can use the system with ease.  Internet based data acquisition system could be widely used in industries and home for monitoring sensor data remotely wirelessly without the need of expensive wireless receiver/transmission module.Reference 1. Pactical Arduino : A book on Arduino programming environment written by Jonathan Oxan 2. Getting Started with Processing : Book written by Casy Reans and Ben Fry on the Processing programming language 3. Documentary notes of ENC28J60 Ethernet controller module 4. Documentary notes on ATMEGA168 microcontroller 5. Official arduino programming website 6. 7. Mr Andy D linslay’s blog: 8. developers of ENC28J60 ethernet module’s ‘C’ library for Arduino 9. online magazine for electronics hobbyist Projects 10. to read the documentary of the Google API library for Java client. 39