User Tools

Site Tools


proiecte:temp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
proiecte:temp [2018/09/24 13:10]
narcisa_ana.vasile
proiecte:temp [2018/11/28 11:48] (current)
narcisa_ana.vasile [Bibliography]
Line 1: Line 1:
-====== Temp ======+====== CoAP for Contiki OS over Sparrow ======
  
 ===== Introduction ===== ===== Introduction =====
-TODO+The goal of this project is to create a flexible platform for developing Wireless Sensor Networks applications using the Sparrow sensor nodes. The key objectives of this project include porting the open-source operating system, Contiki, to Sparrow sensor nodes and porting CoAP network protocol to Contiki-running Sparrow nodes.
  
 ===== Network Topology ===== ===== Network Topology =====
Line 11: Line 11:
  
 One of the Sparrow nodes is chosen to be the border router that communicates with a host using a tool called tunslip6. Tunslip6 creates a virtual network interface(tun0) and uses SLIP (Serial Line Internet Protocol) to encapsulate the traffic on the serial line. The border router will receive the address aaaa::1 and it will form a network with the other Sparrow nodes, by passing the prefix received from the host to all nodes. One of the Sparrow nodes is chosen to be the border router that communicates with a host using a tool called tunslip6. Tunslip6 creates a virtual network interface(tun0) and uses SLIP (Serial Line Internet Protocol) to encapsulate the traffic on the serial line. The border router will receive the address aaaa::1 and it will form a network with the other Sparrow nodes, by passing the prefix received from the host to all nodes.
- 
 The other Sparrow nodes will run Contiki with a CoAP server as the main application. Those nodes will acquire data using different sensors and will pass the data to the CoAP client in the external network.  The other Sparrow nodes will run Contiki with a CoAP server as the main application. Those nodes will acquire data using different sensors and will pass the data to the CoAP client in the external network. 
  
-===== TODO Title =====+===== Technologies ===== 
 + 
 +==== Contiki ==== 
 + 
 +Contiki is an operating system for memory constrained systems, optimized for low-power microcontrollers. A list of available hardware platforms on which Contiki has been ported can be found at http://www.contiki-os.org/hardware.html. Contiki's kernel is event-driven, but a library can be optionally linked to provide multi-threading capabilities.  
 + 
 +===CoAP ====
  
 Sensor nodes are devices capable of acquiring information from the environment using different types of sensors attached to them. Those sensors perform measurements and return information such as the value of the temperature, the quality of air, the value of the humidity in the air, etc. The microcontroller communicates with the sensors and retrieves the data gathered by them to process/analyze/send it further. The transmission of the data from the sensors to the microcontroller is done using a common language (communication protocol) that enforces a set of communication rules to allow the exchange of information. Similarly, to transmit the data from the sensor node to a different device (a laptop, a phone, a different node, etc.) a protocol must be established between the entities that wish to communicate. Actually, multiple protocols are usually used to allow communication between devices, each one of them governing a different communication level/layer. The scheme of protocols for sensor nodes communication used in this project is depicted in the following diagram. Sensor nodes are devices capable of acquiring information from the environment using different types of sensors attached to them. Those sensors perform measurements and return information such as the value of the temperature, the quality of air, the value of the humidity in the air, etc. The microcontroller communicates with the sensors and retrieves the data gathered by them to process/analyze/send it further. The transmission of the data from the sensors to the microcontroller is done using a common language (communication protocol) that enforces a set of communication rules to allow the exchange of information. Similarly, to transmit the data from the sensor node to a different device (a laptop, a phone, a different node, etc.) a protocol must be established between the entities that wish to communicate. Actually, multiple protocols are usually used to allow communication between devices, each one of them governing a different communication level/layer. The scheme of protocols for sensor nodes communication used in this project is depicted in the following diagram.
Line 48: Line 53:
 git checkout sparrow git checkout sparrow
 </file> </file>
 +
 +Then follow the instructions from https://elf.cs.pub.ro/wsn/wiki/lab7 to finish configuration and install missing tools needed for Contiki.
 +
 +==== Border Router ====
  
 To make and upload the border-router application to the Sparrow node To make and upload the border-router application to the Sparrow node
Line 91: Line 100:
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)       RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B) 
  
-</code> 
 Autostart other processes Autostart other processes
 RPL-Border router started  RPL-Border router started 
Line 104: Line 112:
   fe80::11:22ff:fe33:4404     fe80::11:22ff:fe33:4404  
 </code> </code>
 +
 +==== CoAP Server ====
 +
 +To make and upload the CoAP server on a different Sparrow node:
 +
 +<file>
 +cd examples/er-rest-example
 +make upload WITH_COAP=1 AVRDUDE_PORT=/dev/ttyUSB1
 +make login AVRDUDE_PORT=/dev/ttyUSB1
 +</file>
 +
 +The ip address of the CoAP server should be printed in the console. 
 +
 +==== CoAP Client ====
 +
 +From Github, clone the open source CoAP client (implemented in Python). Example of running the client:
 +<file>
 +python coapclient.py -o GET -p coap://[aaaa::11:22ff:fe33:4403]:5683/sensors/temperature
 +</file>
 +
 +==== Firebase ====
 +
 +Firebase is an application development platform that offers services such as realtime database, cloud messaging, analytics, etc. It can be used to store the data gathered by the Sparrow nodes and it's easy to integrate it with mobile application, so that users can receive notifications about data evolution directly ontheir phones.
 +
 +I order to setup Firebase, firstly, go to Firebase console https://console.firebase.google.com and create a new project. Then, install Node.js and from the terminal, run the following commands:
 +
 +<file>
 +npm install -g firebase-tools
 +firebase login
 +</file>
 +
 +Login with your google account and initialize Firebase:
 +
 +<file>
 +firebase init
 +</file>
 +
 +If you want to link Firebase with a mobile phone application, you should also initialize the cloud functions:
 +
 +<file>
 +firebase init functions
 +</file>
 +
 +A file named "database.rules.json" should be created. Edit this file to change the permissions for your database. For example, the following code allows only authenticated users to read and write from/to the database:
 +
 +<code>
 +{                                                                           
 +"rules": {
 +   ".read": "auth != null",
 +   ".write": "auth != null"
 +  }
 +
 +</code>
 +
 +To store the information gathered from the sensors in the database, follow these steps:
 +  - From Firebase console **Project settings -> Service accounts -> Generate new provate key**. Download the file generated locally - this will be used to allow access to firebase from your laptop.
 +  - Go to Firebase console, copy the url of your project. It should be something similar to 'https://projectID.firebaseio.com', where projectID can be found in **Project settings -> Your project**.
 +  - Send the information received by the CoAP client running on the laptop to Firebase. Below, is an example of a python code that sends the value of the temperature in cloud:
 +
 +<code>
 +import firebase_admin                                                                                                                       
 +from firebase_admin import credentials
 +from firebase_admin import db
 +
 +firebase_url = 'https://ProjectID.firebaseio.com'
 +cred = credentials.Certificate("./PrivateKeyGeneratedInTheFirstStep.json")
 +firebase_admin.initialize_app(cred, {
 +         'databaseURL': firebase_url
 +})
 +
 +ref = db.reference('sensors')
 +data_ref = ref.child('Temperature/')
 +data_ref.set({
 +    'title' : 'Temperature',
 +    'body' : TemperatureValue,
 +})
 +</code>
 +
 +
 +
  
proiecte/temp.1537783817.txt.gz · Last modified: 2018/09/24 13:10 by narcisa_ana.vasile