by: TECHVEZA TEAM


SUMMARY



SmartLibraries is an intuitive, easy-to-use, mobile application, that has the objective of providing useful information to the citizens, especially the students, about the libraries available in the city. With this app you can know different and interesting parameters as the occupation, location, timetables and noise of the libraries. You can also search for particular libraries or find which library is more suitable for you to go based in your location.

This idea also gives birth to a greater project. This project we want to manage, involves all the places suitable for the study who would want to join the idea. Thanks to the collaboration of this entities and places and the installation of sensors with the system Raspberry Pi, we will be able to obtain more interesting and accurate data. 

The data stored, could be used in the future as an analytic source for public or private entities, such as city halls, in order to manage the libraries' timetables depending on the amount of people in different time slots or to improve other services.




FULL DESCRIPTION


Getting Started

This application is meant to offer the user the possibility to search information about every library of Barcelona and obtain
which of them are the nearest ones.

In order to create this app, we have used different services provided by IBM Bluemix.
  • Cloudant Service: This service allows us to upload and update the data obtained from different libraries. We have create two different databases:
    • One for the default stored information: Name, address, timetable, accessibility, phone, web, latitude, longitude, wifi, capacity and study room booking available.
    • Another one for the data obtained by the sensors: Number of people inside the library and how noisy is it


  • Internet of things: This service helps us to establish the connections between the sensors of the Raspberry Pi and redirect the data obtained from them to the created database. It also manipulates that information.

  • Node-RED: This service is used for coding, in an intuitively way, all the necessary code for getting the data sent from the Raspberry, manipulate that data and upload it to the database. 
The environment used for coding the application is Android Studio.

We have also used a Raspberry Pi with two motion sensors and one pressure sensor. The first step is getting all the information from the sensors, then the Raspberry does a pre-processing of that data and finally, we send it to a data base using internet of things and node-red.

User Interface

The user interface is clear and simple.

You have two possibilities for finding the best library for you.
  • Find by name.
  • Button show me: It will show the libraries ordered by proximity. You can first see the information of the three libraries that are closer to you. If you want to see more, there is a show more button option.
                            Main page                                                    Finding by Name                                            Finding by location



Once you have selected the library you are interested in, it is shown a page where you can read all the information about it:
  • Name. Timetable. Address. Accessibility. Phone. Web. Wifi. Capacity. Study room booking available. People in the library. Noise level.
In there you are able to also see a map where it is shown the location of the building. 

 Information Page



Cloudant

As we have said, using that service, we have created two different databases depending on the kind of data we want to upload and use.
One of them includes the default information about the libraries, in other words, the information that is not provided by the sensors installed.



Sample document with the default information in the database

In the second database you can find the information from the sensors. A document is created inside of it every time the sensors send information. In that document you are able to see three different aspects: People, noise, timestamp. 


Sample document with the sensors information in the database

We have created a query in order to obtain the last document allocated in the database, that corresponds to the last information uploaded. For that, we defined an ascendent order based on the timestamp and we pretend to obtain the first position of the sorted documents to be able to show in our app the real time data from the sensors. 

Function used to get the documents based on the timestamp

The API URL of the data base allow us to access the documents in the indicated data base. Since we want to access to the last of them, we use the command include_docs=true&limit=1&descending=true just before the URL given.

With all of the above together, we are able to use all the data storage in our data base in the mobile application and show the users the information they are looking for.



Internet of things

The Internet of Things is a powerful tool that allows us to interconnect devices using a simple protocol (MQTT) that can be implemented by all sort of programing languages.

First of all we have created a Java application that reads the data from the sensors connected to the GPIO pins of the Raspberry and then does a pre-processing of this information. This information is sent using MQTT publications that will be received and processed using Node-RED.  All the Raspberry Pi devices will send informations the same way from all of the libraries.



Node-RED

Using Node-RED, we will be able to manipulate all that data (source, location, timestamp) and upload it to Cloudant in the final format in order to be accessed from the mobile app.  As the number of Smart Libraries increase Node-RED will be capable of processing all that data and upload it in an organized way.  The time invested to manipulate the data will be dramatically decreased because Node-RED allows us to process all that data in a very intuitive and simple way.  Node-RED will also give us the opportunity to adapt the system without having to change the Smart Library devices thanks to the flexibility and simplicity of this tool.


In this sample we see how we receive the information from the Raspberry Pi and upload it to the Data Base with no code.
When all the devices start to work in different Smart Libraries we will be able to see all the information flow and process it easily.

addTimeStamp:


msg.payload.d.timestamp = Math.floor(Date.now()/1000);
return msg;
msg.payload.d.timestamp = Math.floor(Date.now()/1000);
return msg;


Raspberry Pi

Raspberry Pi is a good choice as a sensor platform for our project.  First of all, it is a cheap device with very good capacities, so as, internet connection, digital pins, multi language platform, etc.  Also, it has got a very low power intake that with the little maintenance needed makes it excellent for permanent usage.

We will use two motor sensor at the entrance of the library to count the people in it, one of them will count the people going in, and an other one, the people leaving.  Another pressure sensor will be installed in each floor of the library that will provide continuous information of the noise in a simple and cheap way.  This sensor is very basic because it only gives two states (noisy or silent) but by continuously monitoring the environment we are able to give useful information of the average noise quantity of the place.

Demo


    You can see in that video a demo about how our application works on a mobile phone.
    We find first the libraries by name and then we choose the option of finding them by our location so we can see the three closest to us.
    When the library is chosen and we are able to see all the details uploaded, we start to interact with the sensors used. So we can change the data that depends on them, the noise level and the number of people in the library. When the information is shown the second time, this two levels are changed according to the new data sent by the sensors. 




    BLUEMIX CODE

    Library dataBase API url (it contains the information about the libraries) : 
    https://e5324516-1b4f-417a-b9ca-e777efc3467b-bluemix.cloudant.com/library/_all_docs

    • Access  to the code : http://pastebin.com/cGr9RARu

    Pi dataBase API url(it contains the information provided by the sensors) : https://6eeb4e08-932a-4dc0-9db8-6c6f4026a074-bluemix.cloudant.com/pi/_all_docs

    • Access to the code: http://pastebin.com/EezJM9xD

    Query (Map function): http://pastebin.com/a741rniU

    AddTimeStamp function used in Node-RED: http://pastebin.com/zsVGTcth


    Hackk code (code to be able to send the information from the sensors to node-RED): https://github.com/Techveza/SmartLibraries/tree/master/Hackk 
     





    Video Presentation

    If your project has been nominated for global awards, please embed here your 3-minute Youtube presentation. (Select "Insert" --> "Youtube").
TEAM 
Techveza


MEMBERS

Alejandro Woodward

Irina Sánchez

Javier González

Oriol Vila

Cristina González

Diana González


GITHUB

IBM BLUEMIX USE
  • Cloudant
  • Internet of things
  • node-RED
Library dataBase API url 
(it contains the information 
about the libraries) : link

(https://e5324516-1b4f-417a-b9ca-e777efc3467b-bluemix.cloudant.com/library/_all_docs)

  • Access  to the code: link 
  • http://pastebin.com/cGr9RARu

Pi dataBase API url
(it contains the information provided 
by the sensors) : link

(https://6eeb4e08-932a-4dc0-9db8-6c6f4026a074-bluemix.cloudant.com/pi/_all_docs)

  • Access to the code: link
  • http://pastebin.com/EezJM9xD

Query (Map function): link
(http://pastebin.com/a741rniU)


AddTimeStamp function used in 
Node-RED: link
(http://pastebin.com/zsVGTcth)


Hackk code 
(code to be able to send the 
information from the sensors to 
node-RED): link
(https://github.com/Techveza/SmartLibraries/tree/master/Hackk)