Loading...

Tutorial 6 : Sending Data to Servers Sending data over Wifi to a server

If you have followed the previous tutorials your Termite should now be connected to the Internet. Now we want to send the data to a server. The Termite platform provides an easy way to send data over the network to a central server using the MQTT protocol.

When you send a message to the MQTT server, the server will then broadcast the message to all devices or computers listening to that server. Both the devices sending and listening to the server need to be using the same “Topic” in order to communicate. “Topics” are used as filters and allow you to receive only the data you want. Both the server and “topics” can be secured with a login and password to keep your data safe.


Step 1 MQTT Settings

Lets set up our MQTT settings (Make sure your Termite is connected)

 Open up Termite Connect and click “Settings”

 

Go ahead and enter your MQTT settings. For this you will need to find a public server. If you don’t know of one you can use the values provided for you in the example below. This example uses a public MQTT server that is unsecured and anyone could potentially view your data. But it serves as a really good resource for testing purposes. When we gather data we use our own secured server and topics.

  1. Enter the MQTT address “broker.mqttdashboard.com
  2. Enter the MQTT Port which is by default “1883
  3. Enter your MQTT Topic this can be anything, for now use “tests
  4. Leave your MQTT Login blank for now
  5. Leave your MQTT Password blank for now
  6. Enable MQTT so that the Termite knows that it should try to send data over MQTT

 

Step 2 Receiving the Data

We are now going to receive the data with an MQTT client. This client can either be a program you download for Windows or Mac, or your own code.

 

MacOs

  1. Download and Install MQTTBox:
  2. After opening MQTTBox, “Create MQTT Client
  3. The enter the following details.
  • MQTT Client Name: You can use anything for this
  • Protocol: mitt/tcp
  • Host: broker.mqttdashboard.com:1883

Hit “Save“……The app should now connect to the server and show you a screen that looks like the one below. In order to view your data, you need to subscribe to the correct topic. Enter “tests” in the topic area and click “Subscribe“.

 

 

You should now see the Termite data coming through every 2 seconds.

 

Congradulations

You are now receiving data through a server!!!

The beautiful thing about MQTT is that the server address never changes, so you can plugin your Termite anywhere you like and the data will always be accessible through a MQTT client.