AskSensors IoT Platform Documentation


Connect Hardware to AskSensors over MQTT




As there are many IoT hardware available nowadays, AskSensors is not tied to some specific hardware or platform.
If your device is connected to the internet, you can connect it easily to AskSensors and start building your Internet of Things project in few minutes.
The AskSensors supports the Internet of Things and machine-to-machine (M2M) connectivity protocol: MQTT(Message Queuing Telemetry Transport).
This section will cover how to connect your hardware to the AskSensors IoT platform over MQTT.

AskSensors : mqtt.org



Here is a list of how to use instructions provided for some popular platforms. To start using the platform select the development board you want to use:

1-MQTT Publish/Subscribe API

2-Connect ESP8266 over MQTT

3-Connect ESP32 over MQTT

4-Connect Arduino Ethernet over MQTT



1-MQTT Publish/Subscribe API

MQTT (Message Queue Telemetry Transport) is an ISO standard publish/subscribe based and light-weight messaging protocol.
With small IoT devices in mind, the MQTT is designed for connections with remote locations where the network bandwidth is limited or a small code footprint is required.The MQTT protocol works over three transport protocols: TCP, UDP, and WebSockets.

While HTTP adheres to the standard request response model and using the common client-server pattern, the MQTT clients connect to a broker and the remote devices publish reduced message size with low latencies, which makes the MQTT more efficient in IoT applications.

a) Publish Subscribe:

Here are the main entities of MQTT protocol:

  • A message has a topic and a payload.
  • The Publisher sends a message to the network.
  • The Subscriber listens for messages with a particular topic.
  • The Broker (AskSensors broker) is responsible for coordinating the communication between publishers and subscribers.
The sender publishes a message to a topic, and any software with a subscription for that topic gets a copy of this message. The sender never really knows who is listening, and just provide his message to a set of shared queue.

The receiver subscribes to a narrow selection of topics and only receives the information he is looking for. This saves both processing time and network bandwidth.

b) AskSensors MQTT structure:

The AskSensors topic is structured in a simple way: "username/apiKeyIn"
  • username: Your AskSensors username.
  • apiKeyIn: The sensor Api Key In generated by AskSensors during the creation of your sensor.
The message payload structure:“m1=value1&m2=value2...m6=value6”.
Where "value1...value6" are the modules values. Here is an example of payload with two modules: "m1=10&m2=20".
As response to the MQTT publish sequence, The AskSensors broker returns the number of modules updated successfully.


c) Send data with timestamp:

For many applications, users need to send their data along with timestamp. The following structure shows the integration of the timestamp in the payload:
“m1=value1&m2=value2...m6=value6&t=timestamp”.
Where "timestamp" is the local timestamp of the values being sent in the payload.
The timestamp format is UNIX Epoch time in ms(or Unix time or POSIX time or Unix timestamp), which describes the number of milliseconds that have elapsed since January 1, 1970 (midnight UTC/GMT)

Below is an example of a payload sent with timestamp of Human time (GMT): Tuesday 1 January 2019 00:00:00:
"m1=10&m2=20&t=1546300800000".