Displaying GPS Data from Multiple Sensors on a Single Maps Widget--Maps can not be displayed

I am currently working on a project that involves location and health monitoring. My setup includes a pulse oximeter sensor, a temperature sensor, and a GPS sensor. I want all the sensor data to be displayed on an Ubidots dashboard via MQTT.

So far, I have been successful in displaying the health monitoring sensor data on the Ubidots dashboard. However, I am facing challenges in displaying the data from the GPS module on my widget. Could anyone provide some advice or point me towards relevant tutorials that might help me resolve this issue?

Additionally, I have another question related to the display of GPS data. Let’s say I have three sets of modules, each with its own sensor. Is it possible to display the different points from these three GPS sensors on the same dashboard, specifically within a single maps widget? If so, could you recommend any references that could guide me through this process?

Thank you for your assistance.

Hello @shonaafaiqa,

I hope this message finds you well.

Here is a complete guide to configure properly your map widget.

Regarding your other question, the answer is yes, you can display different points on a single map widget. You just need to change the marker group according to the available options.

I’ll be attentive if you need further assistance.


Alright. Thank you so much for your assistance.

HI! Is it possible to use this method for mqtt canvas?

See a free 24/7 demo at

Hello @shonaafaiqa,

Did you mean HTML Canvas?

I am sorry, I mean using the mqtt protocol. Is that the same?
I’ve created my project using ubidots esp mqtt library

Oh got it @shonaafaiqa,

When you asked about the possibility of using this method for MQTT, which specific method were you referring to? This will help me provide you with more accurate assistance.


to make it more clear, here I provide you my code. In this code I’ve been successfully get the value of my temperature sensor and my pulse oximeter sensor to show the result in ubidots dashboard. I wonder if I could add the code from your reference to my existing code here:

#include <Wire.h>
#include "MAX30105.h"
#include <OneWire.h>
#include <DallasTemperature.h>
#include "UbidotsESPMQTT.h"
#include "spo2_algorithm.h"

#define TOKEN "" // Your Ubidots TOKEN
#define WIFINAME "" //Your SSID
#define WIFIPASS "" // Your Wifi Pass
#define MQTTCLIENTNAME "" // Your MQTT Client Name, it must be unique so we recommend to choose a random ASCII name
#define PIN_DALLAS D4 // GPIO pin for Dallas temperature sensor

MAX30105 particleSensor;
OneWire ourWire(PIN_DALLAS);
DallasTemperature sensors(&ourWire);

float temp;

uint32_t irBuffer[100]; // Infrared LED sensor data
uint32_t redBuffer[100]; // Red LED sensor data

int32_t spo2; // SPO2 value
int8_t validSPO2; // Indicator for valid SPO2 calculation
int32_t heartRate; // Heart rate value
int8_t validHeartRate; // Indicator for valid heart rate calculation

void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived [");
  Serial.print("] ");
  for (int i = 0; i < length; i++) {

void setup() {
  client.wifiConnection(WIFINAME, WIFIPASS);

  pinMode(PIN_DALLAS, INPUT); // Configure Dallas temperature sensor pin as input

  // Initialize sensor
  if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) {
    Serial.println(F("MAX30105 was not found. Please check wiring/power."));
    while (1);

  // Sensor setup
  particleSensor.setup(); // Use default settings

  // Clear buffers
  memset(irBuffer, 0, sizeof(irBuffer));
  memset(redBuffer, 0, sizeof(redBuffer));


void loop() {
  unsigned long startTime = millis(); // Record the start time

  // Loop for approximately 5 minutes (300,000 milliseconds)
  while (millis() - startTime < 300000) {
    if (!client.connected()) {

    // Read sensor data
    for (byte i = 0; i < 100; i++) {
      while (!particleSensor.available()) // Wait until new data is available

      redBuffer[i] = particleSensor.getRed();
      irBuffer[i] = particleSensor.getIR();

    // Calculate heart rate and SPO2
    maxim_heart_rate_and_oxygen_saturation(irBuffer, 100, redBuffer, &spo2, &validSPO2, &heartRate, &validHeartRate);

    temp = sensors.getTempCByIndex(0);
    client.add("temperature", temp);
    client.add("spo2", spo2);
    client.add("heart rate", heartRate);


    // Output data
    for (byte i = 0; i < 100; i++) {
      Serial.print(F(", ir="));
      Serial.print(F(", HR="));
      Serial.print(F(", HRvalid="));
      Serial.print(F(", SPO2="));
      Serial.print(F(", SPO2Valid="));
      Serial.print(", Temperature=");

    // Disconnect MQTT client

    // Wait for a short interval before performing the next iteration of sensor reading and publishing
    delay(1000); // Adjust the delay time as needed

  // Enter deep sleep mode for 2 minutes (2 minutes * 60 seconds * 1e6 microseconds)
  Serial.println("Entering deep sleep for 1 minutes for example");
  ESP.deepSleep(1 * 60 * 1e6);

Hello @shonaafaiqa,

Thank you for providing your code. To include GPS coordinates in your code using the ESP32 MQTT library, add the following to the client payload before publishing the data.


Each client.add() call adds a new variable to the payload before sending all the data to your device in Ubidots. Therefore, you need to add another variable called ‘position’ first.

client.add("position", 1)

Next, use the addContext function to include the latitude and longitude in the context of the ‘position’ variable. Here is a detailed explanation of our MQTT library.

Ubidots.addContext("lat", latitude)
Ubidots.addContext("lng", longitude)

Therefore, based on your device, you need to determine how to obtain the latitude and longitude before sending the data.

Let me know if this helps you.


Thank you for your answer, it give me an idea about what to do in my code.
Actually, I use the “UbidotsESPMQTT.h” for esp8266.
Below I attached the github for the library that I use
library of “UbidotsESPMQTT.h”

Perfect @shonaafaiqa,

Let me know if you need further assistance.