ESP32 Sensor Data Transmission Sample

What We’ll Do

  • Create a sample that sends data using a temperature and humidity sensor and creates graphs. For a simple sample code using temperature and humidity API, see here.

Required Items

  • ESP32
  • USB cable (for data transfer)
  • Temperature and humidity sensor (DHT11, etc.)
  • Jumper wires
  • Breadboard (optional)

Steps

  1. Set up ESP32 development environment (PlatformIO)
  2. Connect/read temperature and humidity sensor
  3. Run data transmission sample
  4. Verify data transmission and create graphs
  5. (Bonus) Configure OTA updates

1. Set Up ESP32 Development Environment (PlatformIO)

Set up ESP32 development environment using PlatformIO.

Install PlatformIO

  1. Download and install PlatformIO IDE
    • Installing as a Visual Studio Code extension is recommended
  2. Launch Visual Studio Code and verify that PlatformIO extension is enabled

Create Project

  1. Select “New Project” from PlatformIO home screen
  2. Enter project name (e.g., esp32-miniviz)
  3. Select “ESP32 Dev Module” as Board
  4. Select “Arduino” as Framework
  5. Create project
  6. (Set baud rate to 115200)

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

Add Required Libraries

Add required libraries to the project’s platformio.ini file.

2. Connect/Read Temperature and Humidity Sensor

Sensor Connection

Connect a temperature and humidity sensor such as DHT11 to ESP32.

DHT11 Connection Example:

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

3. Run Data Transmission Sample

Create ESP32 code to send data to Miniviz API.

Create Code

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

-> See ESP32 Sample Code.

Build and Upload

  1. Connect ESP32 to PC with USB cable
  2. Run the following command from PlatformIO terminal:
  3. Check operation with serial monitor:

4. Verify Data Transmission and Create Graphs

Verify Data Transmission

  1. Log in to Miniviz web interface
  2. Check sent data from Database menu
  3. Verify that temperature and humidity data is displayed

DATA_BASE_ESP32

Create Graphs

  1. Create graphs from Visualize menu
  2. Select graph type (line chart recommended)
  3. Select temperature and humidity as data sources
  4. Verify that graphs are displayed correctly

For details, see “5. Create Charts” in Quick Start.


This site uses Just the Docs, a documentation theme for Jekyll.