SlideShare ist ein Scribd-Unternehmen logo
1 von 39
An Internet Based
Interactive Real –Time
Data Acquisition
System
A Data Acquisition Sytem with Internet
connectivity for better Connectivity and
Controllability on a Move
Index .........
1.Introduction.................................................................................. 1
   Embedded systems

  Data Acquisition System

  Internet Enabled Embedded Systems

 Internet Data Acquisition System

         Benefits

         Limitations


2. 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 L293D


3.Softwares Used ............................................................................................. 13
         Arduino

         Processing

4. External third-party server used .................................................................. 14
         Google :Google Docs

         Pachube

5. Methods of Building a Data Acquisition System............................................16

6. Using the ENC28J60 Ethernet Controller Node connected to a router to
upload the sensor value .................................................................... 17


                                                         2
Methodology

Program’s structure

7. using PC to save sensor data in Google Spreadsheet ............................... 26
          Methodology

         Program’s structure

8. A Full Duplex communication over the internet , between the third party
server (Pachube) and an Embedded device connected to PC directly............30

            Methodology

            Program’s structure

9. Conclusion .................................................................................................................................... 34

10. Reference ....................................................................................................................................34




                                                                           3
The Entire Setup of my the Internet Based Data Acquisition System




                                4
Introduction
Embedded Systems

Embedded systems is a computer system designed for specific control functions within a larger
system often with real time computing constraints .It is embedded as part of a complete device
often 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 wide
range of end-user needs but are quite expensive . Embedded systems control many devices in
common use today and are usually build dedicated to perform a specific task . Design engineers can
optimize 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 systems
are especially suited for use in transportation, fire safety, military, security, medical applications in
form of alarm system monitoring abnormal activity or Data acquisition system monitoring a patient’s
heart beat for further analysing of the patient’s health. Other consumer electronics like handheld
computer , Personal Digital Assistant (PDA) , GPS , Home automation system ,Temperature
monitoring system in homes etc

Data Acquisition system
 A typical Data acquisition system (DAS) consists of individual sensors with the necessary signal
conditioning , data conversion , data processing , multiplexing , data handling and associated
transmission , storage and display data. DAS is very useful in keeping track of data from sensors
recording values from the environment in real time .In order to optimise the characteristics of the
system in terms of handling capacity and cost .Analog data is generally acquired and converted ito
digital form for the purpose of processing , transmission , display and storage.

                   The data collected from the sensor may be transmitted over long distances from
the test center to the controlling authority , Some of the main objective of data acquisition system
are :

        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
Processing may consist of a large variety of operations , ranging from simple comparison to
complicated mathematical manipulations. It can be for such a purpose as collection of
information(averages,satistics) ,converting the data into useful forms (eg calculations of efficiency of
motor speed , torque and power input developed), using data for controlling a process ,performing
repeated calculation to separate signals buried in the noise , generating information for display ,and
various other purpose.

Data may be transmitted over long distances or short distance . Both wired or wireless transmission
is used for transmission of data from test centre to a nearby PC , display panel or CRO .In wireless
transmission the data is send from test centre to the display unit either through infrared , Bluetooth
or Zigbee protocol . Wireless transmission tends to be more flexible , but expensive and complex as
there is a need for connecting external transmission/receiver modules between the test centre and
display 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 manufacturing
sector in the next few years. To date, much of the research work pertaining to the Internet in
construction, 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 passive
remote monitoring to direct control or resetting. Intel terms this as the fourth phase in the evolution
of internet ; The first being connection to main frames (external server ; Primary example on what
this project is based on ) , The second being e- commerce and e-mail revolution , and the third being
social networking . With Embedded systems getting more advanced and so many devices waiting to
be connected to the internet
                  Generally used embedded systems like PDA, MP3 Players , Mobile phones have
already 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 for
performing balance checks, account transactions, payments, credit applications and other banking
transactions 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 can
have direct internet access using a WI-Fi connection , and directly upload images to popular photo
sharing websites like Flickr , Picasa or social networking websites like facebook .Televisions too are
also getting connected to internet . Some modern day television also have a Ethernet port to access
and 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 the
internet so that the consumer may set it to start cooling or heating the room moments before
leaving for home from their workplace .Other examples of general consumer electronics products
needed to be connected to the internet for either of the three reasons mentioned above are just too
many to be mentioned .

Internet Based Data Acquisition System
The Primary goal of building a Internet connected Data Acquisition system is to build a DAS which
would be able to acquire the necessary data from sensors , at correct speed and at a correct time
and upload and record the values up on an external server through internet . So that a system values
can be monitored from anywhere without the need of special equipments to receive and display
information in condensed , understandable and legible manner. A user may also be able to diagnose

                                                   6
the problem and could even set it right .The information can easily be accesed and controlled by PC
or 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 this
information is significantly curtailed by this need for proximity. However, developments in the
Internet protocol, TCP/IP, which is the universal communication standard, looks set to change all of
this. In order to allow communications to be directed, every physical location on the Internet (server
or client) requires an IP address. Softwares have been designed to run in PDA or PC that passes
messages 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 etc

Limitation: 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
An Internet Based Interactive Data Acquisition System for Real-time
Applications
The primary aim of building this project is to build an Microcontroller ATMega168 enabled
embedded 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 or
processed by a script on the server. And can be accesed on demand by internet enabled PC ,PDA and
mobile phones , A application would also be running in the PDA or PC which would be able to display
the 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 the
embedded device like LCD, Motor ,Pump etc.




              Fig 1: System Architecture of the Internet Based Data Acquisition system



The System consists of two nodes one is the microcontroller board which consists of microcontroller
ATmega168 , Temperature sensor LM35 , Potentiometer (for testing purpose) ,Motor Driver L293D
(for operating actuators like pump, fan) 3v3 volt regulator for powering the Ethernet module and
The second node is the Ethernet controller which consists of Ethernet Controller ENC28j60 from
Microchip and RJ45 Jack with Integrated magnetic and integrated LEDS (LEDA and LEDB : Depicting
Transmission 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), Shift
Clock(SCLK) , SDI (Din) and SDO (Dout) to maintain SPI communication between the two nodes.




                                                  8
Tools and Components
The 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 with
internal magnetic however were not typically available from ordinary hobbyist stores . But are
obtained 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 regulator



Microcontroller Atmega168




                        Fig 2 : Pin Diagram of Microcontroller ATMEGA168

Microcontroller ATMEGA 168 is a 8 bit 28 pin microcontroller from ATMEL corporation , Some of the
prime feature of this Microcontroller because of which this microcontroller has been selected for
this project are :-

     Memory Details
    1K bytes of internal SRAM
    512 bytes of EEPROM

                                                  9
 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 Oscillator

All these features are sufficient , for building the IDAS . Pheripheral features like 8 channel ADC can
be used for reading the sensor values , PWM channels are used for operating external peripherals
like 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 a
reference voltage (and then to take necessary operation) , SPI Serial interface : to communicate
with the ENC28j60 ethernet controller and Watch Dog Timer to reset itself in case of unexpected
error in absence of the operator, Small size and low cost gives an extra advantage.

ENC28J60 Ethernet Controller
ENC28J60 Ethernet controller from Microchip Corporation. The ENC28J60 is a stand-alone Ethernet
controller with an industry standard Serial Peripheral Interface (SPI). It is designed to serve as an
Ethernet network interface for any controller equipped with SPI. The ENC28J60 meets all of the IEEE
802.3 specifications.
It incorporates a number of packet filtering schemes to limit incoming packets. It also provides an
internal DMA module for fast data throughput. Communication with the host controller is
implemented via two interrupt pins and the SPI, with data rates of up to 10 Mb/s. Two dedicated
pins are used for LED link and network activity indication.


Fig 3: A pin diagram of the ENC28j60 IC is shown below :




                                                  10
The Ethernet controller may be a separate, standalone device, or it may be integrated with the host
microcontroller (MCU). The Ethernet controller transmits and receives data from the Ethernet cable
and manages Ethernet protocol. Ethernet controllers are often separated into two pieces, the Media
Access Control (MAC) and the Physical Layer (PHY).

Media Access Control (MAC)

The MAC provides addressing and channel access control mechanisms for several terminals or
network nodes to communicate within a multi-point network, typical a local area network (LAN). As
part of the channel access control, it provides multiple access protocol that allows for an automatic
retransmission when a collision occurs. It also emulates a full-duplex logical communication channel
in a multi-point network. This channel may provide unicast, multicast or broadcast communication
service.

Physical Layer (PHY)

The PHY provides the means of transmitting raw bits over a physical data link (i.e. twisted pair
cable). The PHY module interfaces to a signal transformer, which in turn connects to the RJ-45
Ethernet socket. The host controller receives data from the Ethernet controller and applies the
necessary protocol rules. The host controller also formats outgoing data and places it into the
Ethernet controller transmit buffer.




Fig 4: ENC28J60 Interface with MCU and RJ45 jack


The 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 a
frequency out of the crystal manufacturer specifications. Thus the crystal, has to be 25.000 MHz, not
24 not 26, 25 MHz no more or no less and as specified in the datasheet . This has to do with the
timing specifications of the IEEE 802.3 (Ethernet) standard, if the ENC28J60 oscillator is running at a
different frequency, it will have a very hard time to communicate with other IEEE 802.3 compliant
devices.




                                                  11
RJ45 Ethernet MAGJACK
MAGJACK is a RJ45 cable jack with an in built Ethernet transformer , Status LEDs and Sheilding




                                         Fig 5 : RJ45 Magjack

The Yellow and the Green LEDs in the figure above indicates the Reception and Transmission of
Packets respectively.

LM35 temperature sensor
The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is
linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over
linear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a large
constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require
any 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 at
the wafer level. The LM35's low output impedance, linear output, and precise inherent calibration
make interfacing to readout or control circuitry especially easy. It can be used with single power
supplies, 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 temperature
range




                             Fig 6 : LM35 temperature sensor pin details




                                                  12
Power Supply
The apparatus requires dual power supply of 5V and 3.3V for powering Microcontroller and
ENC28J60 respectively , The microcontroller is powered by a 5V voltage regulator LM7805 and a
Zener diode is used to regulate power provided to the ENC28J60.



Motor Driver L293D
L293D is a dual H-Bridge motor driver, So with one IC we can interface two DC motors which can be
controlled in both clockwise and counter clockwise direction. Thishelps in controlling actuators like
pump , cooler etc and if you have motor with fix direction of motion the you can make use of all the
four I/Os to connect up to four DC motors. L293D has output current of 600mA and peak output
current of 1.2A per channel. Moreover for protection of circuit from back EMF ouput diodes are
included within the IC. The output supply (VCC2) has a wide range from 4.5V to 36V, which has
made L293D a best choice for DC motor driver. Motor driver is used in the DAS to control actuators
like pump,lever,cooler etc.

A simple schematic for interfacing a DC motor using L293D is shown below.




                            Fig 7: L293D connection with Microcontroller

                                                 13
Fig 8: The Microcontroller Board’s schemetic with serial port, motor driver and voltage regulator




                                               14
Fig 9: Ethernet controller ENC28J60 and MAGJACK interface Schematic




                                              15
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
Software used
The System requires two different set of different computer Programs one for generating a .hex file
which is to be burned inside the microcontroller ROM And the second is a interactive program with
Graphical User interface (GUI) running in PC /PDA. The program built for this project would only run
on PC. The microcontroller on the board is programmed using the Arduino programming
language (based on Wiring) and the Arduino development environment (GUI program running in PC
: Processing).

Arduino
Arduino is an open-source single-board AVR microcontroller programming software , descendant of
the open-source Wiring platform, designed to make the process of using electronics in
multidisciplinary projects more accessible. The hardware consists of a simple open hardware design
for the Arduino board with an Atmel AVR processor and on-board input/output support. The
software consists of a standard programming language compiler and the boot loader that runs on
the board. Arduino (or Wiring) programming instructions are much like that of C++ , it even supports
object oriented programming and have several pre defined library functions including for interfacing
with Ethernet modulus like Wiznet and ENC28j60 , The arduino library for ENC28J60 used in this
project 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 software

Processing
Processing too is an open source programming language and integrated development
environment (IDE) built for the electronic arts and visual design communities with the purpose of
teaching the basics of computer programming in a visual context, and to serve as the foundation for
electronic sketchbooks. The project was initiated in 2001 by Casey Reas and Benjamin Fry, both
formerly of the Aesthetics and Computation Group at the MIT Media Lab. One of the stated aims of

                                                 17
“Processing” is to act as a tool to get non-programmers started with programming, through the
instant gratification of visual feedback. The language builds on the Java programming language, but
uses a simplified syntax and supports rich graphics. Other features of processing like its platform
independent and takes low memory space makes it an ideal programming tool to built GUI for
interfacing with microcontroller (sending sensor value ) , PC and external server (where the sensor
values are being recorded)

A mobile version of “processing” is available called “Mobile Processing” allows software written
using the Processing language and environment to run on Java powered mobile devices. Which can
be used to build IDAS software for mobile devices also. The Processing serial library allows for easily
reading and writing data to and from external machines. It allows two computers to send and
receive data and gives the flexibility to communicate with custom microcontroller devices, using
them as the input or output to Processing programs.

Firmata
Firmata is a generic protocol for communicating with microcontrollers from software on a host
computer. It is intended to work with any host computer software package. Right now there is a
matching object in a number of languages. It is easy to add objects for other software to use this
protocol. Basically, this firmware establishes a protocol for talking to the Arduino from the host
software , Firmata can also be used with other microcontroller like PIC microcontroller series of
Microchip . The aim is to allow people to completely control the Embedded device from software
running on the host computer. The Firmata acts as a bridge between the AVR ATMEGA168
microcontroller and the host software running on PC or PDA.




Third Party Server Sevices
When we are planning to build an embedded device which is able to collect a sensor data and
upload the sensor values in to that remotely located server. And should also be able to display the
reading 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 sensor
reading will only be available to the local clints in the LAN in which the IEED is connected. The two
third party Server used in this project are of Google and Pachube.

Google : Google Docs
Google Docs is a free, Web-based office suite, and data storage service offered by Google. It allows
users to create and edit documents online while collaborating in real-time with other users. Google
Docs originated from two separate products, Writely and Google Spreadsheets. Writely was a web
based word processor created by the software company Upstartle and launched in August
2005. Spreadsheets, launched as Google Labs Spreadsheets on June 6, 2006, originated from the
acquisition of the XL2Web product by 2Web Technologies. We would only be using the Google
Spreadsheet in our project. Where the sensor readings from the Microcontroller to PC through




                                                  18
USART protocol would be uploaded to the Google Spreadsheet feature of the user or operator’s
Google Account directly.



Pachube
Pachube is an on-line database service provider especially designed for allowing embedded system
developers 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 Haque

Pachube is a realtime data infrastructure platform for the , Internet of Things (A network of
Internet enabled embedded devices )managing millions of datapoints per day from thousands of
individuals, organisations & companies around the world. Pachube's powerful and scalable
infrastructure 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 the
world. 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 energy
monitors, virtual worlds and mobile sensor devices can all "talk" and "respond" to each other in
realtime

Pachube's 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, you're ready to monitor & control it.




                            Fig 12: Pachube’s Infrastructure Architecture

                                                  19
Build mobile & web apps that create value:
 With a rapid development cycle & dozens of code examples & libraries, Pachube's simple yet
 sophisticated'physical-to-virtual' API makes it quick & easy to build applications that add value to
 networked objects & environments. That's 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 Embedded
Systems
There are many method of building internet enabled embedded systems (IEED). Only three
methods 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
Using the ENC28J60 Ethernet Controller Node connected to a
router to upload the sensor value
As already mentioned the entire hardware is divided into two parts the microcontroller Sensor
board and the Ethernet node with the Ethernet router and MAGJACK. The Microcontroller and the
Ethernet node communicates through SPI protocol. And Ethernet node sends over those values
received from microcontroller to the internet by using the Ethernet (IEEE 802.3).




                       Fig 13: Mode 1: Ethernet controller and Router Setup

Methodology

In this method the Microcontroller works as a simple web server that responds to web requests with
a page containing the current sensor readings. The program can be modified to change the format of
the web page that is sent, but before getting into the details of the code there are a few limitations
of 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/IP
implementation breaks up large messages into packets, each of which is transmitted independently
across the network and reassembled at the other end to reconstruct the complete message. Packets
are, 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 less
than 1518 bytes as the upper size. Another and the biggest limitation of this method is The other
limitation is that the etherShield library doesn’t have any provision for specifying a gateway or
netmask, so it has no concept of routing. You can’t configure a gateway address in your program and
have it initiate a TCP/IP connection to a host outside your network because it simply won’t
understand where to send the packet. Note, however, that you can have it respond to requests from
outside your network if your gateway does source-NAT (network address translation).

Program’s structure
In the C program written in Arduino Programming tool for microcontroller ATMEGA168, First we
need to download the EtherSheild library from the developer’s website (The EtherSheild library is


                                                  21
not available by default in the Pre defined arduino library). After which we have to call the library
from 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 MAC
address is hard programmed into the equipments firmware. However with the Arduino
programming tool we can define the MAC address ourselves. Likewise, the IP address needs to be
unique on your network, and you need to enter it twice: once as the four elements in the myIp array
and then as a string in baseurl. These values are different because the TCP/IP stack needs to use the
actual local IP address in the headers, but the web page that is created also needs to display a form
that submits to itself, and the address used in your browser may be different to the actual IP address
if 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[] = "http://192.168.0.77/";
static uint16_t myPort = 80; // Listen to values coming from port 80 by default

where unit8_t is an unsigned integer of length 8 bits and unit16_t is an unsigned integer of length 16
bits. The myPort value can be changed if you want your device to listen on a port other than the
default port 80. However, if you change it make sure you also change the baseurl variable to include
the port number or the form won’t work. For example, if you wanted to listen on port 81, you could
change those lines to the following:

static char baseurl[] = "http://192.168.0.77:81/";
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 EtherShield
object called “es” as follows:

// Set up variables for the TCP/IP buffer
#define BUFFER_SIZE 500
static uint8_t buf[BUFFER_SIZE+1];
#define STR_BUFFER_SIZE 22
static 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 buffer
uint16_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 and
which 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 pins
to be inputs. SFR’s of ENC28J60 used for initialization the Ethernet connections are


void setup()
{
/*initialize enc28j60*/



                                                            22
es.ES_enc28j60Init(myMac);
      // Change clkout from 6.25MHz to 12.5MHz
es.ES_enc28j60clkout(2);
delay(10);
     // Magjack leds configuration
    // LEDA=green LEDB=yellow
   // 0x880 is PHLCON LEDB=on, LEDA=on
es.ES_enc28j60PhyWrite(PHLCON, 0x880); // Values taken from the ENC28J60 datasheet
delay(500);
  // 0x990 is PHLCON LEDB=off, LEDA=off
es.ES_enc28j60PhyWrite(PHLCON, 0x990);
delay(500);
         // 0x880 is PHLCON LEDB=on, LEDA=on
es.ES_enc28j60PhyWrite(PHLCON, 0x880);
delay(500);
         // 0x990 is PHLCON LEDB=off, LEDA=off
es.ES_enc28j60PhyWrite(PHLCON, 0x990);
delay(500);
        // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit
es.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 sensor
digitalWrite(SENSOR, LOW);
pinMode(SENSOR , INPUT);

After which the ENC28j60 would monitor the RJ45 cable to check for valid packets , using the
instruction

plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);

After which we need to check the “plen” contains a valid packet, by using the instructions

if(plen!=0) {
     // arp is broadcast if unknown but a host may also verify the mac address by
sending it to a unicast address( the sending of messages to a single network destination identified by a
unique 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 , By
comparing the destination ip address in the packet with our ip address defined in the beginning of
the program which is 198.168.0.77

if (es.ES_eth_type_is_ip_and_my_ip (buf,plen) == 0)

and

if (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
}
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 time
through and manages the appropriate responses.



  // 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] == myPort) {
if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V) {
es.ES_make_tcp_synack_from_syn (buf); // make_tcp_synack_from_syn does 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);
}

    checks are both done using a call to analyse_cmd(), which processes the request header to find
the value of the cmd (content management database) variable passed through in the request. If the
value is 1 it responds with the default page , if the cmd value is 2 it goes into the About page and like
wise. This check is not strictly necessary because if you only want your program to return the page
with the sensor data on it.
          This is one of the two most important functions in the program here we can analyse the
value 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 codes

plen = es.ES_fill_tcp_data_p (buf,0,PSTR ("HTTP/1.0 200 OKrnContent-Type:
text/htmlrnrn<h1>200 OK</h1>"));
goto SENDTCP;
}


                                                   24
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 http
es.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 returned
value which is stored in the global var strbuf


uint8_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 the
value if it’s a number.

int8_t analyse_cmd (char *str)
{
int8_t r = -1;


                                                25
if (find_key_val (str,"cmd")) {
if (*strbuf < 0x3a && *strbuf > 0x2f) {
// is a ASCII number, return it
r = (*strbuf-0x30);
}
}
return r;
}

The next function is the main function which is to be used by the arduino code to make a HTML web
page in the local clients browser

uint16_t print_webpage (uint8_t *buf)
{
// Arrays to hold the temperature reading from each sensor
char 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

plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>Arduino ENC28J60 Ethernet Shield : Made by Saptarshi
Nag : 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 instruction

buf[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 controller
connected to a Router :-

/*

 Web based Temperature monitoring system

 Created by Saptarshi – Dec 2011

 */

#include "etherShield.h"




                                                         26
#define SENSOR 0 // pin 28 of ATMEGA is pin 0 when programmed in Arduino
//Programming Environment

static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x24};
static uint8_t myip[4] = {192,168,0,77};
static char baseurl[] = "http://192.168.0.77/";
static uint16_t mywwwport = 80; // listen port 80 by default for tcp/www
(max range 1-254)

#define BUFFER_SIZE 500
static uint8_t buf[BUFFER_SIZE+1];
#define STR_BUFFER_SIZE 22
static char strbuf[STR_BUFFER_SIZE+1];

EtherShield es=EtherShield();


// prepare the webpage by writing the data to the tcp send buffer
uint16_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
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;
    }
    // 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_POR
T_L_P]==mywwwport){
       if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V){
           es.ES_make_tcp_synack_from_syn(buf); // make_tcp_synack_from_syn
does 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 200
OKrnContent-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 http
es.ES_make_tcp_ack_with_data(buf,plen); // send data
}
}


                                        28
// The returned value is stored in the global var strbuf
uint8_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 sensor
char 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
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>Arduino ENC28J60 Ethernet Shield : Made by Saptarshi
Nag : 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 on
the internet. This is a Half Duplex communication.

Mode 2 : using PC to save sensor data in Google
Spreadsheet
This method only needs the microcontroller /Sensor module Connected to a PC with internet
connectivity through USART protocol , no need of the Ethernet controller. The microcontroller
continuously sends the sensor data to the computer through the serial port. A software client
portion of this project runs on PC and is written in processing Processing is a computer language and
development environment similar to Arduino and created for creating virtual effect program . We
use Processing to build a computer program which would be running on the computer which would
serialy 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 use
this basic setup to record data from more sophisticated sensors, such as a Parallax GPS receiver
module into Google Spreadsheets. And use Google maps to point to the latitude/longitude you are
located in.

  The sketch (Processing’s code) relies on the Google API Client Library for Java, which is a set of code
libraries for interacting with various Google’s services (not just Spreadsheets).

Methodology

Create a Spreadsheet
The first step in the project is to set up a Google Spreadsheet. To do this, we first need to sign in to
our 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, these
column headers are used in the code to interact with the data in the spreadsheet. Then save the
spreadsheet.

Loading the Program on the host Computer


                                                         30
We first download the “Java client library” and “ Google Collection Library” nicknamed “Guava” to
the “Processing” library. After downloading the required libraries. We built the Processing code
which reads the serial port for sensor values and upload the code to the spreadsheet service of the
Google account assigned in the code .

In the beginning we need to import the library whose functions( predefined ) we would be using in
our program

import   com.google.gdata.client.spreadsheet.*;
import   com.google.gdata.data.*;
import   com.google.gdata.data.spreadsheet.*;
import   com.google.gdata.util.*;


The four instructions above imports from the Google API client library depending on the application
we are working on (Google Spreadsheet). The above four imported packages also have been
recommended for spreadsheet related application in Google Developers Guide (v3.0). the last
imported package gdata.util is the most important among all the four gdata.util contains a wide
assortments 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 library
allows for easily reading and writing data to and from external machines. In this case the
ATMEGA168 microcontroller.

The next few instructions are used to uniquely identify your Google Account and the spreadsheet we
want to record our temperature sensor data.

// Variables structures for google spreadsheet API
SpreadsheetService service; //Holds link to all my spreadsheets
WorksheetEntry worksheet; //Holds link to the sensor log spreadsheet
String uname = "[Saptarshi.nag99]";//My Google user name
String pwd = "[--- My Google Password ---]";

String spreadsheet_name = "sensor log";                   //Name of the spreadsheet we want
to want to write the sensor data to.

int spreadsheet_idx = 0; //Index for the "sensor log spreadsheet

Next we define the variables we need for writing sensor data ...


Serial port;    // Create object from Serial class
int oldTime;    //timer variable
int reportingInterval = 2000; //Number of miliiseconds between when sensor
   data is recorded ; This is the Sampling rate which may differ for
diffent sensors

After this declaration, our main program starts, We use the predefined library of the Google API
clent within the user defined function“ transmitData(<value to be written>)” which passes values to
the Google spreadsheet.

void transmitData(float val) {


                                                   31
String date = day() + "/" + month() + "/" + year(); //Build the current
date,from Google server
  String time = hour() + ":" + minute() + ":" + second(); //Build the
current 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 of
the 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 to
the column names in the worksheet.

The codes have been enclosed between the try – catch block which is a Java programming
instruction for exceptional handling. An exception is an event, which occurs during the execution
of a program, that disrupts the normal flow of the program's instructions. The catch block contains
code that is executed if and when the exception handler is invoked.

The next codes set up the processing to start receiving serial data

Println(Serial.list);

String arduinoPort = Serial.list()[<the port number controller is
connected>];

  port = new Serial(this, arduinoPort, 9600);

The first instruction , list the number of available serial ports in your PC , In the second instruction
we assign the name of the port “arduinoPort” and in the third line of the instruction we define the
baudrate in this case by the rate of 9600 baud rate data would be transmitted/Received between PC
and microcontroller

The Main Processing Program:-

import com.google.gdata.client.spreadsheet.*;


                                                  32
import com.google.gdata.data.*;
import com.google.gdata.data.spreadsheet.*;
import com.google.gdata.util.*;

import processing.serial.*;

// Variables structures for google spreadsheet API
SpreadsheetService service; //Holds link to all your spreadsheets
WorksheetEntry worksheet; //Holds link to the sensor log spreadsheet
String uname = "[Saptarshi.nag99]"; //Your google account user name
String pwd = "[--- My Google Password ---]";
String spreadsheet_name = "sensor log";
int spreadsheet_idx = 0; //Index for the "sensor log spreadsheet


//Variables for writing sensor data
Serial port; // Create object from Serial class
int oldTime; //timer variable
int reportingInterval = 2000; //Number of miliiseconds between when sensor
data is recorded

// Sends the data to the spreadsheet
void transmitData(float val) {
  String date = day() + "/" + month() + "/" + year(); //Build the current
date
  String time = hour() + ":" + minute() + ":" + second(); //Build the
current 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 we're looking for

     // this code pulls a list of all the Spreadheets inthe acocunt and
searches for the
     // one with the matching name.
URL feedURL = new
URL("http://spreadsheets.google.com/feeds/spreadsheets/private/full/");

                                      33
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); //Fetch
the spreadsheet we want
     worksheet = se.getWorksheets().get(0); //Fetch the first worksheet
from 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 Google
void draw() {
  float val = 0;
  if (port.available() > 0) { // If data is available,
    val = port.read();        // 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 the
third party server (Pachube) and an Embedded device
connected to PC directly.
Pachube is an on-line database service provider allowing developers to connect sensor data (energy
and environment data from objects, devices & buildings) to the Web and to build their own
applications on it. This method uses a internet enabled PC connected through a serial port to the
embedded device. The microcontroller sends the sensor values to the PC through the serial port . A
processing code is used in this method too to run on the host PC collect the data being send by the
microcontroller through serial port and this time uses Pachube services to host the sensor data in a
graphical and legible order. Pachube also provides application of dial and push button to send data
to the embedded device.

Methodology
Create an account in Pachube




                                                 34
First we need to make an account in Pachube.com by filling in a form and select a username and
password. 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 key
for 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 start
sending 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
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("cI2AMoDhJj1RDuiTXi9kTsmLMegU90G8Gw8hZaXjlOvuMROxqHh9fezUT6sBR5sZWT
jDe4KyKAQgYEybQrHMyKnBDL5HKdWYOPQ4yMmntWWhgdUFw0Nyhy2i9Q6fDfMH");

    // MY API KEY ; Provided to me by Pachube.com

    // 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
void onReceiveRequest(DataOut d){

    p.updateLocalSensors(d);

}




OutPut Screenshot
On Entering the URL https://pachube.com/feeds/44513 in a web browser (Google Chrome, in my
case) the present sensor reading along with other information like Geographical location and other
details will be displayed in a graphical and legible manner.




                                                37
Other Pachube Plugins and apps
Besides the online database management services provided by the Pachube , Pachube.com provides
its user with wide range of graphical apps to its users, One of them is the use of graphical Virtual
Switch and Rotary Dial which could be used to controlling and manipulate actuators from a remote
location.




Pachube.com also provides option on how to display the data in other various graphical formats like
dial clock , graphs with preferred color settings etc.




                                                38
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. Micrchip.com: Documentary notes of ENC28J60 Ethernet controller module
   4. Atmel.com: Documentary notes on ATMEGA168 microcontroller
   5. Arduino.cc: Official arduino programming website
   6. Pachube.com
   7. Mr Andy D linslay’s blog: http://blog.thiseldo.co.uk
   8. Nuelectronics.com: developers of ENC28J60 ethernet module’s ‘C’ library for
       Arduino
   9. Makezine.com: online magazine for electronics hobbyist Projects
   10. Code.google.com: to read the documentary of the Google API library for Java client.




                                           39

Weitere ähnliche Inhalte

Was ist angesagt?

data-acquisition-system-ppt
data-acquisition-system-pptdata-acquisition-system-ppt
data-acquisition-system-pptRavi Anand
 
Data Acquisition System and Data loggers
Data Acquisition System and Data loggersData Acquisition System and Data loggers
Data Acquisition System and Data loggersSwara Dave
 
Lectute instrumentation and process control data acquisition
Lectute instrumentation and process control data acquisitionLectute instrumentation and process control data acquisition
Lectute instrumentation and process control data acquisitionrama52
 
Micro controller based DAQ
Micro controller based DAQMicro controller based DAQ
Micro controller based DAQMurugappa Group
 
Data Acquisition System & Data Logger
Data Acquisition System & Data LoggerData Acquisition System & Data Logger
Data Acquisition System & Data LoggerTrivedi Jay
 
Data acquisition & system control basic information
Data acquisition & system control basic information Data acquisition & system control basic information
Data acquisition & system control basic information patel andil
 
Data Acquisition System
Data Acquisition SystemData Acquisition System
Data Acquisition Systemrajparkash
 
MadgeTech Wireless Data Loggers
MadgeTech Wireless Data LoggersMadgeTech Wireless Data Loggers
MadgeTech Wireless Data LoggersMadgeTech Inc
 
Data acquisition system
Data acquisition systemData acquisition system
Data acquisition systemSANTOSH A M S
 
Power system automation
Power system automationPower system automation
Power system automationKiran Gham
 
supervisory control and data acquisition system
supervisory control and data acquisition systemsupervisory control and data acquisition system
supervisory control and data acquisition systemselvakumar R
 
Tikam ppt 8 sem
Tikam ppt 8 semTikam ppt 8 sem
Tikam ppt 8 semTIKAMVANOT
 
Power system automation
Power system automationPower system automation
Power system automationsatyam11
 
Dhiraj seminar # power system automation
Dhiraj seminar # power system automationDhiraj seminar # power system automation
Dhiraj seminar # power system automationvision2d16
 
Dhiraj power system automation
Dhiraj power system automationDhiraj power system automation
Dhiraj power system automationvision2d16
 
Power system automation introduction
Power system automation introductionPower system automation introduction
Power system automation introductionMohammed Naser
 

Was ist angesagt? (20)

data-acquisition-system-ppt
data-acquisition-system-pptdata-acquisition-system-ppt
data-acquisition-system-ppt
 
Data Acquisition System
Data Acquisition SystemData Acquisition System
Data Acquisition System
 
Data Acquisition System and Data loggers
Data Acquisition System and Data loggersData Acquisition System and Data loggers
Data Acquisition System and Data loggers
 
Lectute instrumentation and process control data acquisition
Lectute instrumentation and process control data acquisitionLectute instrumentation and process control data acquisition
Lectute instrumentation and process control data acquisition
 
Micro controller based DAQ
Micro controller based DAQMicro controller based DAQ
Micro controller based DAQ
 
Data Acquisition System & Data Logger
Data Acquisition System & Data LoggerData Acquisition System & Data Logger
Data Acquisition System & Data Logger
 
Data acquisition & system control basic information
Data acquisition & system control basic information Data acquisition & system control basic information
Data acquisition & system control basic information
 
Data Acquisition System
Data Acquisition SystemData Acquisition System
Data Acquisition System
 
MadgeTech Wireless Data Loggers
MadgeTech Wireless Data LoggersMadgeTech Wireless Data Loggers
MadgeTech Wireless Data Loggers
 
Data acquisition system
Data acquisition systemData acquisition system
Data acquisition system
 
Data loggers
Data loggersData loggers
Data loggers
 
Data logger
Data loggerData logger
Data logger
 
Power system automation
Power system automationPower system automation
Power system automation
 
supervisory control and data acquisition system
supervisory control and data acquisition systemsupervisory control and data acquisition system
supervisory control and data acquisition system
 
Tikam ppt 8 sem
Tikam ppt 8 semTikam ppt 8 sem
Tikam ppt 8 sem
 
Power system automation
Power system automationPower system automation
Power system automation
 
Samiullah final ppt sacda
Samiullah final ppt sacdaSamiullah final ppt sacda
Samiullah final ppt sacda
 
Dhiraj seminar # power system automation
Dhiraj seminar # power system automationDhiraj seminar # power system automation
Dhiraj seminar # power system automation
 
Dhiraj power system automation
Dhiraj power system automationDhiraj power system automation
Dhiraj power system automation
 
Power system automation introduction
Power system automation introductionPower system automation introduction
Power system automation introduction
 

Andere mochten auch

Real-Time Monitoring and Control System for Industry
Real-Time Monitoring and Control System for IndustryReal-Time Monitoring and Control System for Industry
Real-Time Monitoring and Control System for Industryijsrd.com
 
Wireless sensor network applications
Wireless sensor network applicationsWireless sensor network applications
Wireless sensor network applicationsDeepshika Reddy
 
SECURED WIRELESS COMMUNICATION FOR INDUSTRIAL AUTOMATION AND CONTROL BY USING...
SECURED WIRELESS COMMUNICATION FOR INDUSTRIAL AUTOMATION AND CONTROL BY USING...SECURED WIRELESS COMMUNICATION FOR INDUSTRIAL AUTOMATION AND CONTROL BY USING...
SECURED WIRELESS COMMUNICATION FOR INDUSTRIAL AUTOMATION AND CONTROL BY USING...JOLLUSUDARSHANREDDY
 
Gsm based industrial security system
Gsm based industrial security systemGsm based industrial security system
Gsm based industrial security systemRAJASHREE B
 
Arduino Interface with MySQL for Storing RFID Access Details
Arduino Interface with MySQL for Storing RFID Access DetailsArduino Interface with MySQL for Storing RFID Access Details
Arduino Interface with MySQL for Storing RFID Access DetailsSanjay Kumar
 
Linux Ethernet device driver
Linux Ethernet device driverLinux Ethernet device driver
Linux Ethernet device driver艾鍗科技
 
Development of a Low Cost, Reliable & Scalable Home Automation System.
Development of a Low Cost, Reliable & Scalable Home Automation System.Development of a Low Cost, Reliable & Scalable Home Automation System.
Development of a Low Cost, Reliable & Scalable Home Automation System.imtiyazEEE
 
Industrial automation using gsm (ppt)
Industrial automation using gsm (ppt)Industrial automation using gsm (ppt)
Industrial automation using gsm (ppt)Mahira Banu
 
Wireless sensor network report
Wireless sensor network reportWireless sensor network report
Wireless sensor network reportGanesh Khadsan
 
Ethernet and TCP optimizations
Ethernet and TCP optimizationsEthernet and TCP optimizations
Ethernet and TCP optimizationsJeff Squyres
 
Green house weather control system
Green house weather control systemGreen house weather control system
Green house weather control systemShiven Vashisht
 
Ppt for automatic plant irrigation system
Ppt for automatic plant irrigation systemPpt for automatic plant irrigation system
Ppt for automatic plant irrigation systemstk25
 
Embedded Web Server based Interactive data acquisition and Control System
Embedded Web Server based Interactive data acquisition and Control SystemEmbedded Web Server based Interactive data acquisition and Control System
Embedded Web Server based Interactive data acquisition and Control SystemIOSR Journals
 
Wireless sensor network applications environment monitoring
Wireless sensor network applications environment monitoringWireless sensor network applications environment monitoring
Wireless sensor network applications environment monitoringCliff Cooper, MS, CIH
 
Gsm based industrial security system
Gsm based industrial security system Gsm based industrial security system
Gsm based industrial security system RAJASHREE B
 
wireless sensor network my seminar ppt
wireless sensor network my seminar pptwireless sensor network my seminar ppt
wireless sensor network my seminar pptEisha Madhwal
 

Andere mochten auch (19)

Real-Time Monitoring and Control System for Industry
Real-Time Monitoring and Control System for IndustryReal-Time Monitoring and Control System for Industry
Real-Time Monitoring and Control System for Industry
 
Wireless sensor network applications
Wireless sensor network applicationsWireless sensor network applications
Wireless sensor network applications
 
SECURED WIRELESS COMMUNICATION FOR INDUSTRIAL AUTOMATION AND CONTROL BY USING...
SECURED WIRELESS COMMUNICATION FOR INDUSTRIAL AUTOMATION AND CONTROL BY USING...SECURED WIRELESS COMMUNICATION FOR INDUSTRIAL AUTOMATION AND CONTROL BY USING...
SECURED WIRELESS COMMUNICATION FOR INDUSTRIAL AUTOMATION AND CONTROL BY USING...
 
Gsm based industrial security system
Gsm based industrial security systemGsm based industrial security system
Gsm based industrial security system
 
Arduino Interface with MySQL for Storing RFID Access Details
Arduino Interface with MySQL for Storing RFID Access DetailsArduino Interface with MySQL for Storing RFID Access Details
Arduino Interface with MySQL for Storing RFID Access Details
 
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver
 
Linux Ethernet device driver
Linux Ethernet device driverLinux Ethernet device driver
Linux Ethernet device driver
 
Development of a Low Cost, Reliable & Scalable Home Automation System.
Development of a Low Cost, Reliable & Scalable Home Automation System.Development of a Low Cost, Reliable & Scalable Home Automation System.
Development of a Low Cost, Reliable & Scalable Home Automation System.
 
Industrial automation using gsm (ppt)
Industrial automation using gsm (ppt)Industrial automation using gsm (ppt)
Industrial automation using gsm (ppt)
 
Wireless sensor network report
Wireless sensor network reportWireless sensor network report
Wireless sensor network report
 
Ethernet and TCP optimizations
Ethernet and TCP optimizationsEthernet and TCP optimizations
Ethernet and TCP optimizations
 
Green house weather control system
Green house weather control systemGreen house weather control system
Green house weather control system
 
Automatic irrigation system ppt
Automatic irrigation system pptAutomatic irrigation system ppt
Automatic irrigation system ppt
 
Raspberry pi
Raspberry pi Raspberry pi
Raspberry pi
 
Ppt for automatic plant irrigation system
Ppt for automatic plant irrigation systemPpt for automatic plant irrigation system
Ppt for automatic plant irrigation system
 
Embedded Web Server based Interactive data acquisition and Control System
Embedded Web Server based Interactive data acquisition and Control SystemEmbedded Web Server based Interactive data acquisition and Control System
Embedded Web Server based Interactive data acquisition and Control System
 
Wireless sensor network applications environment monitoring
Wireless sensor network applications environment monitoringWireless sensor network applications environment monitoring
Wireless sensor network applications environment monitoring
 
Gsm based industrial security system
Gsm based industrial security system Gsm based industrial security system
Gsm based industrial security system
 
wireless sensor network my seminar ppt
wireless sensor network my seminar pptwireless sensor network my seminar ppt
wireless sensor network my seminar ppt
 

Ähnlich wie An Internet Based Interactive Data Acquisition System

Comparative analysis of traditional scada systems and io t implemented scada
Comparative analysis of traditional scada systems and io t implemented scadaComparative analysis of traditional scada systems and io t implemented scada
Comparative analysis of traditional scada systems and io t implemented scadaIJARIIT
 
It 443 lecture 1
It 443 lecture 1It 443 lecture 1
It 443 lecture 1elisha25
 
IoT Notes Syllabus .pdf
IoT Notes Syllabus .pdfIoT Notes Syllabus .pdf
IoT Notes Syllabus .pdfAnujashejwal
 
Arm Based Real Time Monitoring and Controlling of Industrial Parameters Using...
Arm Based Real Time Monitoring and Controlling of Industrial Parameters Using...Arm Based Real Time Monitoring and Controlling of Industrial Parameters Using...
Arm Based Real Time Monitoring and Controlling of Industrial Parameters Using...IJTET Journal
 
Embedded Web Server based Interactive data acquisition and Control System
Embedded Web Server based Interactive data acquisition and Control SystemEmbedded Web Server based Interactive data acquisition and Control System
Embedded Web Server based Interactive data acquisition and Control SystemIOSR Journals
 
Easily Accessibility Of Power Plant Data & Reporting.pptx
Easily Accessibility Of Power Plant Data & Reporting.pptxEasily Accessibility Of Power Plant Data & Reporting.pptx
Easily Accessibility Of Power Plant Data & Reporting.pptxNayanSinhParmar
 
EDGE SEMINAR.pptx
EDGE SEMINAR.pptxEDGE SEMINAR.pptx
EDGE SEMINAR.pptxSachuS16
 
Graduation Project Documentation.PDF
Graduation Project Documentation.PDFGraduation Project Documentation.PDF
Graduation Project Documentation.PDFMostafa Elhoushi
 
Internet of things - Introduction and Variations (Architecture)
Internet of things - Introduction and Variations (Architecture)Internet of things - Introduction and Variations (Architecture)
Internet of things - Introduction and Variations (Architecture)Mayank Vijh
 
Edge Computing.docx
Edge Computing.docxEdge Computing.docx
Edge Computing.docxSVITSEEERK
 
IoT ( M2M) - Big Data - Analytics: Emulation and Demonstration
IoT ( M2M) - Big Data - Analytics: Emulation and DemonstrationIoT ( M2M) - Big Data - Analytics: Emulation and Demonstration
IoT ( M2M) - Big Data - Analytics: Emulation and DemonstrationCHAKER ALLAOUI
 
Performance Evaluation Of A Wimax Testbed
Performance Evaluation Of A Wimax TestbedPerformance Evaluation Of A Wimax Testbed
Performance Evaluation Of A Wimax TestbedAlison Reed
 
UBIQUITOUS NETWORK TECHNICAL ROOM MONITORING SYSTEM MODEL USING WEB SERVICE
UBIQUITOUS NETWORK TECHNICAL ROOM MONITORING SYSTEM MODEL USING WEB SERVICE UBIQUITOUS NETWORK TECHNICAL ROOM MONITORING SYSTEM MODEL USING WEB SERVICE
UBIQUITOUS NETWORK TECHNICAL ROOM MONITORING SYSTEM MODEL USING WEB SERVICE cscpconf
 

Ähnlich wie An Internet Based Interactive Data Acquisition System (20)

Comparative analysis of traditional scada systems and io t implemented scada
Comparative analysis of traditional scada systems and io t implemented scadaComparative analysis of traditional scada systems and io t implemented scada
Comparative analysis of traditional scada systems and io t implemented scada
 
It 443 lecture 1
It 443 lecture 1It 443 lecture 1
It 443 lecture 1
 
IoT Notes Syllabus .pdf
IoT Notes Syllabus .pdfIoT Notes Syllabus .pdf
IoT Notes Syllabus .pdf
 
Arm Based Real Time Monitoring and Controlling of Industrial Parameters Using...
Arm Based Real Time Monitoring and Controlling of Industrial Parameters Using...Arm Based Real Time Monitoring and Controlling of Industrial Parameters Using...
Arm Based Real Time Monitoring and Controlling of Industrial Parameters Using...
 
Embedded Web Server based Interactive data acquisition and Control System
Embedded Web Server based Interactive data acquisition and Control SystemEmbedded Web Server based Interactive data acquisition and Control System
Embedded Web Server based Interactive data acquisition and Control System
 
Jq2416671672
Jq2416671672Jq2416671672
Jq2416671672
 
Src 147
Src 147Src 147
Src 147
 
Easily Accessibility Of Power Plant Data & Reporting.pptx
Easily Accessibility Of Power Plant Data & Reporting.pptxEasily Accessibility Of Power Plant Data & Reporting.pptx
Easily Accessibility Of Power Plant Data & Reporting.pptx
 
Lecture 4
Lecture  4Lecture  4
Lecture 4
 
EDGE SEMINAR.pptx
EDGE SEMINAR.pptxEDGE SEMINAR.pptx
EDGE SEMINAR.pptx
 
Ak4103212215
Ak4103212215Ak4103212215
Ak4103212215
 
Beagle board
Beagle boardBeagle board
Beagle board
 
Graduation Project Documentation.PDF
Graduation Project Documentation.PDFGraduation Project Documentation.PDF
Graduation Project Documentation.PDF
 
Internet of things - Introduction and Variations (Architecture)
Internet of things - Introduction and Variations (Architecture)Internet of things - Introduction and Variations (Architecture)
Internet of things - Introduction and Variations (Architecture)
 
Edge Computing.docx
Edge Computing.docxEdge Computing.docx
Edge Computing.docx
 
IoT ( M2M) - Big Data - Analytics: Emulation and Demonstration
IoT ( M2M) - Big Data - Analytics: Emulation and DemonstrationIoT ( M2M) - Big Data - Analytics: Emulation and Demonstration
IoT ( M2M) - Big Data - Analytics: Emulation and Demonstration
 
Report file on Embedded systems
Report file on Embedded systemsReport file on Embedded systems
Report file on Embedded systems
 
Performance Evaluation Of A Wimax Testbed
Performance Evaluation Of A Wimax TestbedPerformance Evaluation Of A Wimax Testbed
Performance Evaluation Of A Wimax Testbed
 
UBIQUITOUS NETWORK TECHNICAL ROOM MONITORING SYSTEM MODEL USING WEB SERVICE
UBIQUITOUS NETWORK TECHNICAL ROOM MONITORING SYSTEM MODEL USING WEB SERVICE UBIQUITOUS NETWORK TECHNICAL ROOM MONITORING SYSTEM MODEL USING WEB SERVICE
UBIQUITOUS NETWORK TECHNICAL ROOM MONITORING SYSTEM MODEL USING WEB SERVICE
 
COMPARATIVE STUDY BETWEEN VARIOUS PROTOCOLS USED IN INTERNET OF THING
COMPARATIVE STUDY BETWEEN VARIOUS  PROTOCOLS USED IN INTERNET OF THINGCOMPARATIVE STUDY BETWEEN VARIOUS  PROTOCOLS USED IN INTERNET OF THING
COMPARATIVE STUDY BETWEEN VARIOUS PROTOCOLS USED IN INTERNET OF THING
 

Kürzlich hochgeladen

DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...
DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...
DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...Rishabh Aryan
 
simpson-lee_house_dt20ajshsjsjsjsjj15.pdf
simpson-lee_house_dt20ajshsjsjsjsjj15.pdfsimpson-lee_house_dt20ajshsjsjsjsjj15.pdf
simpson-lee_house_dt20ajshsjsjsjsjj15.pdfLucyBonelli
 
Pearl Disrtrict urban analyusis study pptx
Pearl Disrtrict urban analyusis study pptxPearl Disrtrict urban analyusis study pptx
Pearl Disrtrict urban analyusis study pptxDanielTamiru4
 
10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designers10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designersPixeldarts
 
Piece by Piece Magazine
Piece by Piece Magazine                      Piece by Piece Magazine
Piece by Piece Magazine CharlottePulte
 
How to Empower the future of UX Design with Gen AI
How to Empower the future of UX Design with Gen AIHow to Empower the future of UX Design with Gen AI
How to Empower the future of UX Design with Gen AIyuj
 
AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - MorgenboosterAI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster1508 A/S
 
The spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenologyThe spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenologyChristopher Totten
 
10 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 202410 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 2024digital learning point
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Rndexperts
 
Map of St. Louis Parks
Map of St. Louis Parks                              Map of St. Louis Parks
Map of St. Louis Parks CharlottePulte
 
Interior Design for Office a cura di RMG Project Studio
Interior Design for Office a cura di RMG Project StudioInterior Design for Office a cura di RMG Project Studio
Interior Design for Office a cura di RMG Project StudioRMG Project Studio
 
group_15_empirya_p1projectIndustrial.pdf
group_15_empirya_p1projectIndustrial.pdfgroup_15_empirya_p1projectIndustrial.pdf
group_15_empirya_p1projectIndustrial.pdfneelspinoy
 
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书zdzoqco
 
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.pptMaking and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.pptJIT KUMAR GUPTA
 
guest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssssguest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssssNadaMohammed714321
 
cda.pptx critical discourse analysis ppt
cda.pptx critical discourse analysis pptcda.pptx critical discourse analysis ppt
cda.pptx critical discourse analysis pptMaryamAfzal41
 
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptxUnit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptxNitish292041
 
General Knowledge Quiz Game C++ CODE.pptx
General Knowledge Quiz Game C++ CODE.pptxGeneral Knowledge Quiz Game C++ CODE.pptx
General Knowledge Quiz Game C++ CODE.pptxmarckustrevion
 
Iconic Global Solution - web design, Digital Marketing services
Iconic Global Solution - web design, Digital Marketing servicesIconic Global Solution - web design, Digital Marketing services
Iconic Global Solution - web design, Digital Marketing servicesIconic global solution
 

Kürzlich hochgeladen (20)

DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...
DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...
DAKSHIN BIHAR GRAMIN BANK: REDEFINING THE DIGITAL BANKING EXPERIENCE WITH A U...
 
simpson-lee_house_dt20ajshsjsjsjsjj15.pdf
simpson-lee_house_dt20ajshsjsjsjsjj15.pdfsimpson-lee_house_dt20ajshsjsjsjsjj15.pdf
simpson-lee_house_dt20ajshsjsjsjsjj15.pdf
 
Pearl Disrtrict urban analyusis study pptx
Pearl Disrtrict urban analyusis study pptxPearl Disrtrict urban analyusis study pptx
Pearl Disrtrict urban analyusis study pptx
 
10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designers10 must-have Chrome extensions for designers
10 must-have Chrome extensions for designers
 
Piece by Piece Magazine
Piece by Piece Magazine                      Piece by Piece Magazine
Piece by Piece Magazine
 
How to Empower the future of UX Design with Gen AI
How to Empower the future of UX Design with Gen AIHow to Empower the future of UX Design with Gen AI
How to Empower the future of UX Design with Gen AI
 
AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - MorgenboosterAI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
AI and Design Vol. 2: Navigating the New Frontier - Morgenbooster
 
The spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenologyThe spirit of digital place - game worlds and architectural phenomenology
The spirit of digital place - game worlds and architectural phenomenology
 
10 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 202410 Best WordPress Plugins to make the website effective in 2024
10 Best WordPress Plugins to make the website effective in 2024
 
Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025Top 10 Modern Web Design Trends for 2025
Top 10 Modern Web Design Trends for 2025
 
Map of St. Louis Parks
Map of St. Louis Parks                              Map of St. Louis Parks
Map of St. Louis Parks
 
Interior Design for Office a cura di RMG Project Studio
Interior Design for Office a cura di RMG Project StudioInterior Design for Office a cura di RMG Project Studio
Interior Design for Office a cura di RMG Project Studio
 
group_15_empirya_p1projectIndustrial.pdf
group_15_empirya_p1projectIndustrial.pdfgroup_15_empirya_p1projectIndustrial.pdf
group_15_empirya_p1projectIndustrial.pdf
 
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
办理卡尔顿大学毕业证成绩单|购买加拿大文凭证书
 
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.pptMaking and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
Making and Unmaking of Chandigarh - A City of Two Plans2-4-24.ppt
 
guest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssssguest bathroom white and bluesssssssssss
guest bathroom white and bluesssssssssss
 
cda.pptx critical discourse analysis ppt
cda.pptx critical discourse analysis pptcda.pptx critical discourse analysis ppt
cda.pptx critical discourse analysis ppt
 
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptxUnit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
Unit1_Syllbwbnwnwneneneneneneentation_Sem2.pptx
 
General Knowledge Quiz Game C++ CODE.pptx
General Knowledge Quiz Game C++ CODE.pptxGeneral Knowledge Quiz Game C++ CODE.pptx
General Knowledge Quiz Game C++ CODE.pptx
 
Iconic Global Solution - web design, Digital Marketing services
Iconic Global Solution - web design, Digital Marketing servicesIconic Global Solution - web design, Digital Marketing services
Iconic Global Solution - web design, Digital Marketing services
 

An Internet Based Interactive Data Acquisition System

  • 1. An Internet Based Interactive Real –Time Data Acquisition System A Data Acquisition Sytem with Internet connectivity for better Connectivity and Controllability on a Move
  • 2. Index ......... 1.Introduction.................................................................................. 1 Embedded systems Data Acquisition System Internet Enabled Embedded Systems Internet Data Acquisition System Benefits Limitations 2. 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 L293D 3.Softwares Used ............................................................................................. 13 Arduino Processing 4. External third-party server used .................................................................. 14 Google :Google Docs Pachube 5. Methods of Building a Data Acquisition System............................................16 6. Using the ENC28J60 Ethernet Controller Node connected to a router to upload the sensor value .................................................................... 17 2
  • 3. Methodology Program’s structure 7. using PC to save sensor data in Google Spreadsheet ............................... 26 Methodology Program’s structure 8. A Full Duplex communication over the internet , between the third party server (Pachube) and an Embedded device connected to PC directly............30 Methodology Program’s structure 9. Conclusion .................................................................................................................................... 34 10. Reference ....................................................................................................................................34 3
  • 4. The Entire Setup of my the Internet Based Data Acquisition System 4
  • 5. Introduction Embedded Systems Embedded systems is a computer system designed for specific control functions within a larger system often with real time computing constraints .It is embedded as part of a complete device often 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 wide range of end-user needs but are quite expensive . Embedded systems control many devices in common use today and are usually build dedicated to perform a specific task . Design engineers can optimize 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 systems are especially suited for use in transportation, fire safety, military, security, medical applications in form of alarm system monitoring abnormal activity or Data acquisition system monitoring a patient’s heart beat for further analysing of the patient’s health. Other consumer electronics like handheld computer , Personal Digital Assistant (PDA) , GPS , Home automation system ,Temperature monitoring system in homes etc Data Acquisition system A typical Data acquisition system (DAS) consists of individual sensors with the necessary signal conditioning , data conversion , data processing , multiplexing , data handling and associated transmission , storage and display data. DAS is very useful in keeping track of data from sensors recording values from the environment in real time .In order to optimise the characteristics of the system in terms of handling capacity and cost .Analog data is generally acquired and converted ito digital form for the purpose of processing , transmission , display and storage. The data collected from the sensor may be transmitted over long distances from the test center to the controlling authority , Some of the main objective of data acquisition system are : 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. Processing may consist of a large variety of operations , ranging from simple comparison to complicated mathematical manipulations. It can be for such a purpose as collection of information(averages,satistics) ,converting the data into useful forms (eg calculations of efficiency of motor speed , torque and power input developed), using data for controlling a process ,performing repeated calculation to separate signals buried in the noise , generating information for display ,and various other purpose. Data may be transmitted over long distances or short distance . Both wired or wireless transmission is used for transmission of data from test centre to a nearby PC , display panel or CRO .In wireless transmission the data is send from test centre to the display unit either through infrared , Bluetooth or Zigbee protocol . Wireless transmission tends to be more flexible , but expensive and complex as there is a need for connecting external transmission/receiver modules between the test centre and display 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 manufacturing sector in the next few years. To date, much of the research work pertaining to the Internet in construction, 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 passive remote monitoring to direct control or resetting. Intel terms this as the fourth phase in the evolution of internet ; The first being connection to main frames (external server ; Primary example on what this project is based on ) , The second being e- commerce and e-mail revolution , and the third being social networking . With Embedded systems getting more advanced and so many devices waiting to be connected to the internet Generally used embedded systems like PDA, MP3 Players , Mobile phones have already 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 for performing balance checks, account transactions, payments, credit applications and other banking transactions 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 can have direct internet access using a WI-Fi connection , and directly upload images to popular photo sharing websites like Flickr , Picasa or social networking websites like facebook .Televisions too are also getting connected to internet . Some modern day television also have a Ethernet port to access and 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 the internet so that the consumer may set it to start cooling or heating the room moments before leaving for home from their workplace .Other examples of general consumer electronics products needed to be connected to the internet for either of the three reasons mentioned above are just too many to be mentioned . Internet Based Data Acquisition System The Primary goal of building a Internet connected Data Acquisition system is to build a DAS which would be able to acquire the necessary data from sensors , at correct speed and at a correct time and upload and record the values up on an external server through internet . So that a system values can be monitored from anywhere without the need of special equipments to receive and display information in condensed , understandable and legible manner. A user may also be able to diagnose 6
  • 7. the problem and could even set it right .The information can easily be accesed and controlled by PC or 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 this information is significantly curtailed by this need for proximity. However, developments in the Internet protocol, TCP/IP, which is the universal communication standard, looks set to change all of this. In order to allow communications to be directed, every physical location on the Internet (server or client) requires an IP address. Softwares have been designed to run in PDA or PC that passes messages 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 etc Limitation: 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. An Internet Based Interactive Data Acquisition System for Real-time Applications The primary aim of building this project is to build an Microcontroller ATMega168 enabled embedded 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 or processed by a script on the server. And can be accesed on demand by internet enabled PC ,PDA and mobile phones , A application would also be running in the PDA or PC which would be able to display the 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 the embedded device like LCD, Motor ,Pump etc. Fig 1: System Architecture of the Internet Based Data Acquisition system The System consists of two nodes one is the microcontroller board which consists of microcontroller ATmega168 , Temperature sensor LM35 , Potentiometer (for testing purpose) ,Motor Driver L293D (for operating actuators like pump, fan) 3v3 volt regulator for powering the Ethernet module and The second node is the Ethernet controller which consists of Ethernet Controller ENC28j60 from Microchip and RJ45 Jack with Integrated magnetic and integrated LEDS (LEDA and LEDB : Depicting Transmission 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), Shift Clock(SCLK) , SDI (Din) and SDO (Dout) to maintain SPI communication between the two nodes. 8
  • 9. Tools and Components The 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 with internal magnetic however were not typically available from ordinary hobbyist stores . But are obtained 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 regulator Microcontroller Atmega168 Fig 2 : Pin Diagram of Microcontroller ATMEGA168 Microcontroller ATMEGA 168 is a 8 bit 28 pin microcontroller from ATMEL corporation , Some of the prime feature of this Microcontroller because of which this microcontroller has been selected for this project are :- Memory Details  1K bytes of internal SRAM  512 bytes of EEPROM 9
  • 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 Oscillator All these features are sufficient , for building the IDAS . Pheripheral features like 8 channel ADC can be used for reading the sensor values , PWM channels are used for operating external peripherals like 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 a reference voltage (and then to take necessary operation) , SPI Serial interface : to communicate with the ENC28j60 ethernet controller and Watch Dog Timer to reset itself in case of unexpected error in absence of the operator, Small size and low cost gives an extra advantage. ENC28J60 Ethernet Controller ENC28J60 Ethernet controller from Microchip Corporation. The ENC28J60 is a stand-alone Ethernet controller with an industry standard Serial Peripheral Interface (SPI). It is designed to serve as an Ethernet network interface for any controller equipped with SPI. The ENC28J60 meets all of the IEEE 802.3 specifications. It incorporates a number of packet filtering schemes to limit incoming packets. It also provides an internal DMA module for fast data throughput. Communication with the host controller is implemented via two interrupt pins and the SPI, with data rates of up to 10 Mb/s. Two dedicated pins are used for LED link and network activity indication. Fig 3: A pin diagram of the ENC28j60 IC is shown below : 10
  • 11. The Ethernet controller may be a separate, standalone device, or it may be integrated with the host microcontroller (MCU). The Ethernet controller transmits and receives data from the Ethernet cable and manages Ethernet protocol. Ethernet controllers are often separated into two pieces, the Media Access Control (MAC) and the Physical Layer (PHY). Media Access Control (MAC) The MAC provides addressing and channel access control mechanisms for several terminals or network nodes to communicate within a multi-point network, typical a local area network (LAN). As part of the channel access control, it provides multiple access protocol that allows for an automatic retransmission when a collision occurs. It also emulates a full-duplex logical communication channel in a multi-point network. This channel may provide unicast, multicast or broadcast communication service. Physical Layer (PHY) The PHY provides the means of transmitting raw bits over a physical data link (i.e. twisted pair cable). The PHY module interfaces to a signal transformer, which in turn connects to the RJ-45 Ethernet socket. The host controller receives data from the Ethernet controller and applies the necessary protocol rules. The host controller also formats outgoing data and places it into the Ethernet controller transmit buffer. Fig 4: ENC28J60 Interface with MCU and RJ45 jack The 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 a frequency out of the crystal manufacturer specifications. Thus the crystal, has to be 25.000 MHz, not 24 not 26, 25 MHz no more or no less and as specified in the datasheet . This has to do with the timing specifications of the IEEE 802.3 (Ethernet) standard, if the ENC28J60 oscillator is running at a different frequency, it will have a very hard time to communicate with other IEEE 802.3 compliant devices. 11
  • 12. RJ45 Ethernet MAGJACK MAGJACK is a RJ45 cable jack with an in built Ethernet transformer , Status LEDs and Sheilding Fig 5 : RJ45 Magjack The Yellow and the Green LEDs in the figure above indicates the Reception and Transmission of Packets respectively. LM35 temperature sensor The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in ° Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any 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 at the wafer level. The LM35's low output impedance, linear output, and precise inherent calibration make interfacing to readout or control circuitry especially easy. It can be used with single power supplies, 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 temperature range Fig 6 : LM35 temperature sensor pin details 12
  • 13. Power Supply The apparatus requires dual power supply of 5V and 3.3V for powering Microcontroller and ENC28J60 respectively , The microcontroller is powered by a 5V voltage regulator LM7805 and a Zener diode is used to regulate power provided to the ENC28J60. Motor Driver L293D L293D is a dual H-Bridge motor driver, So with one IC we can interface two DC motors which can be controlled in both clockwise and counter clockwise direction. Thishelps in controlling actuators like pump , cooler etc and if you have motor with fix direction of motion the you can make use of all the four I/Os to connect up to four DC motors. L293D has output current of 600mA and peak output current of 1.2A per channel. Moreover for protection of circuit from back EMF ouput diodes are included within the IC. The output supply (VCC2) has a wide range from 4.5V to 36V, which has made L293D a best choice for DC motor driver. Motor driver is used in the DAS to control actuators like 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. Fig 8: The Microcontroller Board’s schemetic with serial port, motor driver and voltage regulator 14
  • 15. Fig 9: Ethernet controller ENC28J60 and MAGJACK interface Schematic 15
  • 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. Software used The System requires two different set of different computer Programs one for generating a .hex file which is to be burned inside the microcontroller ROM And the second is a interactive program with Graphical User interface (GUI) running in PC /PDA. The program built for this project would only run on PC. The microcontroller on the board is programmed using the Arduino programming language (based on Wiring) and the Arduino development environment (GUI program running in PC : Processing). Arduino Arduino is an open-source single-board AVR microcontroller programming software , descendant of the open-source Wiring platform, designed to make the process of using electronics in multidisciplinary projects more accessible. The hardware consists of a simple open hardware design for the Arduino board with an Atmel AVR processor and on-board input/output support. The software consists of a standard programming language compiler and the boot loader that runs on the board. Arduino (or Wiring) programming instructions are much like that of C++ , it even supports object oriented programming and have several pre defined library functions including for interfacing with Ethernet modulus like Wiznet and ENC28j60 , The arduino library for ENC28J60 used in this project 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 software Processing Processing too is an open source programming language and integrated development environment (IDE) built for the electronic arts and visual design communities with the purpose of teaching the basics of computer programming in a visual context, and to serve as the foundation for electronic sketchbooks. The project was initiated in 2001 by Casey Reas and Benjamin Fry, both formerly of the Aesthetics and Computation Group at the MIT Media Lab. One of the stated aims of 17
  • 18. “Processing” is to act as a tool to get non-programmers started with programming, through the instant gratification of visual feedback. The language builds on the Java programming language, but uses a simplified syntax and supports rich graphics. Other features of processing like its platform independent and takes low memory space makes it an ideal programming tool to built GUI for interfacing with microcontroller (sending sensor value ) , PC and external server (where the sensor values are being recorded) A mobile version of “processing” is available called “Mobile Processing” allows software written using the Processing language and environment to run on Java powered mobile devices. Which can be used to build IDAS software for mobile devices also. The Processing serial library allows for easily reading and writing data to and from external machines. It allows two computers to send and receive data and gives the flexibility to communicate with custom microcontroller devices, using them as the input or output to Processing programs. Firmata Firmata is a generic protocol for communicating with microcontrollers from software on a host computer. It is intended to work with any host computer software package. Right now there is a matching object in a number of languages. It is easy to add objects for other software to use this protocol. Basically, this firmware establishes a protocol for talking to the Arduino from the host software , Firmata can also be used with other microcontroller like PIC microcontroller series of Microchip . The aim is to allow people to completely control the Embedded device from software running on the host computer. The Firmata acts as a bridge between the AVR ATMEGA168 microcontroller and the host software running on PC or PDA. Third Party Server Sevices When we are planning to build an embedded device which is able to collect a sensor data and upload the sensor values in to that remotely located server. And should also be able to display the reading 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 sensor reading will only be available to the local clints in the LAN in which the IEED is connected. The two third party Server used in this project are of Google and Pachube. Google : Google Docs Google Docs is a free, Web-based office suite, and data storage service offered by Google. It allows users to create and edit documents online while collaborating in real-time with other users. Google Docs originated from two separate products, Writely and Google Spreadsheets. Writely was a web based word processor created by the software company Upstartle and launched in August 2005. Spreadsheets, launched as Google Labs Spreadsheets on June 6, 2006, originated from the acquisition of the XL2Web product by 2Web Technologies. We would only be using the Google Spreadsheet in our project. Where the sensor readings from the Microcontroller to PC through 18
  • 19. USART protocol would be uploaded to the Google Spreadsheet feature of the user or operator’s Google Account directly. Pachube Pachube is an on-line database service provider especially designed for allowing embedded system developers 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 Haque Pachube is a realtime data infrastructure platform for the , Internet of Things (A network of Internet enabled embedded devices )managing millions of datapoints per day from thousands of individuals, organisations & companies around the world. Pachube's powerful and scalable infrastructure 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 the world. 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 energy monitors, virtual worlds and mobile sensor devices can all "talk" and "respond" to each other in realtime Pachube's 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, you're ready to monitor & control it. Fig 12: Pachube’s Infrastructure Architecture 19
  • 20. Build mobile & web apps that create value: With a rapid development cycle & dozens of code examples & libraries, Pachube's simple yet sophisticated'physical-to-virtual' API makes it quick & easy to build applications that add value to networked objects & environments. That's 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 Embedded Systems There are many method of building internet enabled embedded systems (IEED). Only three methods 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. Using the ENC28J60 Ethernet Controller Node connected to a router to upload the sensor value As already mentioned the entire hardware is divided into two parts the microcontroller Sensor board and the Ethernet node with the Ethernet router and MAGJACK. The Microcontroller and the Ethernet node communicates through SPI protocol. And Ethernet node sends over those values received from microcontroller to the internet by using the Ethernet (IEEE 802.3). Fig 13: Mode 1: Ethernet controller and Router Setup Methodology In this method the Microcontroller works as a simple web server that responds to web requests with a page containing the current sensor readings. The program can be modified to change the format of the web page that is sent, but before getting into the details of the code there are a few limitations of 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/IP implementation breaks up large messages into packets, each of which is transmitted independently across the network and reassembled at the other end to reconstruct the complete message. Packets are, 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 less than 1518 bytes as the upper size. Another and the biggest limitation of this method is The other limitation is that the etherShield library doesn’t have any provision for specifying a gateway or netmask, so it has no concept of routing. You can’t configure a gateway address in your program and have it initiate a TCP/IP connection to a host outside your network because it simply won’t understand where to send the packet. Note, however, that you can have it respond to requests from outside your network if your gateway does source-NAT (network address translation). Program’s structure In the C program written in Arduino Programming tool for microcontroller ATMEGA168, First we need to download the EtherSheild library from the developer’s website (The EtherSheild library is 21
  • 22. not available by default in the Pre defined arduino library). After which we have to call the library from 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 MAC address is hard programmed into the equipments firmware. However with the Arduino programming tool we can define the MAC address ourselves. Likewise, the IP address needs to be unique on your network, and you need to enter it twice: once as the four elements in the myIp array and then as a string in baseurl. These values are different because the TCP/IP stack needs to use the actual local IP address in the headers, but the web page that is created also needs to display a form that submits to itself, and the address used in your browser may be different to the actual IP address if 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[] = "http://192.168.0.77/"; static uint16_t myPort = 80; // Listen to values coming from port 80 by default where unit8_t is an unsigned integer of length 8 bits and unit16_t is an unsigned integer of length 16 bits. The myPort value can be changed if you want your device to listen on a port other than the default port 80. However, if you change it make sure you also change the baseurl variable to include the port number or the form won’t work. For example, if you wanted to listen on port 81, you could change those lines to the following: static char baseurl[] = "http://192.168.0.77:81/"; 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 EtherShield object called “es” as follows: // Set up variables for the TCP/IP buffer #define BUFFER_SIZE 500 static uint8_t buf[BUFFER_SIZE+1]; #define STR_BUFFER_SIZE 22 static 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 buffer uint16_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 and which 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 pins to be inputs. SFR’s of ENC28J60 used for initialization the Ethernet connections are void setup() { /*initialize enc28j60*/ 22
  • 23. es.ES_enc28j60Init(myMac); // Change clkout from 6.25MHz to 12.5MHz es.ES_enc28j60clkout(2); delay(10); // Magjack leds configuration // LEDA=green LEDB=yellow // 0x880 is PHLCON LEDB=on, LEDA=on es.ES_enc28j60PhyWrite(PHLCON, 0x880); // Values taken from the ENC28J60 datasheet delay(500); // 0x990 is PHLCON LEDB=off, LEDA=off es.ES_enc28j60PhyWrite(PHLCON, 0x990); delay(500); // 0x880 is PHLCON LEDB=on, LEDA=on es.ES_enc28j60PhyWrite(PHLCON, 0x880); delay(500); // 0x990 is PHLCON LEDB=off, LEDA=off es.ES_enc28j60PhyWrite(PHLCON, 0x990); delay(500); // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit es.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 sensor digitalWrite(SENSOR, LOW); pinMode(SENSOR , INPUT); After which the ENC28j60 would monitor the RJ45 cable to check for valid packets , using the instruction plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf); After which we need to check the “plen” contains a valid packet, by using the instructions if(plen!=0) { // arp is broadcast if unknown but a host may also verify the mac address by sending it to a unicast address( the sending of messages to a single network destination identified by a unique 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 , By comparing the destination ip address in the packet with our ip address defined in the beginning of the program which is 198.168.0.77 if (es.ES_eth_type_is_ip_and_my_ip (buf,plen) == 0) and if (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. } 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 time through and manages the appropriate responses. // 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] == myPort) { if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V) { es.ES_make_tcp_synack_from_syn (buf); // make_tcp_synack_from_syn does 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); } checks are both done using a call to analyse_cmd(), which processes the request header to find the value of the cmd (content management database) variable passed through in the request. If the value is 1 it responds with the default page , if the cmd value is 2 it goes into the About page and like wise. This check is not strictly necessary because if you only want your program to return the page with the sensor data on it. This is one of the two most important functions in the program here we can analyse the value 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 codes plen = 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. 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 http es.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 returned value which is stored in the global var strbuf uint8_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 the value if it’s a number. int8_t analyse_cmd (char *str) { int8_t r = -1; 25
  • 26. if (find_key_val (str,"cmd")) { if (*strbuf < 0x3a && *strbuf > 0x2f) { // is a ASCII number, return it r = (*strbuf-0x30); } } return r; } The next function is the main function which is to be used by the arduino code to make a HTML web page in the local clients browser uint16_t print_webpage (uint8_t *buf) { // Arrays to hold the temperature reading from each sensor char 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 plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>Arduino ENC28J60 Ethernet Shield : Made by Saptarshi Nag : 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 instruction buf[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 controller connected to a Router :- /* Web based Temperature monitoring system Created by Saptarshi – Dec 2011 */ #include "etherShield.h" 26
  • 27. #define SENSOR 0 // pin 28 of ATMEGA is pin 0 when programmed in Arduino //Programming Environment static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x24}; static uint8_t myip[4] = {192,168,0,77}; static char baseurl[] = "http://192.168.0.77/"; static uint16_t mywwwport = 80; // listen port 80 by default for tcp/www (max range 1-254) #define BUFFER_SIZE 500 static uint8_t buf[BUFFER_SIZE+1]; #define STR_BUFFER_SIZE 22 static char strbuf[STR_BUFFER_SIZE+1]; EtherShield es=EtherShield(); // prepare the webpage by writing the data to the tcp send buffer uint16_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. 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; } // 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_POR T_L_P]==mywwwport){ if (buf[TCP_FLAGS_P] & TCP_FLAGS_SYN_V){ es.ES_make_tcp_synack_from_syn(buf); // make_tcp_synack_from_syn does 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 200 OKrnContent-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 http es.ES_make_tcp_ack_with_data(buf,plen); // send data } } 28
  • 29. // The returned value is stored in the global var strbuf uint8_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 sensor char 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. plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><head><title>Arduino ENC28J60 Ethernet Shield : Made by Saptarshi Nag : 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 on the internet. This is a Half Duplex communication. Mode 2 : using PC to save sensor data in Google Spreadsheet This method only needs the microcontroller /Sensor module Connected to a PC with internet connectivity through USART protocol , no need of the Ethernet controller. The microcontroller continuously sends the sensor data to the computer through the serial port. A software client portion of this project runs on PC and is written in processing Processing is a computer language and development environment similar to Arduino and created for creating virtual effect program . We use Processing to build a computer program which would be running on the computer which would serialy 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 use this basic setup to record data from more sophisticated sensors, such as a Parallax GPS receiver module into Google Spreadsheets. And use Google maps to point to the latitude/longitude you are located in. The sketch (Processing’s code) relies on the Google API Client Library for Java, which is a set of code libraries for interacting with various Google’s services (not just Spreadsheets). Methodology Create a Spreadsheet The first step in the project is to set up a Google Spreadsheet. To do this, we first need to sign in to our 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, these column headers are used in the code to interact with the data in the spreadsheet. Then save the spreadsheet. Loading the Program on the host Computer 30
  • 31. We first download the “Java client library” and “ Google Collection Library” nicknamed “Guava” to the “Processing” library. After downloading the required libraries. We built the Processing code which reads the serial port for sensor values and upload the code to the spreadsheet service of the Google account assigned in the code . In the beginning we need to import the library whose functions( predefined ) we would be using in our program import com.google.gdata.client.spreadsheet.*; import com.google.gdata.data.*; import com.google.gdata.data.spreadsheet.*; import com.google.gdata.util.*; The four instructions above imports from the Google API client library depending on the application we are working on (Google Spreadsheet). The above four imported packages also have been recommended for spreadsheet related application in Google Developers Guide (v3.0). the last imported package gdata.util is the most important among all the four gdata.util contains a wide assortments 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 library allows for easily reading and writing data to and from external machines. In this case the ATMEGA168 microcontroller. The next few instructions are used to uniquely identify your Google Account and the spreadsheet we want to record our temperature sensor data. // Variables structures for google spreadsheet API SpreadsheetService service; //Holds link to all my spreadsheets WorksheetEntry worksheet; //Holds link to the sensor log spreadsheet String uname = "[Saptarshi.nag99]";//My Google user name String pwd = "[--- My Google Password ---]"; String spreadsheet_name = "sensor log"; //Name of the spreadsheet we want to want to write the sensor data to. int spreadsheet_idx = 0; //Index for the "sensor log spreadsheet Next we define the variables we need for writing sensor data ... Serial port; // Create object from Serial class int oldTime; //timer variable int reportingInterval = 2000; //Number of miliiseconds between when sensor data is recorded ; This is the Sampling rate which may differ for diffent sensors After this declaration, our main program starts, We use the predefined library of the Google API clent within the user defined function“ transmitData(<value to be written>)” which passes values to the Google spreadsheet. void transmitData(float val) { 31
  • 32. String date = day() + "/" + month() + "/" + year(); //Build the current date,from Google server String time = hour() + ":" + minute() + ":" + second(); //Build the current 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 of the 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 to the column names in the worksheet. The codes have been enclosed between the try – catch block which is a Java programming instruction for exceptional handling. An exception is an event, which occurs during the execution of a program, that disrupts the normal flow of the program's instructions. The catch block contains code that is executed if and when the exception handler is invoked. The next codes set up the processing to start receiving serial data Println(Serial.list); String arduinoPort = Serial.list()[<the port number controller is connected>]; port = new Serial(this, arduinoPort, 9600); The first instruction , list the number of available serial ports in your PC , In the second instruction we assign the name of the port “arduinoPort” and in the third line of the instruction we define the baudrate in this case by the rate of 9600 baud rate data would be transmitted/Received between PC and microcontroller The Main Processing Program:- import com.google.gdata.client.spreadsheet.*; 32
  • 33. import com.google.gdata.data.*; import com.google.gdata.data.spreadsheet.*; import com.google.gdata.util.*; import processing.serial.*; // Variables structures for google spreadsheet API SpreadsheetService service; //Holds link to all your spreadsheets WorksheetEntry worksheet; //Holds link to the sensor log spreadsheet String uname = "[Saptarshi.nag99]"; //Your google account user name String pwd = "[--- My Google Password ---]"; String spreadsheet_name = "sensor log"; int spreadsheet_idx = 0; //Index for the "sensor log spreadsheet //Variables for writing sensor data Serial port; // Create object from Serial class int oldTime; //timer variable int reportingInterval = 2000; //Number of miliiseconds between when sensor data is recorded // Sends the data to the spreadsheet void transmitData(float val) { String date = day() + "/" + month() + "/" + year(); //Build the current date String time = hour() + ":" + minute() + ":" + second(); //Build the current 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 we're looking for // this code pulls a list of all the Spreadheets inthe acocunt and searches for the // one with the matching name. URL feedURL = new URL("http://spreadsheets.google.com/feeds/spreadsheets/private/full/"); 33
  • 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); //Fetch the spreadsheet we want worksheet = se.getWorksheets().get(0); //Fetch the first worksheet from 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 Google void draw() { float val = 0; if (port.available() > 0) { // If data is available, val = port.read(); // 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 the third party server (Pachube) and an Embedded device connected to PC directly. Pachube is an on-line database service provider allowing developers to connect sensor data (energy and environment data from objects, devices & buildings) to the Web and to build their own applications on it. This method uses a internet enabled PC connected through a serial port to the embedded device. The microcontroller sends the sensor values to the PC through the serial port . A processing code is used in this method too to run on the host PC collect the data being send by the microcontroller through serial port and this time uses Pachube services to host the sensor data in a graphical and legible order. Pachube also provides application of dial and push button to send data to the embedded device. Methodology Create an account in Pachube 34
  • 35. First we need to make an account in Pachube.com by filling in a form and select a username and password. 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 key for 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 start sending 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. 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("cI2AMoDhJj1RDuiTXi9kTsmLMegU90G8Gw8hZaXjlOvuMROxqHh9fezUT6sBR5sZWT jDe4KyKAQgYEybQrHMyKnBDL5HKdWYOPQ4yMmntWWhgdUFw0Nyhy2i9Q6fDfMH"); // MY API KEY ; Provided to me by Pachube.com // 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. void onReceiveRequest(DataOut d){ p.updateLocalSensors(d); } OutPut Screenshot On Entering the URL https://pachube.com/feeds/44513 in a web browser (Google Chrome, in my case) the present sensor reading along with other information like Geographical location and other details will be displayed in a graphical and legible manner. 37
  • 38. Other Pachube Plugins and apps Besides the online database management services provided by the Pachube , Pachube.com provides its user with wide range of graphical apps to its users, One of them is the use of graphical Virtual Switch and Rotary Dial which could be used to controlling and manipulate actuators from a remote location. Pachube.com also provides option on how to display the data in other various graphical formats like dial clock , graphs with preferred color settings etc. 38
  • 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. Micrchip.com: Documentary notes of ENC28J60 Ethernet controller module 4. Atmel.com: Documentary notes on ATMEGA168 microcontroller 5. Arduino.cc: Official arduino programming website 6. Pachube.com 7. Mr Andy D linslay’s blog: http://blog.thiseldo.co.uk 8. Nuelectronics.com: developers of ENC28J60 ethernet module’s ‘C’ library for Arduino 9. Makezine.com: online magazine for electronics hobbyist Projects 10. Code.google.com: to read the documentary of the Google API library for Java client. 39