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.
- Web application
- In web application is possible to manage networks and sensors, manage XMPP nodes, define policies, and share data.
- This service is responsible to store sensor data in database, when published in nodes
- 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.
- This service is responsible to order the previous services to subscribe or unsubscribe from PubSub nodes.
- glib-2, gmodule, libloudmouth, soxlib, mysql, C, XML, XMPP
- Openfire XMPP Server
- MySQL database server
- Apache HTTP Server
- Postfix email server
install soxlib and sox_tools
- 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] JIDfirstname.lastname@example.org/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 USERNAMEemail@example.com 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?
When creating a new network it is possible to specify the access level, and network location.
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.
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 “USERNAMEfirstname.lastname@example.org&USERPASSWORD=user123&VARIABLEID=11&NODE=myHome&DATA=14698” $URL
View data charts
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 working
Datarecorder service output, policy Url being called
SMS notification arrived
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.
- 1 temperature sensor
- 1 photo-resistor
- 2 arduinos
- 1 ethernet shield
- 1 RF kit
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
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
Inteligent Mail box
- adding soon
- adding soon
- turn power off from all standby devices, if inactivity in a room is greater than a number of seconds
- arduino or pc+PIR+Relay
- create policy with geographical limitations (square), when device enters this area an action will be triggered