Skip to content

jmir17/barbara_data_receiver_example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Barbara IoT
Barbara Data Receiver Example


Introduction

This is an example to gather the messages published in a MQTT topic and store it in a MongoDB database. The client, built in NodeJS, connects to the MQTT server over TLS and starts listening in a topic provided. When a message arrives, it takes the message and inserts it raw in a mongo collection. Both servers are containerized using Docker and can be built and deployed using Docker compose.


Installation

In order to run this software, it is necessary to install Docker CE. Find the instructions here. Also docker compose is required. Install docker compose.


Start up the servers

Clone the repository

First of all, it is necessary to get the code, clone the repository with any tool or just download the zip and extract the data inside.

Add MQTT certificates

Navigate to the folder where the repository is copied, and paste under the certs folder the certificates, using the following names: certs/client.key certs/client.crt certs/ca.crt

If you have not generated your certs yet, read the instructions here.

Define MQTT server url and the topic

To set the server url and the topic to parse, in the root path of the repository, open the file docker-compose.yaml and edit the lines 22 and 23:

-- HOST=example.com -- TOPIC=topicName

This will set the values as environment variables inside the node server.

Also, check that the IP configuration is not shared with any other network in your environment.

Run the containers

In the root path of the repository, run the containers with this command:

docker-compose up

To run the containers in the background, just add a -d flag at the end of the line:

docker-compose up -d

Build again the containers

After doing any modification to the code, the Docker containers must be rebuilt, to achieve so, we have to stop them and then run the following lines:

docker-compose build docker-compose up -d

Stop a running container in the background

To list the running containers in the server, run the command:

docker ps

Identify the containers you want to stop, and run:

docker stop 7f6ecaf856f9 da96f5374cba

In case you want to stop and also delete a running container, execute:

docker rm -f 7f6ecaf856f9 da96f5374cba


Check the data stored

Once the device has started to send data to the mqtt server, the mongodb database should have stored all the information. In order to check the collection in mongo server, any tool can be used. For instance, Mongo Compass or Studio 3T

About

Docker with tools to receive data from Barbara Things

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published