You are on page 1of 60
= UNIT Iv | loT Communication and Open Platforms Syllabus Ws ee cation Models and APIs 10 Communication Protocols- Bluetooth - WiFi ZigBee - es = Open Platform (like Raspberry Pi) - Architecture - Programming - Interfacing - Accessing GPIO Pins - Sending and Receiving Si ne to the Cloud. ng and Receiving Signals Using GPIO Pins - Connecting Contents 61 [oT Communication Models and APIs 6.2 loT Communication Protocols 63 ZigBee 64 GPS 65 GSM Modules 66 Open Platform : Raspberry Pi Architecture 6.7 — Raspberry Pi Interfacing 6.8 — Raspberry Pi Programming 69 — Connecting to the Cloud 6.10 Two Marks Questions with Answers 1unication and Open Platforms Embedded Systems and /oT. eS ae [ESI 'oT Communication Models and APIs * oD devices connect and communicate through their technic ref Models. An effective communication model shows how the process works and helps one understand how communication can be done. . * The Internet of Things enables people and things (devices) 2 e Pa er wherever they are, using any network or service they like. IoT allows to connect multiple devices (things) to communicate with each other. * There are four basic types of IoT communication models as given = 2 ee i Request-Response Model, Publisher-Subscriber Model, Push-Pul elma Exclusive Pair Model. al communication Request / Response model : * In the Request / Response model, client requests information from the ate and waits till the response is served from the server. Fig. 6.11 shows Request / Response model. HTTP 200 OK (content) Fig. 6.1.1 Request / Response model * HTTP protocol is used by Request / Response model. For example, a browser client may request a web page from the server through a "Request" and the corresponding web page will be served by the server as a "Response’. * The client and the server can communicate one to one-or one to many with more requests. * This model is stateless communication model and each request-response pair is independent of others. Publish / Subscribe model ; Publishers : Publishers generate event data and publishes them. Subscribers : Subscribers submit their subscriptions and process the events received. Publish/Subscribe service : It's the mediator/broker that filters and routes events from publishers to interested subscribers. TECHNICAL PUBLICATIONS® - an up-thrst for knowledge Embedded Systems and loT 8-3 loT Communication and Open Ptatforms glo, Communication and Oper BESS Fig. 6.1.2 shows Publish / Subscribe model. Producer Fig. 6.1.2 Publish / Subscribe model The publishers and subscribers are autonomous, which means that they do not need to know the presence of each other. This model is highly suited for mobile applications, ubiquitous computing and distributed embedded systems, Failure of publishers or subscribers does not bring down the entire system. No strong guarantee on broker to deliver content to subscriber. After a publisher publishes the event, it assumes that all corresponding subscribers would receive it. + Potential bottleneck in brokers when subscribers and publishers overload them. Push - Pull model : * Data procedure push the data to queues and consumers pull the data from the queues. Fig. 6.1.3 shows push-pull model. Fig. 6.1.3 Push - pull model © Sometimes queue act as buffer in between producer and consumer. Producer does not need to be aware of the consumers. Exclusive Pair model : ee | © This communication model is full duplex, bi-directional communication model. It uses persistent connection between client and server. Fig, 6.14 shows exclusive pair model. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge Jor Communication and Open Platforms mrnunicetion D0 See aie Request for connection Response (ACK) Client Data +ACK Request for closing connection Response for closing connection Fig. 6.1.4 Exclusive Pair model * Client send request to server for opening the connection. This connection is open. till the client send request for closing the connection. loT Communication APIs 1. REST based communication API : * A large part of the interoperability, scale, and control for IoT can be achieved through API management. Standards-based design patterns for Web APIs, API management, and a RESTful architecture provide tremendous value in simplifying the task of interoperability across heterogeneous systems handling vast amounts of data. * Representational State Transfer (REST) APIs follow the request-response communication model. Applications conforming to the REST constraints can be called RESTful. RESTful systems typically communicate over HTTP with the same Methods (GET, POST, PUT, DELETE etc) that browsers use to retrieve web pages and to send data to Temote servers. 1. Client-Server : Requires that a service offer one or more operations and that services wait for clients to request these operations. 2. Stateless : Requires communication between service consumer (client) and service provider (server) to be stateless. 3. Cache : Requires responses to be clearly labeled as cacheable or non-cacheable. 4. Uniform interface : Requires all service providers and consumers within a REST-compliant architecture to share a single common interface for all operations. 5. Layered system : Requires the ability to add or remove intermediaries at runtime without disrupting the system. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge emveded Systems and lor = one loT Communication and Open Platforms 6. Code-on-Demay nd All 7 updated independeny 7 ei® Within clients (such as Web browsers) to be ily from server-side logic using executable code shipped from i service providers to consumers, + Each client request applications expect ea must contain all the describe this kind of between client and and server Tesponse is a message and REST-compliant a Message to be self-descriptive. That means each message information necessary to complete the task. Other ways to message are "stateless" or "context-free." Each message passed Server can have a body and metadata. + HTTP request methods and actions : 1. GET: Re : ee turn whatever information is identified by the Request-URI. messa; ‘ieee! to GET except that the server must not return a ge-body in the response, only the metadata. a OPTIONS + Return information about the communication options available on 'e request/response chain identified by the Request-URI. 4. PUT : Requests that the enclosed entity be stored under the supplied Request-URI. 5. POST : Requests that the origin server accept the entity enclosed in the request | as a new subordinate of the resource identified by the Request-URI. 6. DELETE : Requests that the origin server delete the resource identified by the Request-URI. * The first three are read-only operations, while the last three are write operations. 2. WebSocket based Communication API : * WebSocket support full-duplex, two-way communication between client and server. * WebSocket APIs reduce the network traffic and latency as there is no overhead for connection setup and termination requests for each message. © WebSocket uses a standard HTTP request-response sequence to establish a connection. When the connection is established, the WebSocket API provides a read and write interface for reading and writing data over the established connection in an asynchronous full duplex manner. « WebSocket also provides an interface for asynchronously closing the connection from either side. loT Communication Protocols © Communication protocols are used as a backbone of IoT systems. It enable network connectivity and coupling to applications. Communication protocols allow devices to exchange data over the network. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge ee ee Embedded Systems and loT 6-6 JoT Communication and Open Platforms * Communication protocol also performs error correction and detection, flow control, data encoding, addressing mechanism etc. * Sequence control, lost of packet, retransmission are the other functions of communication protocol. Bluetooth * Bluetooth is a wireless technology that enables a wireless device to communicate in the 2.4 GHz Industrial Scientific and Medical (ISM band). * The number of hardware manufacturers adapting the Bluetooth technology and providing Bluetooth modules is rapidly increasing. This has made the modules reasonably cheap and is driving the market to provide smaller highly integrated products. © This, on the other hand, benefits adaptive markets such as the sensor market. Hopefully, Bluetooth opens up possibilities of creating cheap, efficient, wireless sensor- and control networks. ‘* Bluetooth is a short range, low cost and Iow power wireless communication standard. Today, we can find Bluetooth chips. * Embedded in PCs, laptops, digital cameras, GPS de-vices, Smart Phones and a whole range of other electronic devices. « Bluetooth supports point-to-point and point-to-multipoint connections. * Bluetooth operates in the 2.4 GHz Industrial, Scientific and Medical (ISM) band at a maximum data rate of 720 kbps. It uses Frequency Hopping Spread Spectrum that divides the frequency band yielding 79 channels. The modulation used is a Gaussian-shaped binary Frequency Shift Keying (GESK) modulation scheme. * Fig. 6.2.1 shows use of Bluetooth in embedded system. Fig. 6.2.1 Use of Bluetooth In embedded system * Bluetooth uses TDD (Time. Division Duplex) to perform full-duplex communication. The master defines slots of time and allocates one slot per slave. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge embedded Systoms and lor ee loT Communication and Open Platforms ¢ Bluetooth. is organize 7 slaves and ee s ae sanuatetalave mode. The topology supports 1 master, time slots for all nodes, “S In parked mode, The master defines the clock and + A master can reque ; becomes the manera Le his role with a slave, at which point the slave phone starts the commas mastet becomes the slave, For example : A head wares ‘nication as a master, but it prefers to be the slave. e Pologies are possible in Bluetooth : Piconet and Scatternet Topology. + Bluetooth devices have 3 mode state : sniff mode, ES) wii s to save power energy in transmission inactive hold mode and parked mode. ee Beate Wireless Fidelity. It is a wireless technology that uses radio frequency 0 transmit data through the ai i i air. The standard for Wireless Local Area Networks (WLANs). It's actually IEEE 802.11, a family of standards. Wi-Fi is based on the 802.11 standard : 802.11a, 802.11b and 802.11g. + IEEE created standard, but Wi-Fi Alliance certifies products. The Wireless Ethernet Compatibility Alliance started the Wi-Fi-wireless fidelity—certification program to ensure that equipment claiming 802.11 compliance was genuinely interoperable. * WiFi systems are the half duplex shared media configurations, where all stations transmit and receive on the same radio channel. * Wi-Fi combines concepts found in CSMA/CA and MACAW, but also offers features to preserve energy. The developers of the 80211 specifications develop a collision avoidance mechanism called the Distributed Control Function (DCF). According to DCF, a Wifi station will transmit only when the channel is clear. All transmissions are acknowledged, so if a station does not receive an acknowledgement, it assumes a collision occurred and retries. ISM Band * ISM stands for Industrial, Scientific, and Medical. ISM bands are set aside for equipment that is related to industrial or scientific processes or is used by medical equipment. + Perhaps the most familiar ISM-band device is the microwave oven, which operates in the 2.4-GHz ISM band. « ‘The ISM bands are license-free, provided that devices are low-power. You don't need a license to set up and operate a wireless network. « WLAN architecture : Ad-Hoc mode : Peer-to-peer setup where clients can connect to each other directly. Generally not used for business networks. TECHNICAL PUBLICATIONS® - en up-thnust for knowledge Embedded Systems and loT 638. loT Communication and Open Platforms Mobile stations communicate to each other directly. It's set up for a special Purpose and for a short period of time. For example, the participants of a meeting in a conference room may create an ad hoc network at the beginning of the meeting and dissolve it when the meeting ends. Wi-Fi network services are as follows : 1. Distribution and integration 2. Association, re-association and disassociation 3. Authentication and deauthentication 4. Providing privacy Distribution : This service is used by mobile stations in an infrastructure network every time they send data. Once a frame has been accepted by an access point, it uses the distribution service to deliver the frame to its destination. Any communication that uses an access point travels through the distribution service, including communications between two mobile stations associated with the same access point. Integration : Is a service provided by the distribution system; it allows the connection of the distribution system to a non-IEEE 802.11 network. The integration function is specific to the distribution system used and therefore is not specified by 802.11, except in terms of the services it must offer. Association : Delivery of frames to mobile stations is made possible because mobile stations register, or associate, with access points. The distribution system can then use the registration information to determine which access point to use for any mobile station. Reassociations : When a mobile station. moves between basic service areas within a single extended service area, it must evaluate signal strength and perhaps switch the access point with which it is associated. Reassociations are initiated by mobile stations when signal conditions indicate that a different association would be beneficial; they are never initiated by the access point. After the reassociation is complete, the distribution system updates its location records to reflect the reachability of the mobile station through a different access point. Disassociation : To terminate an existing association, stations may use the disassociation service. When stations invoke the disassociation service, any mobility data stored in the distribution system is removed. Once disassociation is complete, it is as if the station is no longer attached to the network. Disassociation is a polite task to do during the station shutdown process. The MAC is, however, designed to accommodate stations that leave the network without formally disassociating. TECHNICAL PUBLICATIONS® - an up-thrust. for knowledge Embedded Systems and loT a 28 JoT Communication and Open Platforms 2 ee ae : Physical security is a major component of a sffces, Wireless epectaton: Wired network's equipment can be locked inside however anaes ‘orks cannot offer the same level of physical security, re must depend on additional authentication routines to ensure that users accessing the network are authorized to do so. Authentication is a necessary Prerequisite to association because only authenticated users are authorized to use the network, Deauthentication terminates an authenticated relationship. Because authentication is needed before network use is authorized, a side effect of deauthentication is termination of any current association. + Each 802.11a/b/g device can operate in one of four possible modes : 1, Master mode (also called AP or infrastructure mode) is used to create a service that looks like a traditional access point. 2. Managed mode is sometimes also referred to as client mode. Wireless cards in managed mode will join a network created by a master and will automatically change their channel to match it. 3. Ad-hoc mode creates a multipoint-to-multipoint network where there is no single master node or AP. In ad-hoc mode, each wireless card communicates directly with its neighbors. 4. Monitor mode is used by some tools to passively listen to all radio traffic on a given channel. When in monitor mode, wireless cards transmit no data. ZigBee * ZigBee is built on top of the IEEE 802.15.4 standard. ZigBee provides routing and multi-hop functions to the packet-based: radio protocol. ZigBee is a registered trademark of the ZigBee Alliance. 802.15.4™ is a trademark of the Institute of Electrical and Electronics Engineers (IEEE). 802.15.4 defines the physical and MAC layers, and ZigBee defines the network and application layers. * ZigBee is the primary protocol which builds on the 802.154 standard, adding a network layer capable of peer-to-peer multi-hop mesh networking, a security layer capable of handling complex security situations, and an application layer for interoperable application profiles. © The 802.154 specification was created and is maintained by IEEE. This specification defines the physical (PHY) and Media Access Control (MAC) layers of a personal area, low-power, wireless network. «ZigBee is a wireless standard for home ‘and commercial use developed by the ZigBee Alliance, established in 2002, It is based on an TEEE 802.15.4 standard, The latest version of the standard is known as ZigBee Pro and was published in 2007. TECHNICAL PUBLICATIONS® - an up-thnist for knowledge Embedded Systems and oT 6-10 loT Communication and Open Platforms Arinajor feature of the ZigBee protocol is its mesh network topology that is healing and auto-routing. Mesh networks do not depend on any single fon: if one link is broken, devices séarch through the mesh to find another "available route. This capability makes a ZigBee-based network very reliable and flexible. The protocol is administered by the ZigBee Alliance, an re non-profit association of approximately 400 members. The Alliance certifies products and promotes worldwide adoption of ZigBee as the wirelessly networked standard for sensing and control in consumer, commercial and industrial areas. * The ZigBee specifications enhance the IEEE 802.15.4 standard by adding network and security layers and an application framework. © ZigBee is an open, global, packet-based protocol designed to provide an easy-to-use architecture for secure, reliable, low power wireless networks. Flow or process control equipment can be place anywhere and still communicate with the rest of the system. It can also be moved, since the network doesn't care about the physical location of a sensor, pump or valve. ZigBee targets the application domain of low power, low duty cycle and low data rate requirement devices. Figure below shows the example of a ZigBee network. IEEE 802.15.4 supports star and peer-to-peer topologies. The ZigBee specification supports star and two kinds of peer-to-peer topologies, mesh and cluster tree: ZigBee-compliant devices are sometimes specified as supporting point-to-point and point-to-multipoint topologies. Features 1. Stochastic addressing : A device is assigned a random address and announced. Mechanism for address conflict resolution. Parents node don't need to maintain assigned address table. 2. Link management : Each node maintains quality of links to neighbors. Link quality is used as link cost in routing. 3. Frequency agility : Nodes experience interference report to channel manager, which then selects another channel. 4. Asymmetric link : Each node has different transmit power and sensitivity. Paths may be asymmetric. 5. Power management : Routers and co-ordinators use main power. End Devices use batteries. i TECHNICAL PUBLICATIONS® - an up-trust for knowledge Embedded Systems and loT fa ZigBee Architecture 614 [oT Communication and Open Platforms Fig. 63.1 shows position of ZigBee and IEEE 602.154. ‘Application Application layer ‘Customer application oe [Application profte 7 Neworklayer | TAC yarn] | IEEE 802.15.4 _ PAY layer Fig. 6.3.1 Zigbee stack « ZigBee specifies all the layers above MAC and PHY, including the NWK (network) layer, APS, ZDO and security layers. Its ZigBee that provides the mesh networking and multihop capabilities, enhances the reliability of data packet delivery and specifies application-to-application interoperability. * ZigBee does not use all of the 802.154 MAC/PHY specification; only a small subset. This allows stack vendors to offer smaller solutions by providing a limited MAC for their ZigBee stacks. + ZigBee is asynchronous. Any node may transmit at any time. Only the CSMA/CA, a MAC-level mechanism, prevents nodes from talking over each other. Application (APL) Layer : The top layer in the ZigBee protocol stack consists of | the Application Framework, ZigBee Device Object (ZDO) and Application Support | (APS) Sublayer. | | | «Application Framework : It provides a description of how to build a profile onto the ZigBee stack. It also specifies a range of standard data types for profiles, descriptors to assist in service discovery, frame formats for transporting data and a key value pair construct to rapidly develop simple attribute-based profiles. | * Software at an endpoint that controls the ZigBee device. A single ZigBee node supports up to 240 application objects. Each application object supports endpoints TECHNICAL PUBLICATIONS® - an up-thrust for knowledge [oT Communication and Open Pla -12 Embedded Systems and oT g “ee numbered between 1 and 240 (with endpoint 0 reserved for the ZigBee Device Object (ZDO). © ZigBee Cluster Library (ZCL) is a library of clusters that can is used by as application. This allows common clusters to be reused across a number of differen functional domains, for example the same lighting cust can Be used foray application that requires lighting controls, such as mation ang commercial building automation. * Each cluster has two "ends", client and server. Working of Zigbee 5: . ae ee uses digital radios to allow devices to oon with one another. A typical ZigBee network consists of several types of devices. A network coordinator is a device that sets up the network, is aware of all the nodes within its network, and manages both the information about each node as well as the information that is being transmitted/received within the network. * Every ZigBee network must contain a network coordinator. Other Full Function Devices (FFD's) may be found in the network, and these devices support all of the 802.15.4 functions. They can serve as network coordinators, network routers or as devices that interact with the physical world. Binding In the output In the input cluster list cluster list Fig, 6.3.2 The final device found in these networks is the Reduced Function Device (RED), which usually only serve as devices that interact with the physical world. EEE Logical Device Types * Fig. 6.3.3 shows Zigbee network. ZigBee Coordinators (ZCs) form networks. * The ZigBee stack resides on a ZigBee logical device. There are three logical device types : Coordinator, Router and End device. © Itis at the network layer that the differences in functionality among the devices are determined. It is expected that in a ZigBee network the coordinator and the routers will be mains-powered and that the end devices can be battery-powered. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge emvedded Systems and loT loT Communication and Open Platforms « In a ZigBee network there is one and only one coordinate per network. The number ey routers and/or end devices depends on the application requirements and the conditions of the physical site + Within networks that support sleeping end devices, the coordinator or one of the routers must be designated as | a Primary Discovery Cache Enddevice | Devi These cache devices Fig. 6.3.3 Zigbee network provide server services to upload and store discovery information, as well as respond to discovery requests, on behalf of the sleeping end devices. * Function of ZigBee coordinator : It forms a network. It establishes the 802.15.4 channel on which the network will operate. It establishes the extended and short PAN ID for the network. It decides on the stack profile to use (compile or run-time option). . Tt acts as the arbiter for End-Device-Bind (a commissioning option). It acts as a router for mesh routing. It acts as the top of the tree, if tree routing enabled. Function of ZigBee routers : 1. Finding and joining the " correct " network 2. Perpetuating broadcasts across the network 3. Participating in routing, including discovering and maintaining routes i 4. Allowing other devices to join the network (if permit-join enabled) 5. Storing packets on behalf of sleeping children * Functions of ZigBee end-devices : 1, Finding and joining the correct 1 D. 3 4. 5. tacts as the Trust Center for secure applications and networks. 6 Zz 8. " network TECHNICAL ‘PUBLICATIONS® - an up-thrust for knowledge een ieee 00 gos foT Communication and Open Paton, Embedded Systems and loT the 2. Polling their parents to see if any messages Were sent to them while they fs olling thei asleep. 3. Finding a new parent if the link 0 conservé to the old parent is lost (NWK rejoin) batteries when not in use by jh : t e 4, Sleeping most of the time application. ZigBee Network Formation 1. Forming a Network © The coordinator initiates network formation. . sr forming the netwo! coordinator can function as a router & cq After f twork, the coordiné iB ne accept requests from other devices wishing to join. : : * Depending on the stack and application profile used, the coordinator might also perform additional duties after network formation. 2. Joining a Network A device finds a network by scanning channels. * When a device finds a network with the correct stack profile that is open to joining, it can request to join that network. « A device sends its join request to one of the network's router nodes & the device receiving the request can then use the callback to accept the request or deny it. 3. Network Communication © All nodes that communicate on a network transmit and receive on the same channel, or frequency. * ZigBee uses a Personal Area Network Identifier (PAN ID) to identify a network this provides a way for two networks to exist on the same channel while stil maintaining separate traffic flow. Network Layer * The Zigbee networking layer is probably one of the most complex layers in the protocol stack. : * Network layer responsibilities : 1, Establishment of a new network, 2. New device configuration, addressing assignment, network synchronization 3. Frames security 4, Message routing, TECHNICAL PUBLICATIONS® - an up-tnrust for knowledge edded Systems and jor. + On the transmit Ze loT Communication and Open Platforms Application Sub lave i ate sends data down to the a layer via a data request: as the data request, the APS specif eee ee the destination address, wh, ae or not route discovery will allowed, and the radius, 2 APS layer NWK neighbor table NWK routing table il + The radius is the maximum hops that the frame will be allowed to travel. This is mostly used in broadcasts. Once inside the data MAC layer request, the network header is filled out and then the address is eo examined. At this point, it's probably best to make a distinction between network addressing and MAC addressing. There are two sets of addresses in each Zigbee frame : the 802.15.4 source/destination addresses and the Zigbee network source/destination addresses. « ZigBee uses two unique addresses per node : a long address (MAC address) and a short address (Network address). The long address, also called the IEEE or MAC address, is assigned by the manufacturer of a device using an 802.15.4 radio), and does not change for the life of the device, The long address uniquely identifies the widget from all other 802.15.4 widgets in the world. In fact, the 64 bits (8 bytes) of this address space are large enough to include 123, 853 devices for every square meter on earth. The IEEE address space, surprisingly enough, is controlled by IEEE. A block of them can be purchased by the manufacturer. Each IEEE address uniquely identifies this node from any other node in the world. The top three bytes (24 bits) are called the Organizational Unique Identifier (OUI), and the bottom five bytes (40 bits) are managed by the Original Equipment Manufacturer (OEM). Components : 1. Network Layer Data Entity (NLDE) : Makes NPDU from NSDU 2. Network Layer Management Entity (NLME) : Configure new device, neighbor discovery, route discovery, joining/leaving a network, ... TECHNICAL PUBLICATIONS® - an up-thrust for knowledge JoT Communication and Open Platfonms Embedded Systems and loT ese. se (NIB) : Capabilities (RFD/FFD), Security leve 3. Network Layer Information Ba tries for route discovery, neighbor i x re protocol version, route discovery time, ma’ table, * Fig 6.35 shows ZigBee network layer fr ame format. 00 Data 00 No discovery 01 Command 01 Ifno route, discover 10 or 11 Reserved 11 Force discovery Fig. 6.3.5 ZigBee network layer frame format Simple Tree Routing Protocol © The tree network addresses are assigned using a distributed addressing scheme, These addresses are unique within a particular network, As a result; a router can acquire the relationship of two nodes through their network addresses. © The ZC becomes the root of the tree. Every device except the ZC has a parent node, while a ZR may also has one or more child nodes. A ZED acts as a leaf in the tree topology. * Fig, 6.3.6 shows tree architecture. @ Zisbee coordinator eo ZigBee router © zo Depth 0 = Depth 4 ---~- Depth ~--- Depthn --~= Depth n#1 @ © © @ © 2 = veh Fig. 6.3.6 Tree architecture TECHNICAL PUBLICATIONS® ~ an up-thnust for knowledge 0 2 ::: _ _—<_<_—_—-S_ ti(iéslttétsS Systems and JoT rs 6-17 « Ina tree topology, and configure all a are coordinator deterstnes es le maxi + Whereas Cm is th ¢ maximum loT Communication and Open Platforms the role of oe coordinator is to establish the network | 8 the establishment phase, the ZigBee | um number of nodes, which are (Cm) and (Rm) number of routers a ee Number of children and ‘Rm’ is the maximum attribute called “depth whi "have as children. In addition, each node has an coordinator using only parentchil the minimum number of hops to reach the ld link. The ZigBee coordinator itself has a depth may « Tree routing, also ack : ‘owledged, is only available in Stack Profile 0x01. Tree is just as bandwidth-effici efficient as mesh, and more efficient in terms of memory. But it has a major drawback: If ji 7 If links by é ‘ recovery. So ZigBee uses mesh by ee parent and children break, it has no Advantages : No communication overhead. Disadvantages : a failure. ges : More transmission delay (not optimal path) and Single point of [EET ZigBee-AoDv (zaopv) + Another routing protocol in ZigBee is a route discovery protocol similar to Ad-hoc On-demand Distance Vector Routing. « AODV is a reactive protocol, ie., the network stays silent ‘until a connection is requested. If a’ node wants to communicate with another one, it broadcasts a request to its neighbors who re-route the message and safeguard the node from which they received the message. Ifa node receives a message and it has an entry corresponding to the destination in its routing table, it retums a RREP through the reverse-path to the requesting node. So, the source sends its data through this path to the destination with the minimum number of hops. In ZAODY, when a node desires to send data to another node without having the related routing information, it buffers the data and then initiates a route discovery process to find the optimal path for the destination. 1. Routing Table (RT) 2, Route Discovery Table (RDT) 3. Route Request Command Frame (RREQ) Command Frame (RREP) ses a path cost metric for route comparison during 4. Route Reply The ZigBee routing algorithm u: wry and maintenance. route discove TECHNICAL ‘PUBLICATIONS® - an up-thrust for knowledge Ce iad foT Communication and Open Plattonns Embedded Systems and loT 6-18 RREQ 1. st (RREQ) packet. ‘The source node broadcasts a route reques' i DT entry and rebr If a intermediate router receives an new RREQ it add R ny, ‘Oadcast az the RREQ. 3, If a intermediate router receives an old RREQ, it shall compare the Forward Cos in the RREQ to the one stored in the RDT entry. aes 4. If the Cost is less, the router shall update the RDT entry and rebroadcast the RREQ again. 5. Using Source Address and Route Request ID, the RREQ can be uniquely identified. RREP Te 2. 3. The destination node receives the RREQ, it responds by unicasting a route reply (RREP) packet to its neighbor from which it received the RREQ. The destination will choose the routing path with the lowest cost and then send a route reply. Finally, when the RREP reaches the originator, the route discovery process is finished. ZAODV can effectively reduce the transmission delay. However, the procedure of flooding RREQ wastes significant amount of bandwidth, memory and device energy, and might cause a "broadcast storm" problem. APS Layers Application Support Sublayer (APS) is responsible for : |. Binding tables 2. Message forwarding between bound devices 3. Group address definition and management 4. Address mapping from 64-bit extended addresses to 16-bit NWK addresses 5. Fragmentation and reassembly of packets 6. Reliable data transport TROHNICALPURL GATIONS” sans yess ce knowledge pedded Systems and loT 8-19 loT Communication and Open Platforms « APS layer is responsi ible f san device profiles. Tt also prayer tains @ data service to the application and ZigBee Provides Binding tion sBement service to maintain binding links + ZigBee's security seryi iB table itself, TVices jj Imclude methods for key establishment and transport, and the storage of the ‘ 4 CG net typically provided through ‘Application Profi es. « The APS layer allows fr am : Encryption can be applied tee to be based on link keys or the network key. and the Applietinarcd e different levels, the MAC layer, Network layer ail of these1ayes ee (APS) layer. A ZigBee frame will contain fields from data payloads 'psulated within one another, and each later can encrypt its The APS layer i ; ie te is also responsible for providing applications and the ZDO with ms Zi ent, key transport, and device management services. Fig. 63.7 ‘ows Zigbee frame with security on The APS level. Application of security suite adds auxiliary header and also an integrity code PS | HOR ‘Auniliary] Enerypted APS HOR | __ payload “All of the above APS frame is integrity-protected Fig. 6.3.7 Zigbee frame with security on the APS level ‘The APS sublayer {s key establishment services provide the mechanism by which a ZigBee device may derive a shared secret key, with another ZigBee device. Key establishment involves two entities, an initiator device and a responder device, and is prefaced by a trust-provisioning step. ZigBee Applications «There are numerous applications that are ideal for the redundant, self-configuring and self-healing capabilities of ZigBee wireless mesh networks. Key ones include : 1. Energy management ‘and efficiency : To provide greater information and \ contrel_ of energy usage, provide customers with better service and more choice, better manage resources, and help to reduce environmental impact 2, Home automation ; To provide more flexible management of lighting, heating and cooling, security, and home entertainment systems from anywhere in the | home. TECHNICAL ‘PUBLICATIONS® - an up-thrust for knowledge ew Embedded Systems and loT aed . JoT Communication and Open Platforms 3. Building automation : To integrate and centralize management of lighting, heating, cooling and security. : 4. Industrial automation : To extend existing manufa systems reliability. GPS The Global Positioning System (GPS) is a space-based radio-navigation system consisting of a constellation of satellites broadcasting navigation signals and a network of ground stations and satellite control stations used for monitoring and control. GPS system time is associated with Coordinated Universal Time or UTC as observed by the US Naval Observatory. The accuracy of GPS is based on the clear and fine visibility of the sky, ed any obstructions by means of tree branches or building density may lead to limited accuracy in the forest and urban areas. GPS satellites transmit signals to provide accurate PVT information to an unlimited number of users on the Earth. GPS satellites broadcast a signal that encodes position and time with a high accuracy derived from the satellite's atomic clock time standard. The GPS receivers use the time-of-arrival ranging to generate pseudorange to determine the user's position. Currently 31 GPS satellites orbit the Earth at an altitude of approximately 11,000 miles providing users with accurate information on position, velocity and time anywhere in the world and in all weather conditions. cturing and process control GPS includes three main segments : The space segment, control segment and user segment. Fig. 6.4.1 shows GPS system. (See Fig. 6.4.1 on next page) The GPS space segment includes over 30 satellites in orbit operated and maintained by the U.S. Space Force. These satellites broadcast radio signals to control and monitoring stations on Earth and directly to users requiring highly precise satellite positioning. The US. Space Force also oversees the GPS control segment. It includes master control and backup control stations, dedicated ground antennas and several monitor stations located worldwide. These stations work to ensure GPS satellites are healthy, orbiting in the correct locations and have accurate atomic clocks on board. These stations are integral to the overall health and accuracy of the GPS constellation. TECHNICAL PUBLICATIONS® - an up-thrust for ‘knowledge embedded Systems and loT y loT Communication and Open Platforms Space segment GNSS Satelites GNSS Broadcast signals GNSS Control channel A i, 4 Song ‘gg Se & BB Data uploading Master control Monitor S Manone ee Rs ac lions | User segment Control segment Fig. 6.4.1 GPS system © The user segment includes everyone relying upon GPS satellites for PNT measurements. From a mobile phone providing directions to autonomous vehicles requiring lane-level positioning accuracy; from a farmer tracking planting and harvesting routes year-over-year to a UAV mapping a rainforest, many applications use GPS for high precision positioning and accuracy around the world. [I cs Modules « GSM stands for Global System for Mobile communication. It is widely used for digital cellular radio. It is 2 second generation cellular standard developed to cater voice services and data delivery using digital modulation. + GSM support 200 full: duplex channels per cell. Each channel uses different uplink and downlink frequency: GSM handles channel’ access using “a combination of FDM, TDM and slotted ALOHA: GSM is an open source system and it allows access to code. i : 900, 1800, 1900 MHz. Frequen * GSM in three flavours (frequency bands) : 900, 1800, quency band Ea iE the orange flavour in Israel. Voice is digitized using full-rate coding. TECHNICAL PUBLICATIONS® - an up-thust for knowledge Embedded Systems and oT 6-22 Jo Communication and Open Platforms Embedded Systeme andioT is = OPE _—r * Maximum distance the GSM supports is 95 kilometers. “es a eee operate in the 900 MEiz or 1800 MEz bands while 3G Mua frequency band * The physical channel in GSM is the time: which goes through the physical channel channels. ; : channel (TCH), which is defined as 26 TDMA ‘© User data is carried on the traffic y u ° Vv frames. There are lots of control channels for signaling, base station to mobile, .slot. The logical channel is the information 1, Both user data and signaling are logical mobile to base station. ‘© Performance characteristics of GSM : a) Communication : Mobile, wireless di and data services. Total mobility : International access, different providers. ©) Worldwide connectivity : One number, the network handles localization. 4) High capacity : Better frequency efficiency, smaller cells, more customers per ital communication; support for voice b) chip-card enables use of access points of e) High transmission quality : High audio quality and uninterrupted phone calls at higher speeds. ) Security functions : Access control, authentication via chip-card and PIN * Fig. 6.5.1 shows GSM architecture. GSM architecture consists of three subsystem : 1. Base Station Subsystem (BSS) 2. Network Switching Subsystem (NSS) 3. Mobile station (Cell phone) The mobile Base station subsystem Network subsystem, Fig. 6.5.1 GSM architecture TECHNICAL PUBLICATIONS® - an upcthrust for ‘knowledge advantages of GSM over analo, d Systems and loT e loT Communication and Open Platforms Capacity increases uisystenz, Reduced RF transmission power and | Intemational roaming capability ‘ Better security against fr Encryption capability f ee (through terminal validation and user authentication) ‘or information security and pri {ibility wi g privacy Compatibility with ISDN, leading to wider rigolot bcsiincs ger battery life 6.5.1 Base Station Subsystem Base Station Subsystem (BSS) consi consists i f Station, Controlles (6S¢) of Base Transceiver Station (BTS) and Base ae Base ee Controller (BSC) is in control of and supervises a number of Base ransceiver Stations (BTS). The BSC is responsible for the allocation of radio resources to a mobile call and for the handovers that are made between base stations under his control. Other handovers are under control of the MSC. Each BSC connects to a number of Base Transceiver Stations (BTS) which, in turn, provide radio interfaces for mobile devices. BSC manages the radio resources for one or more BTSs. It handles radio channel setup, frequency hopping and handovers. The BSC also translates the 13 kbps voice channel used over the radio link to the standard 64 kbps channel used by the Public Switched Telephone Network or ISDN. Functions performed by the BSC + 1. Processing of signals 2. Controlling signals to the connected BTSs and control of handover of signals from one BTS to another within a BSS 3, Control and handover of the signals from BSC to MSC 4. Traffic control by continuous measurement of the frequency channel spectrum being used at a given instant 5.- Authentication, encryption and decryption of data 6. Updating location registry for the MSs Bose Panscewver station houses the radio transceivers that define a cell and handles the radio link protocols with the mobilé station. BST servers one or more cells in cellular network and contains more than one transceivers. This transceiver Pro\ ides full duplex communication to mobile stations. TECHNICAL ‘PUBLICATIONS® - an up-thrust for knowledge 6-24 loT Communication and Open Patton Embedded Systems and /oT © Usually a BTS is used t 0 manage one cell in the GSM cellular network, but using a sectorized antenna, a single BTS can be used to manage many cells. Main functions performed by the BTS : 5 2: 3. 4. a a Formation of cells using appropriately Directed antenna Processing of signals Amplification of signals to acceptable strength so that they can be transmitted without loss of data Channel coding and decoding Frequency hopping so that multiple channels for various mobile stations can operate simultaneously using different channel band frequencies Encryption and decryption of data [GEE] Network Switching Subsystem * It acts as an interface between wireless and fixed networks. It mainly consists of switches and databases and manages functions such as handovers between BSS's, worldwide user localization, maintenance of user accounts and call charges and management of roaming. Mobile service Switching Center (MSC) is a main component of network switching subsystem. It acts as switching node of PSTN. * Network subsystem includes four different types of database : 1 3: Home location register Equipment identity register 2. Visitor location register 4. Authentication center Mobile Services Switching Centre (MSC) * MSC consists mainly of high-performance digital ISDN switches. It connects to a number of BSCs over the "A" interface. It also connect to other MSCs and to fixed-line networks through GMSCs. It is used to manage BSCs in a geographical area. MSC performs all necessary functions in order to handle the calls to and from the mobile station. MSC performs following functions : r 2. oy 4. a Call routing Collection of billing information Call setup, monitoring and release Mobility management like registration, location updating and call handoff between BSC and MSC. Management of signaling protocol TECHNICAL PUBLICATIONS® - an up-thrust for knowledge | embedded Systems and ioT 6-25 loT Communication and Open Platforms | « The Home Location ae isit i iste LR) are located within the M: (HLR) and the Visitor Location Register (VLR) Home Location Register (HLR) + Tt includes all permanent user's information. HLR is a database used for storage and management of subscriptions + HLR stores following information : a. Subscriptions information b. International Mobile Station Identity (MSI) c, One or more Mobile station International ISBN numbers (MSISDN) d. Location information which required for billing and routing of calls towards the MSC where the MS is registered. « Each mobile user has only one HLR record worldwide, which is updated constantly on a real-time basis. Each MS must register at a specific HLR of a | specific MSC. The HLR contacts AuC in the network subsystem for authentication. | ¢ Each HLR is associated to an MSC so that when an MS registered at a certain HLR moves to another Location Area (LA), serviced by another MSC, the user's home MSC update the user's current VLR. « The database contains other useful information like tele-services and bearer services subscription information, service restrictions etc. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge | Embedded Systems and loT pee loT Communication and Open Platorms | yo | x Fig. 6.5.2 Location area Location Area Identity (LAl) is broadcasted by the BTS so a mobile station can determine if it has entered a new location area. If a new location area is entered the MSC is in formed and the VLR and HLR is updated. Each cell in a location area is allocated a Cell Identity (CI) consisting of 16 bits. The CI and LAI form a globally unique identifier of a cell. If the HLR fails the system fails. The HLR manages the location updates as mobile Phones roam. HLR connects and interacts with a number of other components on the system. a) The Gateway MSC for handling incoming calls b) The VLR for handling request from mobile phones to attach to the network ©) The SMSC for handling incoming SMS 4) The voice system for delivering notification to the mobile phone that a message is waiting TECHNICAL PUBLICATIONS® «an up-thrust for knowledge added Systems and loT 9 8-27 visting Location Register (yi py loT Communication and Open Platforms , AVLR is a database gf) , similar temporarily hold profiles of = a HLR, which is used by the mobile network to + This VLR data is based on oo users (users outside their home area). VER to handle roaming users, Mf®!mation retrieved from a HLR. MSCs use a + Dynamic real-time database i ase : data which is required for that stores both permanent and temporary subscriber of the MSC associated with ate between the MSs in the coverage area + VLR controls those mobil foe HR. Its database ee ee in its area and reduces number of queries to authentication key, TMSI, TMSI, MSISDN, MSRN, location area and « If a roamer makes a call the call setup. The VLR primary functions are, a) To inform the HLR that a MS has VLR VLR will already have the information it needs for arrived in the particular area covered by the b) To track where the subscriber is within a VLR area when it is not active c) To allocate roaming numbers during the process of incoming calls d) The VLR is reset daily Equipment Identity Register (EIR) + The EIR keeps a black list of stolen phones that should be barred from access. Stolen phones can be re-flashed with a new IMEI and thus avoid the EIR check. EIR can also block phones that are malfunctioning and disturb the network. * The EIR feature is used to reduce the number of GSM mobile handset thefts by providing a mechanism to assist network operators in preventing stolen or disallowed handsets from accessing the network. * This control is done by comparing the International Mobile Equipment Identity (IMEI) that is provided during handset registration to a set of three lists provided by the network operator : a) Black list - Mobile Stations (MS) on the black list will be denied access to the network. b) White list - MSs on the white list will be allowed access to the network. ©) Gray list - MSs on the gray list will be allowed on the network, but may be tracked. TECHNICAL PUBLICATIONS® - an up-thnust for knowledge foT Communication and Open Platforms 6-28 Embedded Systems and loT Authentication Center (AUC) + and ensures the confidentiality of each . The AUC verifies the identity of the TT spared between the SIM and the call. The AUC holds the secret key that 16 SAT SIM nor network. The key never leaves the Network nodes can request the encryption of a set of challenges from the AUC. 4 challenge is then sent to the mobile station and if the respond matches the subscriber is authenticated. : : ; The authentication process also controls encryption for privacy. It is generally associated with HLR. The AUC and the EIR can be implemented a AUC/EIR node. s stand-alone nodes or as a combined are the HLR and VLR used ? 3 Each mobile network has its own HLRs and VLRs. When a MSC detects a mobile user's presence in the area covered by its network, it first checks a database to determine if the user is in his/her home area or is roaming, ie. the user is a visitor. a) User in home area : HLR has the necessary information for initiating terminating, or receiving a call. b) User is roaming : VLR contacts the user's HLR to get the necessary information to set up a temporary user profile. The user's location is recorded in the HLR and in case the user roaming, it is also recorded in the VLR. Suppose that the user wants to make a call : s 1. User in home area : MSC contacts the HLR prior to setting up the call. 2. User is roaming : MSC contacts the VLR prior to setting up the call. Suppose that there is a call for the user (call goes to the home MSC) : 1. User in home area : Home MSC delivers the call immediately. 2. User is roaming : Home MSC contacts the VLR to determine the appropriate switch in the roaming area to handle the arriving call and then transfers the call to the roaming area MSC. Operation and Maintenance Center (OMC) supervises operation of particular GSM system blocks. OMC is connected to all Switching blocks and performs a) Traffic accounting b) Traffic monitorin, ©) Management in case of failure = 4) HLR management TECHNICAL PUBLICATION INS = an up-thrust for knowledge Embedded Systems and loT = 6-29 IoT Communication and Open Platforms + Communications betw. telephone links or its ane and network blocks is implemented by leased protocol of X25 protoce] nt MtWOHS and is performed using the S87 signalling [EEE Mobile Station A Mobile. Statio ie S applicadeng ae (MS) is equipment within the network that is used in coe cig Motion. It can be a hand-held device or any kind of device yee obile vehicle like a car, bus, boat or airplane. a ‘ ; ae emia Intemational Mobile Station Equipment Identity (MED ze Ca ‘e IMEI is often used for preventing a stolen cell phone from accessing e GSM network. It isn’t used, however, for identifying the subscriber. Each MS requites a Subscriber Identification Module (SIM), which stores a unique international mobile subscriber identity (IMSI). The MS can be locked or unlocked to a SIM provided by the operator. + Equipment Identity Register (EIR) contains a list of all valid mobiles. Authentication Center (AuC) stores the secret keys of all SIM cards. Each handset | has a International Mobile Equipment Identity (IMEI) number. Each IMSI contains a unique Mobile Country Code (MCC), a Mobile Network Code (MNC) and a ciphering key (Ke) for authorization with the Authentication Center (AuC) in the GSM network subsystem. ‘SIM card * Identity modules are synonymous with mobile devices that interoperate with GSM cellular networks. Under the GSM framework, a mobile device is referred to as a mobile station and is partitioned into two distinct components : The Universal Integrated Circuit Card (UICC) and the Mobile Equipment (ME). * A UICC, commonly referred to as an identity module (e.g., Subscriber Identity Module [SIM], Universal Subscriber Identity Module [USIM], CDMA Subscriber Identity Module [CSIM)), is a removable component that contains essential information about the subscriber. © The ME and the radio handset portion cannot fully function without a UICC. The UICC's main purpose entails authenticating the user of the mobile device to the network providing access to subscribed services. The UICC also offers storage for personal information, such as. phonebook entries, text messages, Last Numbers Dialed (LND) and service - related information. * Fig, 6.5.3 shows SIM card. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge loT Communication and Open Plattorms Embedded Systems and loT 6-30 Optional pad "or USB. Mini SIM (2FF) Optional pad Micro SIM (3FF) for USB Nano SIM (4FF) Fig, 6.5.3 SIM * SIM stores following types of information : i se 1. SIM stores the Intemational Mobile Subscriber Identity (IMSI), which is a unique identifier for each subscriber in the system. 2. Subscribers can maintain a list of the numbers they call or they are called from more frequently. 3. Information about SMS traffic. 4. Information about subscriber's location : The SIM stores the last area where the subscriber has been registered by the system. 5. Information about calls : The last numbers dialed are stored in a file in the SIM filesystem. 6. Information about the provider : It is possible to extract the provider name and the mobile network commonly used for communications, along with mobile networks that are forbidden to the subscriber. 7. Information about the system : Every SIM card has a unique ID stored in it. IM card (Subscriber Identification Module (SIM)) is a type of smart card used in mobile phone. The SIM is a detachable smart card containing the user's ~ subscription information and phone book. This allows the user to retain his or her information even after switching off the handset. Alternatively, the user can also change service providers while retaining the handset simply by changing the SIM. SIM card Securely stores the service subscriber key having 15 digits. * The digits of the key are : a). First 3 digits - Mobile country code b) Second 2 digits - Mobile network code ©) Third 10 digits - Mobile station identification number TECHNICAL PUBLICATIONS® - an up-thrust for knowledge embedded Systoms and foT $231 loT Communication and Open Platforms pss Interfaces «Um interface : Mobile station interface, also known ag nit Dat station subsystem communicate across Um me interface or radio link. + Abis interface : Base Transcei ceiver Stati communicate actoss Abis eee (BTS) and Base Station Controller (BSC) « A interface : x Base station subsystem communi ; Fea ae center across A interface. mmunicates with mobile service switching [22] GsM Channel * Physical channel corresponds to a time slot on a frequency carrier. There are 8 physical channels per carrier in GSM. Physical channel can be used to transmit speech, data or signalling information. Fig. 6.5.4 shows GSM channel. Channels Uplink Fig. 6.5.4 GSM channel * The channel from the base station to the mobile unit is known as the downlink or forward channel. The channel from the mobile unit to the base station is known as the uplink or reverse channel. Physical channel : Each timeslot on a carrier is referred to as a physical channel. Logical channel : Variety of information is transmitted between the MS and BTS. GSM logical channels consists of two types : Control Channels and Traffic Channels. = * Control channels : Control Channels is subdivided into three types : Broadcast Control channel, Common Control Channel and Dedicated Control Channel. © Channels used for communication between the MS and BSS when a call is in Progress. Control channels used by idle mode mobiles to exchange signaling information, required changing to dedicated mode. TECHNICAL PUBLICATIONS® - an up-trust for knowledge wunication and Open Platforms Embedded Systems and loT 6-32 loT Commi é tions for handov * Mobiles in dedicated mode monitor the surrounding base sta is and other information. Control channels include: 1. Broadcast Control Channel (BCCH) serves for BS iden| juency allocations. 2. oe Correction Channel (FCCH) and Synchronization Channel (SCH) used for synchronization and physical layer definition (time slots, burst time...) 3. Random Access Channel (RACH) used by mobile to request access to the network. 4, Paging Channel (PCH) used for locating the mobile user 5, Access Grant Channel (AGCH) used to obtain a dedicated channel. (Following the request of RACH) tification, broadcasts and Channel Assignment * Channel assignment are of two types : Fixed and Dynamic. * Fixed channel assignment : Each cell is given a fixed number of channels. Any new call with in a cell can only be serviced by unused channels in that cell. Otherwise the call is blocked. A cell which has ran out of channels may "borrow" channels from a neighbouring cell. + Dynamic channel assignment : Channels are allocated to cells based on incoming call requests. It controlled by a centralised entity, usually a MSC Mobile Switching Centre. Dynamic channel allocation requires collection of real time data on channel use, traffic distribution across the network and Received Signal Strength Indication (RSSI) for each channel on a continuous basis. [EX Open Platform : Raspberry Pi Architecture * A Raspberry Pi is a credit card-sized computer originally designed for education, inspired by the 1981 BBC Micro. * Creator Eben Upton's goal was to create a low-cost device that would improve programming skills and hardware understanding at the pre-university level. + The Raspberry Pi is slower than a modem laptop or desktop but is still a complete Linux computer and can provide all the expected abilities that implies, at a low-power consumption level. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge Embedded Systems and Jor Versions Remarks Raspberry Pil « The | Sniginal Raspberry Pi had 256 Mb of RAM, which increased to 512 MB ' ina later revision, _tlthas a 26-way GPIO connector * The = « Pi Zero includes the GPIO connector, but the header pins are not _ soldered | Raspb Pid | eee © + Te Raspbeny 1 3 Suse the procesor to an even more Sete eal Processor, Tt also adds Wi-Fi and bluetooth which vty needed to be added as a USB device, z The Raspberry Pi 3 Model B was launched in February 2016. To get the Raspberry Pi working an SD card needs to be prepared with the Linux operating system installed. Raspberry Pi users have made many creative and impressive projects using this device. It can also be programmed to assist in ‘housekeeping’ your network by functioning as NAS, LDAP server, web server, media server, DNS server etc. The Raspberry Pi Foundation recommends Python. Any language which will compile for ARMv6 can be used. Installed by default on the Raspberry Pi : C, C+, Java, Scratch and Ruby. [EGXII About the Board «Fig 6.6.1 shows the Raspberry Pi board. The Raspberry Pi does not have a separate CPU, RAM or GPU. Instead they are all squeezed into one component called a system on Chip or SoC unit. + Raspberry Pi is open hardware with the exception of its primary chip, the Broadcomm S0C which runs the main components of the board - CPU, graphics, memory, USB controller ete. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge Embedded Systems and loT 6-34 JoT Communication and Open Platforms JTAG headers AUDIO. Status LEDs DSI display connector SD card slot (back of board) Micro USB power Broadcom ETHERNET OUT (5V1ADC) BCM 2635 only on 256 MB models ARM11 700 MHz CSI connector camera HDMI OUT Fig 6.6.1 (a) Raspberry Pi circuit board & cri 512 MB RAM CPU and GPU Fig 6.6.1 (b) Block diagram TECHNICAL PUBLICATIONS® - an up-thnist for knowledge _———— i Operating systems «ya Models share the following features: Rag , Video output : HDMI ian RaspBMC, Arch Linux, Rise OS, OpenELEC Pidora. Composite RCA. , Supported resolutions « standards. 640x350 to 1920x1200, including 1080p, PAL and NTSC 4, Power source : Micro UsB Components | Processor Se ] ee ; oe Pi uses an ARM Processor which is also frst ina wide! | __Yatity of mobile phones + This CPU is single core, however it oes have a co-processor to perform floating point calculations * Model B Raspberry Pi has 512 MB b SDRAM ynehonous Dynamic RAM). \ “s Board has two USB, ports. USB Fo sas prodiae cacrett upto 100 mA + sg: peered hl st possible ts connect more eric a= TECHNICAL PUBLICATIONS® - an upthrus fr knowledge JoT Communication and Open Platforms in nse Sr One Embedded Systems and loT S28 Embedded Systems andioT 898 ‘Not all the GPIO pins are programmable. Some of them are 5.0 VDC or VDC positive power pins, some of them are negative ground pins and a few | of them are marked DNC (do not connect). ; : _ The PI header has 17 programmable pins an * Fig, 6.6.2 shows GPIO pin header. | Reading from various environmental sensors. Writing output to de motors, __ LEDs for status. Micro-USB connector is used for power input Ithas five status LED. d the P5 header adds 4 more, * This card is used for loading operating system * The Raspberry Pi comes with a set of 26 exposed vertical pins on the board. These pins are a General Purpose Input /Output interface that is purposely not linked to any specific native function on the Raspberry Pi board. 2 ___ Raspberry Pi P1 header /PIN# Name _ Me 3.3 VDC power =| | 8 SDAO(I20) =|. a SCLO (2c) Name nio}7|s TECHNICAL PUBLICATIONS® - an up-hnust for knowledge Embedded Systems and loT 6-37 loT Communication and Open Platforms + Instead, the GPIO pi Pins are there explicitly for the end user to have low-level hardware access dit voce Ss oe to the board for the purposes of attaching other hardware , a : pherals, LCD display screens and other hardware devices to the Pi. Status Color ED © The Raspberry Pi draws its power from a microUSB port and requires 2 microUSB-to-AC adapter. Because the Pi is a micro computer and not simply a cell phone getting a battery topped off, you need to use a high quality charger with stable power delivery that provides a consistent 5V with at least 700mA minimum output for older model units and 2.5 A for the Pi 3. [EGE Linux on Raspberry Pi + There are several unix like operating systems for the RPI and there is an operating system called RISC OS that has its origin at the developers of the first ARM chips. « The Raspberry Pi Foundation recommends the use of the following Linux Distributions : ‘ 1. Debian 7 ea 2, Raspbian i 3, Arch Linux ARM 4. QtonPi ; + Raspbian is a free operating system based on Debian optimized for the Raspberry Pi (RPI) hardware. « The default command prompt on the Pi consists of four components shown in Fig. 6.6.3. Raspbian is the desired operating system for the Raspberry Pi, In order to download and install the operating system onto our Raspberry Pi; you will need Raspbian, Win32Disklmager and USB memory card reader. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge munication and Open Platforms ee Embedded Systems and loT 2238: OS SUIT I i in 1, Download . both —Raspbian and working Win32Disklmager and save somewhere te ae araeonh easily accessible { 2. Plug the USB memory card reader into pi@raspberrypi ~ $ your computer 3. Open Win32Diskimager hese Dana 4. Find the location of the image file and this the memory card 5. Click "Write Fig. 6.6.3 Command prompt Logging In «Now itis time to turn on our Raspberry Pi. When the memory card, HDMI lead, i i lead. Ethernet cable, mouse and keyboard are plugged in, plug in the power lead, * As soon as you do this. You screen should be black and filled with white text, This will be visible every time you turn on your raspberry pi- * Wait until your screen reads "raspberrypi logi Username = pi__ [ENTER] Password = raspberry [ENTER] Cetera Patent Cran Tc eae) iota cam eames tari Paar eer en Rae Peer iret ery Sonne Nees atte att) Starting the Raspbian GUI * GUI stands for Graphical User Interface and is a type of operating system. It is the most common type of user interface as it is a very ‘friendly’ way for people to interact with the computer. It makes use of pictures, graphics, icons and pointers, hence the name ‘Graphical’ User Interface. Fig. 6.6.4 shows Rasbian Linux desktop TECHNICAL PUBLICATIONS® - an up-thrust for knowledge Embedded Systems and lor Fig. 6.6.5 : First boot : time to configure your Pi Difference between Raspberry Pi is and Desktop Computers © In Raspberry Pi, operating system is installed on SD card whereas in desktop computer, operating system is installed in hard disk. | «Raspberry Pi does not have their own CPU and RAM. «Processing power of Raspberry Pi is Jess as compared to desktop computers. | «+ Raspberry Pi uses less power than desktop computers TECHNICAL PUBLICATIONS® - an up-thrust for knowiedge —————————————————— JoT Communication and Open Platforms Embedded Systems and loT o Raspberry Pi Interfacing . Ser + Three types of interface is supported by Raspberry Pi. + Serial * It uses serial peripherals for serial communication. eH * Transmit (Tx) and Receive (Rx) pin is used for serial communication. Peripheral Interface (SP!) : SPI is a communication protocol used to transfer data between micro-computers like the Raspberry Pi and peripheral devices. These peripheral devices may be either sensors or actuators. z SPI uses 4 separate connections to communicate with the target device. These connections are the serial clock (CLK), Master Input Slave Output (MISO), Master Output Slave Input (MOSI) and Chip Select (CS). The clock pin sense pulses at a regular frequency, the speed at which the Raspberry Pi and SPI device agree to transfer data to each other. For the ADC, clock pulses are sampled on their rising edge, on the transition from low to high. * The MISO pin is a data pin used for the master to receive data from the ADC. Data is read from the bus after every clock pulse. The MOSI pin sends data from the Raspberry Pi to the ADC. The ADC will take the value of the bus on the rising edge of the clock. This means the value must be set before the clock is pulsed. The Chip Select line chooses which particular SPI device is in use. If there are multiple SPI devices, they can all share the same CLK, MOSI and MISO. The SPI has the following features : 1. 16-bit shift register 2. I6-bit Receive buffer register (SPIBUF) and 16-bit Receive buffer emulation alias register (SPIEMU) ‘ 3. 16-bit Transmit data register (SPIDATO) and 16-bit Transmit data and format selection register (SPIDAT1) 8-bit baud clock generator Serial clock (SPICLK) 1/O pin Slave in, master out (SPISIMO) 1/O pin Slave out, master in (SPISOMI 1/O pin NO op TECHNICAL PUBLICATIONS® - an upthrst for knowedge Embedded Systems and lor ex 6 i loT Communication and Open Platforms 8. Multiple slave chi P select (SPISCS| i 9. Programmable SPI clock aera Y/O pins (4 pin mode only) ange 10. Programmable character length (2 to 16 bits) 11, Programmable clock phase (delay or no delay) 12, Programmable clock polarity (high or low) 13. Interrupt capability 14. DMA support (read/write synchronization events) 15. Up to 66 MHz operation Master-slave configuration of SPI : e Fig. 6.7. Oe eae SPI system. SPI bus is composed by four signals, namely the i lave In (MOSI), Master In Slave Out (MISO), serial clock (SCK) and active low’ slave select ( \SS). + MOSI : This pin is used to transmit data out of the SPI module when it is configured as a Master and receive data when it is configured as Slave. + MISO : This pin is used to transmit data out of the SPI module when it is configured as a Slave and receive data when it is configured as Master. + /SS : This pin is used to output the select signal from the SPI module to another peripheral with which a data transfer is to take place when its configured as a Master and its used as an input to receive the slave select signal when the SPI is configured as Slave. + SCLK : This pin is used to output the clock with respect to which the SPI transfers data or receive clock in case of Slave. Fig. 6.7.1 SPI «© SCK master device will generate a pulse and the data-will be synchronized in both | | master and slave devices. There are four different clock types to define SIP | protocol, depending on what the SCK polarity and phase may be, It must ensure these signals between the master and slave devices compatible with each other. | TECHNICAL PUBLICATIONS® - an up-thrust for knowiedge E Se Embedded Systems and loT Weed Jot Communication and Open Platforms SPI is a Synchronous protocol. The clock signal is provided by a to provide synchronization. The clock signal controls when data can change and when it is valid for reading. SPI creates a data loop between two SDO (serial data output) line. Data entering the mastel input, SDI line. A clock (SCK), is generated by the master device. It controls quickly data is exchanged between the two devices. j $6 allows a master device to control when a particular slave is being addressed, This allows the possibility of having more than one slave and simplifies the communications. When the $5 signal goes low at a slave device, only that slave is accessed by SPI For SPI, there are Serial Clocks (SCLK), Chip Select lines (CS), Serial Data In (SDI) and Serial Data Out( $DO). There is only one master, there number of slaves depends on the number of chip select lines of the master. Synchronous operation, latch on rising or falling edge of clock, SDI on rising edge, SDO on falling edge. It operates in 1 to 2 MHz range. Master sends out clocks and chip selects. Activates the slaves it wants to communicate with, devices. Data leaving the master exits on the , xr enters on the serial data when and how Fig. 6.7.2 master with multiple slave interface. Master Slave 2 Fig. 6.7.2 Multiple slave interface SPI data transmit and data receive register are the main elements of the SPL. When the communication takes place the data on the transmit register red. into the shift register. Seb tooo TECHNICAL PUBLICATIONS® - an up-thrust for knowiedge ——CC—_—————————————— embedded Systems and lor 3 loT Communication and Open Platforms «The shift register j in are linked by MOS Taster of width (6.1632) and the shift register in the slave respectively. and MISO pins to form a distributed 16,32,64 bit register « When the data repinters|lara Su operation needs to be performed these 16,3264 bit clock generated Bee ed eight, sixteen, thirty-two bit positions by the serial le me master and the selected apes so that the data can be exchanged between the Data on the master SPI data transmit register becomes the input data for the slave ad fr ; re pao the MOSI and the data read from the master SPI data receive register was the data send from the slave from MISO. cenes the shift Tegisters are transferred into data receive register when the ransfer completes and this data may be read from the data receive register any time before next transfer has completed. 3. 12 ¢ DC isa communication Protocol that the Raspberry Pi can use to speak to other embedded devices (temperature sensors, displays, accelerometers, etc). T2C is a useful bus that allows data exchange between microcontrollers and peripherals with a minimum of wiring. + [LC is a two wire bus, the connections are called SDA (Serial Data) and SCL (Serial Clock). Each I2C bus has one or more masters ( Raspberry Pi) and one or more slave devices, like the I/O Expander. * As the same data and clock lines are shared between multiple slaves, we need some way to choose which device to communicate with. [El Raspberry Pi Programming + General Purpose Input/Output (GPIO) is a generic pin on a chip whose behavior can be controlled by the user at run time. The GPIO connector has a number of different types of connection : 1. True GPIO pins that you can use to turn LEDs on and off ete. 2. 12C interface pins that allow you to connect hardware modules with just two control pins. 3, SPI interface with SPI devices, a similar concept to I2C but uses a different standard. 4, Serial Rx and Tx pins for communication with serial peripherals. i { | | TECHNICAL PUBLICATIONS® - an up-thrust for knowledge Embedded Systems and [oT 6-44 JoT Communication and Open Platforms [ESE controlling LED with Raspberry Pi * Fig 6.8.1 shows diagram of connecting LED to Raspberry Pi. The LED will initially be off because the GPIO pins are initialized as inputs at power-on. © Install Python 2 library Rpi.GPIO. A library that will let us control the GPIO pins. Install commands : sudo apt?get update sudo apt?get install python?dev sudo apt?get install python?rpi.gpio os aca) ee Perse rey ce ® Cony e Oar forciscty) Fig. 6.8.1 Diagram of connecting LED to Raspberry Pi TECHNICAL PUBLICATIONS® - an up-thrust for knowled e added Systems and [oT 6-45 loT Communication and Open Platforms + Simple LED Circuit is shows below : GPIO pin— Voc 3.3V— Anode oe 2002 Y S 2002 Cathode ne GPIO pin fe) (b) © Fig. 6.8.2 Current flows from the anode (+) to cathode (-). Anode is longer pin and cathode is shorter pin. © Open up IDLE, the Python programming software and create a New file. Save it as led.py and input the code from the code listing. What the code does is first tell Python to use the GPIO module so we can connect to the GPIO pins, by importing the module. * We then import the time module so we can create a delay between commands. We then tell the code to treat the GPIO pins as the number they are on the board and to turn the seventh pin into an output. © We alternate between True and False so that it turns the pin on and off. Once it's cycled a few times, it will print the message "Done’ into IDLE and finally turn off the GPIO pins. ‘Common anode Fig. 6.8.3 TECHNICAL PUBLICATIONS® - an up-thrust for knowledge — eee SSS sation and Open Platforms Embedded Systems and loT 6-46 loT Gommunice Import RPi,GPIO as GPIO Import time GPIO.setmode(GPIO.BOARD) GPIO.setup(7, GPIO.OUT) GPIO.output(7,True) time.sleep(1) GPI0.output(7,False) time.sleep(1) GPIOcoutput(7,True) time.sleep(1) GPIO.output(7 False) print"Done" GPIO.cleanup() Task 1: Turn LED on for 2 seconds and off for 1 second, loop forever. Code is given below : (In this example, we use diagram (b), ie. controlling the LED by controlling the voltage at the anode (+)). import RPi.GPIO as GPIO import time def main() : GPIO.cleanup( ) GPIO.setmode(GPIO.BOARD) # to use Raspberry Pi board pin numbers GPIO.setup(11, GPIO.OUT) # set up GPIO output channel while True : GPIO.output(11, GPIO.LOW)_ # set RPi board pin 11 low. Tum off LED. timessleep(1) GP1O.output(11, GPIO.HIGH) # set RPi board pin 11 high. Turn on LED. time.sleep(2) main( ) * Example : Display digit on 7-segment LED. It is most direct way to control display : 1. Connect pin 3/8 of 7-seg-LED to Vcc TECHNICAL PUBLICATIONS® - an up-thrust for knowledge loT Communication and Open Platforms + For example : display (0 pins as out oT CF, DP. Set ABD, BG te pom ements A, B, D, E, G and tum off segments Gj 10 LOW and Set pin 4, 9, 5 ae and set C, F, DP to HIGH. Set Pin 7, 6, 2, 1, Interfaci 6.8.2 | Ng an LED and Switch with Raspberry Pi « When the switch i, ane peas ss not pushed : GPIO detects Vee (HIGH) ° Switch is pushed : GPIO detects GND (LOW GPIO Input Sample Code import RPi.GPIO as GPIO # Use the pin numbers from the ribbon cable board GPIO.setmode (GPIO.BCM) # Set up this pin as input, GPIO.setup (17, GPIO.IN) # Check the value of the input pin GPIO.input (17) + Hold down the button, run the command again. The output should be “true”, GPIO.input(17) Voc 3.3V GPIO input S10 ka pin pull up resistor re Fig. 6.8.4 [EEE] interfacing Light Sensor «Unlike some other devices the Raspberry Pi does not have any analogue inputs. ‘All 17 of its GPIO pins are digital. They can output high and low levels or read high and low levels. + For sensors that act as a variable resistor such as LDRs (Light Dependent Resistors) or thermistors (temperature sensors) there is a simple solution. It allows TECHNICAL PUBLICATIONS® - an up-hrust for knowledge Neen eal oT Communication and Open Platforms Embedded Systems and lo. Js using a single Gpio pin. In the case of a light different light levels. LDR to Raspberry Pi. you to measure a number of level sensor this allows you to measure «Fig 6.8.5 shows diagram of connecting an Pees ees) Fig. 6.8.5 Diagram of connecting an LDR to Raspberry Pi * Following are steps : 1. First connect pin number 1 (3v3) to the positive rail on the breadboard. 2. Next connect pin number 6 (ground) to the ground rail on the breadboard. 3. Now place the LDR sensor onto the board and have a wire go from one end to the positive rail. : 4, On the other side of the LDR sensor place a wire Iesting bi ci ack to the Raspberry Pi. Hook this to pin number 7, z 5. Finally place the capacitor. from the wire to the. negative rail on the breadboard. Make sure you have the negative pi itor i ee gative pin of the capacitor in the TECHNICAL PUBLICATIONS® - an up-thrust for ‘knowledge embedded Systems and loT loT Communication and Open Platforms + Fig 6.8.6 shows circuit gj “Suit diagram for above configurat; the sequence Of events ; a 1, Set the GPIO pin as an output and set it Low. This Sav (Pint) discharges any charge in the capacitor and ensures that both sides of the capadi i are OV. be 2, Set the GPIO pin as an oh input. This starts a flow of current through the resistors 17 pms) and through the capacitor to ground. The voltage across the capacitor starts to rise. The time it takes is proportional to the resistance of the LDR. 3. Monitor the GPIO pin and read its value. Increment a counter while we wait, 4, At some point the capacitor voltage will increase enough to be considered as a High by the GPIO pin (approx 2v), The time taken is proportional to the light level seen by the LDR. 5, Set the GPIO pin as an output and repeat the process as required. Python Code : ; #/usr/local/bin/python Fig. 6.8.6 Circuit diagram for LDR # Reading an analogue sensor with a single GPIO pin import RPi.GPIO as GPIO, time # Tell the GPIO library to use # Broadcom GPIO references GPIO.setmode(GPIO.BCM) # Define function to measure charge time def RCtime (PiPin) : measurement = 0 # Discharge capacitor GPIO.setup(PiPin, GPIO.OUT) GPIO.output(PiPin, GPIO.LOW) TECHNICAL PUBLICATIONS® - an upsthrust for knowledge lor Communication and Open Platforms Embedded Systems and (oT. 6-50 time.sleep(0.1) GPIO.setup(PiPin, GPIO.IN) # Count loops until voltage across # capacitor reads high on GPIO while (GPIO.input(PiPin) = GPIO.LOW) : measurement += 1 return measurement # Main program loop while True : print RCtime(4) # Measure timing using GPIO4 fa Connecting to the Cloud © Cloud connections are convenient and encrypted end-to-end and highly recommended for connections over the Internet. There's no firewall or router reconfiguration and you don't need to know the IP address of your Raspberry Pi, or provide a static one. ‘© Raspberry Pi and Google Cloud IoT provide a variety of opportunities for rapid prototyping. While Raspberry Pi is a powerful prototyping board on its own, cloud connectivity allows for porting embedded solutions to other boards and IoT devices. WAMP : AutoBahn for loT * WAMP stands for Web Application Messaging Protocol. It is sub-protocol of web-socket and provides publish-subscribe and RPC messaging pattern. WAMP is a routed protocol, with all components connecting to a WAMP Router, where the WAMP Router performs message routing between the components. It support distributed application architecture. Application components are distributed and run on mobile nodes and WAMP provides communication in between them. * WAMP does not make any extra standard, but it bases on established Web standards : WebSocket, JSON and URI. The WebSocket standard is the default transport channel where WAMP is binding. With the WebSocket Standard, WAMP is assumed to be given a reliable, ordered and full-duplex message channel. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge a embedded Systems end [oT Be St loT Communication and Open Platforms Key components of WAMp . 1, Transport : It is commur is default transport for which is reliable and bix tunication channel which connects two peers. WebSocket WAMP. WAMP also uses other transport protocol Wie d bi-directional communication. a 2 eee between two is called as session. 3. Client : Clients are peers that can have one or more roles. In publish-subscribe model, client can have following roles : Message producers are called publishers, whereas message consumers are called subscribers. Messages published to a topic using the publish-and-subscribe model can be received by multiple subscribers, Every subscriber receives a copy of each message, message is broadcasted. Fig. 6.9.1 shows publish-subscribe model. _e[Buvserber ~f ‘Subscriber| Fig. 6.9.1 Publish-subscribe model Role of client in RPC model is as follows : 1. The caller program, which represents the client instance in the client/server model sends a call message to the server process, and waits for a reply message. 2. Callee : Callee executes the producer to which the calls are issued by the caller and returns the result back to the caller. Routers are peers that perform generic call and event routing. Router act as Broker in publish-subscribe model. Broker ; It act as a router and routes the messages published to a topic to all subscriber subscribed to the topic. In RPC model router has the role of a broker = 1. Dealer : It act as router and routes the RPC calls from the caller to the callee and routes results from calle to caller. Application code runs on client machine. Fig, 6.9.2 shows WAMP session between client and router. TECHNICAL PUBLICATIONS® - an up-thrust for knowledge

You might also like