Child pages
  • Arduino library for Labeeb IoT Devices
Skip to end of metadata
Go to start of metadata

What can be done with Labeeb IoT Arduino library for devices


Using this library,you will be able to communicate and publish data to Labeeb IoT through MQTT:  

  1. MQTT connectivity : 

    1. Client initialization : where you can specify the server address and access credentials.

    2. Connect to Labeeb IoT server: where you can establish the connection with Labeeb IoT.

    3. Publish data to Labeeb IoT platform: where you can send your data to Labeeb IoT. 

    4. Subscribe to data on Labeeb IoT platform :where you can receive data from other devices/ends through Labeeb platform.

Library download and import : 

Pre-Requirement

Before you start using this library you need:

1) Download the library files from here: Download link.

2) Extract the folder named : "LabeebIoT".

3) Copy the folder "LabeebIoT" to Arduino IDE library directory, regularly placed in : "C:\Program Files (x86)\Arduino\libraries ".

4) Start Arduino IDE and make sure the library is loaded by checking File > Examples > LabeebIoT, open the "ESP8266_push_sub_labeeb" example and follow the rest of this tutorial.

Hands on Using the Library to push data to Labeeb through MQTT on ESP8266 controller:  


 

  1. What is "ESP8266" ?

    The ESP8266 is a low-cost Wi-Fi chip with full TCP/IP stack and MCU (microcontroller unit) capability produced by Shanghai-based Chinese manufacturer, Espressif Systems, and it's compatible with Arduino core and can be programmed using Arduino IDE.

  2. Initialize the connection: 

    Create and initialize LabeebIoT object by calling the following constructor : 

    Program Language Code 1
    LabeebIoT labeeb (espClient,mqtt_server,1883,"ENTERPRISE NAME");
    
    

    Since the parameters are :
    a) espClient : wifi client object on ESP8266 or you can use Ethernet client object when using Arduino board  with Ethernet shield.
    b) mqtt_server: where you specify the address of MQTT hosting server : mea.labeeb-iot.com
    c) port number of the MQTT broker, default is : 1883.
    d) ENTERPRISE NAME :  where you specify the enterprise name used when you have created your Labeeb account. If you dont have on, visit mea.labeeb-iot.com and create free account. 


  1. Connect to Labeeb IoT: 

    Use connectLabeeb function to establish the connection with Labeeb IoT platform with the following parameters: 

    Program Language Code 1
    labeeb.connectLabeeb("Client ID","TEMPLATE ID", "TEMPLATE PASS")

    a) Client ID:  the Client ID that will be used to connect to the MQTT broker, can be any ID.
    b) TEMPLATE ID: the device template ID that was created in Labeeb platform.
    c) TEMPLATE PASS: the device template password that was specified while creating the device template.This password will be used to connect to the MQTT broker


  2. Publish single datatype data to Labeeb IoT : 

    Use publishLabeebValue function to publish a single value to labeeb IoT platform with the following parameters: 

    Program Language Code 1
    labeeb.publishLabeebValue("device name","data model","data type","value","timestamp","longitude","latitude","altitude");
    
    

    a) device name: the device name within Labeeb IoT platform.
    b) data model: the data type name which belong to the specified device.
    c) data type: data type name which belong to the specified data model.
    d) value: sensor value.
    e) timestamp: Linux formatted time stamp. 

    f) optionally you can add location parameters: longitude,latitude,altitude.


  3. Publish multiple data types to Labeeb IoT : 

    Use publishLabeeb function to publish a multiple values to labeeb IoT platform with the following parameters: 

    Program Language Code 1
    labeeb.publishLabeeb("device name","data model","data Type - values pairs","timestamp","longitude","latitude","altitude");
    

    a) data Type - values pairs: use the following format  : "datatype1:value1,datatype2:value2" 


  4. Subscribe to a specific topic: 

    you can also subscribe to some topic by calling:

    Program Language Code 1
    labeeb.subscribe("TOPIC");

What's next ?


After you push data to your Labeeb IoT account , now you can check the Data on the portal , retrieve it through our  Labeeb IoT APIs and Web Services and then use this data in your mobile apps.Check one of our Getting Started.