Skip to main content

Get Started with the IoT Service

The Echolo IoT Service is an IoT Message broker that allows devices to communicate to each other or to the cloud easily. This service uses a pub/sub (Publish & Subscribe) model allowing a Hub to connect and send or receive messages on any allowed Topics. 

NOTE: All our examples will use the Echolo NPM Library but we support any mqtt library. When using a 3rd party library you will still need to authenticate with the service using your hubId and key. Often times this is labeled as username and password.

Open a connection to the IoT Service

First, we need to open the client and authenticate using our hubId and key.

let iot = Echolo.IoT({ "hubId": "myHubId", "key": "xxxx-xxxx-xxxx-xxxxx-xxxxxx-xxxxxxx" })

Subscribe to the Hub's Topic

When a hub is created, it gets its own topic that it can both read and write to. Review Topics and Hub for more information.

For this example lets say our data is as follows:







As it shows in the Topics guide we form the topic path like so: hub/appId/hubId using the data above it comes to be: hub/12345678-1234-1234-1234-098765431/EcholoHub001

iot.on('connect', function() {

After we subscribe to the topic we then need to watch for an event called message.

iot.on('message', (topic, message) => {

Publish a message to the same Topic

Now that we have opened a subscription to the hub Topic. Let's send it a message, again we will be using the same topic above hub/12345678-1234-1234-1234-098765431/EcholoHub001.

let data = { myKey: 'My Value', someInt: 123 }

iot.publish('hub/12345678-1234-1234-1234-098765431/EcholoHub001', JSON.stringify(data))

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.