System overview

SAWA can be considered as a platform, with a set of services and web application. It uses XMPP Protocol to transport all sensor data in real-time, and allowing secure connections. Using XEP-060, Publisher-Subscribers paradigm it is possible to share data with multiple users with flexibility and scalability. This project uses soxlib with modifications from Sensor Andrew project.

Project blog, Project source

  • Web application
    In web application is possible to manage networks and sensors, manage XMPP nodes, define policies, and share data.

    • Technologies
      Google Maps, Flexigrid, Open Flash Charts 2, jQuery, Ajax, JavaScript, Openfire Css, CodeIgniter, PHP, C, MySQL Services
  • Datarecorder
    This service is responsible to store sensor data in database, when published in nodes

  • Actionchecker
    This service is responsible to match all sensor data with existing policies, and launch these actions when policy matches. Each notification type is included as plugin, making this service more easy to extend.

  • Scheduller This service is responsible to order the previous services to subscribe or unsubscribe from PubSub nodes.

    • Technologies
      glib-2, gmodule, libloudmouth, soxlib, mysql, C, XML, XMPP

Servers - Openfire XMPP Server - MySQL database server - Apache HTTP Server - Postfix email server

Tools

install soxlib and sox_tools
soon...

sox_tools
-sox_tools config

create .sox_tools.cfg in your home

[XMPP]
PORT=10223
HOST=hci.uma.pt
PUBSUB_SERVER_NAME=pubsub.hci.uma.pt
TIMEOUT=10

[DEFAULT_USER]
JID=user123@hci.uma.pt/resource_xpto
PASSWORD=user123

In this example we are publishing the value 25 with unit "C" from variable 14 in user123_network network

sox_tools publish user123_network 14 25 C

Bash script (HTTP method)

#!/bin/bash

# user credentials
USERNAME=user123@hci.uma.pt
USERPASSWORD=user123
NODE=user123_network
VARIABLEID=55

# publish Url
URL=http://dev.hci.uma.pt/sawa/xmpp/publish

# data value
DATA=99

curl -d "USERNAME=$USERNAME&USERPASSWORD=$USERPASSWORD&VARIABLEID[]=$VARIABLEID&NODE=$NODE&DATA[]=$DATA" $URL

How to use this system ?

Create account

After creating an account, login with your credentials.

Create Network
When creating a new network it is possible to specify the access level, and network location.

Create Sensor

To create a sensor, we have to select the network which will belong to, the type (sensor or actuator), location and the variables of the sensor (this variables can be for example door status, open time and closed time count from a door switch sensor). After this steps, we are now able to upload data and see them on charts.

Publish data
There is two methods of sending data, one is HTTP POST, useful for simples devices, without capabilities of parsing XML and establishing SSL connections. The other method is using sox_tools, a specific XMPP client for this system. Last one has the ability to publish, listen events and manage pubsub nodes.

using XMPP Client ( sox_tools recommended )

sox_tools publish myHome 11 14698

using HTTP POST

curl -d -m 10 “USERNAME=user123@hci.uma.pt&USERPASSWORD=user123&VARIABLEID[]=11&NODE=myHome&DATA=14698″ $URL

View data charts

All sensor data is set to be recorded by default, in "Data" menu, select the chart type and sensor variables to be represented, and to finish click on interval to generate graph.

Create policies



In policies we have, four types of notifications, email, sms, url and publish events to actuators, in this example I created a policy to alert me when thee door is more than 300 seconds open. I repeated the same test with all notifications types, the results are bellow.

Email notification

Email notification working

URL notification

Datarecorder service output, policy Url being called

SMS notification


SMS notification arrived

Node event

Event published on node


Practical use cases

Monitoring a refrigerator

I used this experience to test the system, so the objective was to record sensor data.
The variables I selected to record was: door status(open or closed), time open (number of seconds the door was open), and temperature.
Since arduino is very resource limited, i used HTTP POST method to publish data.

Sensors

  • sensors
    • 1 temperature sensor
    • 1 photo-resistor
  • devices
    • 2 arduinos
    • 1 ethernet shield
    • 1 RF kit

Network diagram

Sensor Network diagram

– The arduino on refrigerator sends messages to gateway (arduino in router) with format msg_id:sensor_variable:value (example: 455:door:1:temperature:10)
– Then gateway sends via HTTP POST the sensor value with user credentials and sensor identification
– Then on server, this data is published to XMPP node

Pictures

Refrigerator with Arduino


Arduino with RF transmitter module (with yellow wire as antenna)
Blue wire is energy source, red, black and white are connected to sensors


Instead of having a door switch, I used a photo-resistor as door switch, which measures the amount of light. So when we open the door, the light from refrigerator will go up and go down when door is closed.


Here is two basic sensors the “door switch” and temperature sensor


My sensor gateway, responsible for receiving data through RF and send to server


Arduino+Ethernet Shield+RF Reciver

Data charts




Possible experiences

Inteligent Mail box
adding soon

Wine monitoring
adding soon

Energy savings
turn power off from all standby devices, if inactivity in a room is greater than a number of seconds arduino or pc+PIR+Relay

GPS
create policy with geographical limitations (square), when device enters this area an action will be triggered