How to Send ESP32 Sensor Data to Miniviz for Real-time Visualization(Miniviz #1)
Yoshida.T

Yoshida.T @yoshidataisei

Joined:
Nov 27, 2025

How to Send ESP32 Sensor Data to Miniviz for Real-time Visualization(Miniviz #1)

Publish Date: Nov 30
0 0

What is Miniviz?

Miniviz is a BI platform developed for individuals to accelerate IoT PoC (Proof of Concept). It enables you to easily achieve data transmission, storage, visualization, and notifications all in one place.

The main features are:

  • Database functionality
  • Graph/chart functionality
  • External alert functionality

https://miniviz.net/

What We'll Build

In this tutorial, we'll create a sample project that sends data from a temperature and humidity sensor and creates graphs to visualize the data.

What You'll Need

  • ESP32
  • USB cable (for data transfer)
  • Temperature and humidity sensor (DHT11 or similar)
  • Jumper wires
  • Breadboard (optional)

Steps

  1. Set up ESP32 development environment (PlatformIO)
  2. Connect sensor and implement source code (read temperature/humidity and send data)
  3. Verify data transmission, create graphs, and set up notifications

1. ESP32 Development Environment Setup (PlatformIO)

We'll set up the ESP32 development environment using PlatformIO as a VS Code extension.

  1. Download and install PlatformIO IDE
  2. It's recommended to install it as a Visual Studio Code extension
  3. Launch Visual Studio Code and verify that the PlatformIO extension is enabled
  4. Create a new project
  • Select "New Project" from the PlatformIO home screen
  • Enter a project name (e.g., esp32-miniviz)
  • Select "ESP32 Dev Module" as the board
  • Select "Arduino" as the framework

Example platformio.ini File

[env:esp32doit-devkit-v1]
platform = espressif32
board = esp32doit-devkit-v1
framework = arduino
lib_deps = adafruit/DHT sensor library@^1.4.6
monitor_speed = 115200
Enter fullscreen mode Exit fullscreen mode

Adding the DHT Library

The DHT sensor library for temperature and humidity sensors is imported in the configuration above.

2. Sensor Connection and Source Code Implementation

Sensor Connection

Connect a temperature and humidity sensor like DHT11 to the ESP32.

DHT11 Connection Example:

DHT11              ESP32
------             ----------------
(1) VCC  --------> 3.3V
(2) DATA --------> GPIO4
(3) NC   --------> -
(4) GND  --------> GND
Enter fullscreen mode Exit fullscreen mode

Wiring Example

Here's a visual reference (apologies for the image quality):

Running the Data Transmission Sample

We'll create ESP32 code to send data to the Miniviz API.

The source code is provided at the end of this article.

Getting Project ID and Token

Create a Miniviz account -> Create a project -> Get your project ID and token

For more details, check the Quick Start Guide

Source Code Implementation and Build

Write the following content in the src/main.cpp file (replace PROJECT_ID and TOKEN with your actual values).

Build and upload the code. Verify in the serial monitor that the POST request is successful.

The sample code is provided at the end of this article.

3. Verify Data Transmission and Create Graphs

Verify Data Transmission

Open the Database in the sidebar, and you should see the parsed data displayed.

Create Graphs

  • Create a graph from the Visualize menu
  • Select a graph type (line chart is recommended)
  • Select temperature and humidity as data sources
  • Verify that the graph displays correctly

Get Notifications via Slack and Email!

Miniviz also has an external alert feature, so you can set up notifications as needed!

Source Code

The transmission interval is set to 90 seconds.

#include <Arduino.h>
#include <DHT.h>
#include <WiFi.h>
#include <HTTPClient.h>

//----------------------------------------
// Configuration
//----------------------------------------
const int PIN_DHT = 4;
DHT dht(PIN_DHT, DHT11);

const char *ssid = "WIFI_SSID";
const char *password = "WIFI_PASSWORD";

// Miniviz API
const char *project_id = "MINIVIZ_PROJECT_ID";
const char *token = "MINIVIZ_API_TOKEN";

String endpoint = String("https://api.miniviz.net/api/project/") +
                  project_id + "?token=" + token;

// Deep Sleep (90 seconds)
const uint64_t SLEEP_INTERVAL_US = 90ULL * 1000000ULL;


//----------------------------------------
// Wi-Fi Connection
//----------------------------------------
void connectWiFi()
{
  Serial.println("Connecting to Wi-Fi...");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  int retry = 0;
  while (WiFi.status() != WL_CONNECTED && retry < 30) {
    delay(300);
    Serial.print(".");
    retry++;
  }
  Serial.println();

  if (WiFi.status() == WL_CONNECTED) {
    Serial.println("Wi-Fi connected");
  } else {
    Serial.println("Wi-Fi connection failed");
  }
}

//----------------------------------------
// NTP Time Synchronization
//----------------------------------------
void syncTime()
{
  Serial.println("Syncing NTP...");
  configTime(0, 0, "ntp.nict.jp", "time.google.com");

  struct tm timeinfo;
  while (!getLocalTime(&timeinfo)) {
    delay(200);
    Serial.print("*");
  }
  Serial.println("\nTime synced");
}

//----------------------------------------
// UNIX Timestamp in Milliseconds
//----------------------------------------
uint64_t getTimestampMs()
{
  struct timeval tv;
  gettimeofday(&tv, NULL);
  return (uint64_t)tv.tv_sec * 1000ULL + (tv.tv_usec / 1000ULL);
}

//----------------------------------------
// POST to Miniviz
//----------------------------------------
void sendToMiniviz(float temp, float humid)
{
  if (WiFi.status() != WL_CONNECTED)
    connectWiFi();

  HTTPClient http;
  http.begin(endpoint);
  http.addHeader("Content-Type", "application/json");

  uint64_t ts = getTimestampMs();

  String body = "{";
  body += "\"timestamp\":" + String(ts) + ",";
  body += "\"label_key\":\"esp32_home\",";
  body += "\"payload\":{";
  body += "\"temperature\":" + String(temp) + ",";
  body += "\"humidity\":" + String(humid);
  body += "}}";

  int code = http.POST(body);
  Serial.println("HTTP code: " + String(code));
  Serial.println(http.getString());
  http.end();
}

//----------------------------------------
// Setup
//----------------------------------------
void setup()
{
  Serial.begin(115200);
  delay(200);

  dht.begin();
  connectWiFi();
  syncTime();
}

//----------------------------------------
// Loop (exits after one iteration due to DeepSleep)
//----------------------------------------
void loop()
{
  float t = dht.readTemperature();
  float h = dht.readHumidity();

  Serial.printf("Temperature: %.2f°C  Humidity: %.2f%%\n", t, h);

  sendToMiniviz(t, h);

  Serial.println("Entering deep sleep...");
  esp_deep_sleep(SLEEP_INTERVAL_US);
}
Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment