Posts tagged "FAVORIOT"

ESP32 – Favoriot Example using MQTT and Wifi

September 14th, 2026 Posted by HOW-TO, Internet of Things, IOT PLATFORM 0 thoughts on “ESP32 – Favoriot Example using MQTT and Wifi”

Here’s an example of the source code:

<style data-wp-block-html="css">
/*
 * ESP32 -> Favoriot MQTT Example
 * ------------------------------
 * - Connects to Wi-Fi
 * - Connects to Favoriot MQTT broker (non‑secure port 1883)
 * - Publishes a JSON payload to {access_token}/v2/streams
 * - Subscribes to {access_token}/v2/streams/status
 * - Reconnects automatically if connection drops
 * - Non‑blocking loop (no delay())
 */

#include <WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>   // for easier JSON building

// ================== Wi‑Fi Credentials ==================
const char* WIFI_SSID     = "YOUR_WIFI_SSID";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";

// ================== Favoriot Credentials ==================
const char* DEVICE_DEVELOPER_ID = "deviceDefault@your_username"; // e.g., deviceDefault@favoriot
const char* ACCESS_TOKEN        = "your_device_access_token";    // from Favoriot platform

// ================== MQTT Broker Configuration ==================
const char* MQTT_HOST = "mqtt.favoriot.com";
const int   MQTT_PORT = 1883;   // 1883 = plain TCP, 8883 = TLS (secure)
// For TLS, you would need additional certificates and use WiFiClientSecure – see notes below.

WiFiClient espClient;
PubSubClient client(espClient);

// Topics
const String PUBLISH_TOPIC   = String(ACCESS_TOKEN) + "/v2/streams";           // publish data
const String SUBSCRIBE_TOPIC = String(ACCESS_TOKEN) + "/v2/streams/status";   // receive status

// ================== Timing ==================
const unsigned long PUBLISH_INTERVAL = 10000;  // publish every 10 seconds
unsigned long lastPublishTime = 0;

// ------------------------------------------------------------------
// Connect to Wi‑Fi
// ------------------------------------------------------------------
void setupWiFi() {
  Serial.print("Connecting to Wi‑Fi");
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\n✅ Connected to Wi‑Fi. IP: " + WiFi.localIP().toString());
}

// ------------------------------------------------------------------
// Reconnect to MQTT broker (called when connection lost)
// ------------------------------------------------------------------
void reconnectMQTT() {
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Use access token as username AND password
    if (client.connect("ESP32Client", ACCESS_TOKEN, ACCESS_TOKEN)) {
      Serial.println("✅ Connected to MQTT");
      // Resubscribe to status topic
      client.subscribe(SUBSCRIBE_TOPIC.c_str());
    } else {
      Serial.print("❌ Failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      delay(5000);  // Wait 5s before retrying
    }
  }
}

// ------------------------------------------------------------------
// Callback for subscription (status messages)
// ------------------------------------------------------------------
void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived on topic: ");
  Serial.println(topic);
  Serial.print("Payload: ");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();
}

// ------------------------------------------------------------------
// Build JSON payload and publish
// ------------------------------------------------------------------
void publishData() {
  // Use ArduinoJson to create the payload
  StaticJsonDocument<256> jsonDoc;
  jsonDoc["device_developer_id"] = DEVICE_DEVELOPER_ID;

  // Replace this with actual sensor reads (e.g., temperature, humidity, etc.)
  JsonObject data = jsonDoc.createNestedObject("data");
  data["temperature"] = 25.3;   // example value
  data["humidity"]    = 60.1;
  data["sensor_id"]   = "esp32-01";

  // Serialize to a char buffer
  char buffer[256];
  serializeJson(jsonDoc, buffer);

  Serial.print("Publishing: ");
  Serial.println(buffer);

  // Publish to the topic
  if (client.publish(PUBLISH_TOPIC.c_str(), buffer)) {
    Serial.println("✅ Published successfully");
  } else {
    Serial.println("❌ Publish failed");
  }
}

// ------------------------------------------------------------------
// Arduino setup
// ------------------------------------------------------------------
void setup() {
  Serial.begin(115200);
  setupWiFi();

  // Configure MQTT
  client.setServer(MQTT_HOST, MQTT_PORT);
  client.setCallback(callback);
}

// ------------------------------------------------------------------
// Arduino loop (non‑blocking)
// ------------------------------------------------------------------
void loop() {
  if (!client.connected()) {
    reconnectMQTT();
  }
  client.loop();  // keep the MQTT connection alive

  // Publish data at intervals
  if (millis() - lastPublishTime >= PUBLISH_INTERVAL) {
    publishData();
    lastPublishTime = millis();
  }
}
</style>

<script data-wp-block-html="js">
/*
 * ESP32 -> Favoriot MQTT Example
 * ------------------------------
 * - Connects to Wi-Fi
 * - Connects to Favoriot MQTT broker (non‑secure port 1883)
 * - Publishes a JSON payload to {access_token}/v2/streams
 * - Subscribes to {access_token}/v2/streams/status
 * - Reconnects automatically if connection drops
 * - Non‑blocking loop (no delay())
 */

#include <WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>   // for easier JSON building

// ================== Wi‑Fi Credentials ==================
const char* WIFI_SSID     = "YOUR_WIFI_SSID";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";

// ================== Favoriot Credentials ==================
const char* DEVICE_DEVELOPER_ID = "deviceDefault@your_username"; // e.g., deviceDefault@favoriot
const char* ACCESS_TOKEN        = "your_device_access_token";    // from Favoriot platform

// ================== MQTT Broker Configuration ==================
const char* MQTT_HOST = "mqtt.favoriot.com";
const int   MQTT_PORT = 1883;   // 1883 = plain TCP, 8883 = TLS (secure)
// For TLS, you would need additional certificates and use WiFiClientSecure – see notes below.

WiFiClient espClient;
PubSubClient client(espClient);

// Topics
const String PUBLISH_TOPIC   = String(ACCESS_TOKEN) + "/v2/streams";           // publish data
const String SUBSCRIBE_TOPIC = String(ACCESS_TOKEN) + "/v2/streams/status";   // receive status

// ================== Timing ==================
const unsigned long PUBLISH_INTERVAL = 10000;  // publish every 10 seconds
unsigned long lastPublishTime = 0;

// ------------------------------------------------------------------
// Connect to Wi‑Fi
// ------------------------------------------------------------------
void setupWiFi() {
  Serial.print("Connecting to Wi‑Fi");
  WiFi.mode(WIFI_STA);
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\n✅ Connected to Wi‑Fi. IP: " + WiFi.localIP().toString());
}

// ------------------------------------------------------------------
// Reconnect to MQTT broker (called when connection lost)
// ------------------------------------------------------------------
void reconnectMQTT() {
  while (!client.connected()) {
    Serial.print("Attempting MQTT connection...");
    // Use access token as username AND password
    if (client.connect("ESP32Client", ACCESS_TOKEN, ACCESS_TOKEN)) {
      Serial.println("✅ Connected to MQTT");
      // Resubscribe to status topic
      client.subscribe(SUBSCRIBE_TOPIC.c_str());
    } else {
      Serial.print("❌ Failed, rc=");
      Serial.print(client.state());
      Serial.println(" try again in 5 seconds");
      delay(5000);  // Wait 5s before retrying
    }
  }
}

// ------------------------------------------------------------------
// Callback for subscription (status messages)
// ------------------------------------------------------------------
void callback(char* topic, byte* payload, unsigned int length) {
  Serial.print("Message arrived on topic: ");
  Serial.println(topic);
  Serial.print("Payload: ");
  for (int i = 0; i < length; i++) {
    Serial.print((char)payload[i]);
  }
  Serial.println();
}

// ------------------------------------------------------------------
// Build JSON payload and publish
// ------------------------------------------------------------------
void publishData() {
  // Use ArduinoJson to create the payload
  StaticJsonDocument<256> jsonDoc;
  jsonDoc["device_developer_id"] = DEVICE_DEVELOPER_ID;

  // Replace this with actual sensor reads (e.g., temperature, humidity, etc.)
  JsonObject data = jsonDoc.createNestedObject("data");
  data["temperature"] = 25.3;   // example value
  data["humidity"]    = 60.1;
  data["sensor_id"]   = "esp32-01";

  // Serialize to a char buffer
  char buffer[256];
  serializeJson(jsonDoc, buffer);

  Serial.print("Publishing: ");
  Serial.println(buffer);

  // Publish to the topic
  if (client.publish(PUBLISH_TOPIC.c_str(), buffer)) {
    Serial.println("✅ Published successfully");
  } else {
    Serial.println("❌ Publish failed");
  }
}

// ------------------------------------------------------------------
// Arduino setup
// ------------------------------------------------------------------
void setup() {
  Serial.begin(115200);
  setupWiFi();

  // Configure MQTT
  client.setServer(MQTT_HOST, MQTT_PORT);
  client.setCallback(callback);
}

// ------------------------------------------------------------------
// Arduino loop (non‑blocking)
// ------------------------------------------------------------------
void loop() {
  if (!client.connected()) {
    reconnectMQTT();
  }
  client.loop();  // keep the MQTT connection alive

  // Publish data at intervals
  if (millis() - lastPublishTime >= PUBLISH_INTERVAL) {
    publishData();
    lastPublishTime = millis();
  }
}
</script>

Or you can use Favoriot’s Faybee Chatbot to help you generate the sample code or any help that you want.

The source code above has been generated through the prompt shown below..

FAVORIOT Research Papers and Journals (2017-2026)

September 8th, 2026 Posted by BLOG, HOW-TO, Internet of Things, IOT PLATFORM, PARTNER 0 thoughts on “FAVORIOT Research Papers and Journals (2017-2026)”
FAVORIOT Research Library | Blog Edition
Published research

Ideas made observable.

Explore academic work that uses or discusses the FAVORIOT platform, from air quality and aquaponics to smart buildings, healthcare and infrastructure.

37 research records
26 journal & periodical articles
11 conference papers
6 application domains

Journal & periodical articles

Grouped by application domain. Each record links to a publisher, DOI, repository or direct PDF.

FAVORIOT Research Library Curated for readers, researchers and IoT builders.

Before You Buy Another Sensor, Ask This Question First

September 7th, 2026 Posted by HOW-TO, Internet of Things, IOT PLATFORM, PARTNER 0 thoughts on “Before You Buy Another Sensor, Ask This Question First”

Most IoT budgets get spent in the wrong order. A company decides it wants visibility into a process, picks a sensor or a piece of equipment that looks right on paper, and only afterward starts asking whether the thing can actually talk to a platform. By then the purchase order is signed, the vendor has been paid, and someone on the technical team is quietly trying to figure out why a device that works perfectly on the factory floor refuses to send a single reading anywhere useful.

FAVORIOT has now built a service specifically to catch this problem before it becomes an expensive discovery: the Device Compatibility Assessment.

The Gap Between “It Works” and “It Connects”

A device functioning correctly and a device being ready to integrate are two different things, and the difference is rarely obvious until someone tries to bridge them. A sensor might use a proprietary protocol nobody documented. A machine’s PLC might expose data only through a vendor API that requires credentials nobody thought to request. An older piece of equipment might need a firmware update just to speak a language the rest of the system understands.

None of this shows up in a product brochure. It shows up weeks into a project, usually after budget has already been committed to hardware, and usually as a delay nobody planned for.

What the Assessment Actually Determines

The Device Compatibility Assessment exists to answer one specific question before any commitment is made: can this device connect to FAVORIOT, and if so, how? The assessment looks at four possible paths:

  1. Direct connection – the device can talk to FAVORIOT with no extra work.
  2. A documented vendor API – integration happens through the manufacturer’s own interface.
  3. An edge gateway or protocol converter – the device connects indirectly through a translation layer.
  4. Firmware changes – the device needs updates before it can participate at all.

Each assessment covers one clearly defined configuration, meaning one manufacturer, model, and firmware version, tested against one communications method. That narrow scope is deliberate. A tighter assessment produces a clearer answer than a broad one that tries to cover too much ground at once.

What’s Involved on Both Sides

The process works best as a two-way exchange of information rather than a black box exercise. On FAVORIOT’s side, the assessment includes a remote review, a technical meeting of up to 90 minutes, a review of protocols and payload structure, a look at authentication and security requirements, and a written compatibility report at the end.

On the customer’s side, a few things need to be ready before the clock starts:

  • The exact brand, model, and firmware version of the device in question
  • Datasheets and configuration manuals
  • Protocol, API, and payload documentation
  • Administrative access and a vendor contact, where relevant
  • A working test device, when physical testing is needed
  • Remote access, if a live connection attempt is required

Skipping any of these does not stop the assessment from happening, but it usually stretches the timeline out.

Five Honest Outcomes, Not One Optimistic One

What makes this service worth paying for is that it does not promise a yes. Every assessment ends in one of five clearly labeled outcomes: Ready for direct connection, API Ready through a documented vendor interface, Gateway Ready via a converter, Conditional pending vendor cooperation or firmware work, or Not Currently Compatible due to insufficient access, documentation, or a safe connection route.

That last category matters as much as the first. A report that says a device will not work right now, and explains exactly why, saves far more money than a vague assurance that everything will probably be fine. It also gives a technical team something concrete to bring back to a vendor, rather than a shrug.

Turnaround runs five to ten business days once all required information and equipment are in hand, and the assessment fee applies regardless of which of the five outcomes comes back. That detail is worth stating plainly rather than burying in fine print: the value of the service is the clarity itself, not a guaranteed green light.

Where This Fits Into a Bigger Decision

Not every organisation needs this service. A team that already knows its device inventory speaks MQTT or REST and has the documentation to prove it can likely skip straight to integration. But for anyone standing at the start of a deployment with a mix of legacy equipment, newly purchased sensors, and a deadline that assumes everything will just work, an assessment starting at RM2,500 is a small line item compared to the cost of finding out the hard way, mid-project, that a device was never going to connect at all.

Organisations weighing a new IoT deployment, or trying to make sense of equipment they already own, are welcome to reach out to FAVORIOT‘s professional services team (or contact info@favoriot.com ) to see whether this is the right first step.

Copyright © 2026 All rights reserved