By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
Viral Trending contentViral Trending content
  • Home
  • World News
  • Politics
  • Sports
  • Celebrity
  • Business
  • Crypto
  • Gaming News
  • Tech News
  • Travel
Reading: ESP32 Temperature & Humidity Sensor Monitoring Using Grafana
Notification Show More
Viral Trending contentViral Trending content
  • Home
  • Categories
    • World News
    • Politics
    • Sports
    • Celebrity
    • Business
    • Crypto
    • Tech News
    • Gaming News
    • Travel
  • Bookmarks
© 2024 All Rights reserved | Powered by Viraltrendingcontent
Viral Trending content > Blog > Gaming News > ESP32 Temperature & Humidity Sensor Monitoring Using Grafana
Gaming News

ESP32 Temperature & Humidity Sensor Monitoring Using Grafana

By Viral Trending Content 9 Min Read
Share
SHARE

By Adrelien
in
ESP32
—
Mar 5, 2025

Contents
Hardware RequirementsSoftware RequirementsStep 1: Setting Up Your Development EnvironmentInstalling ESP32 Board SupportInstalling Required LibrariesStep 2: Wiring the BME280 Sensor to ESP32Step 3: Setting Up Telemetry HarborStep 4: Uploading and Testing the CodeStep 5: Visualizing Data with Telemetry HarborConclusion

The ESP32 is a powerful microcontroller with built-in Wi-Fi, making it an excellent choice for IoT projects. In this guide, we will walk you through how to collect temperature data from a BME280 sensor, send it to the cloud using Telemetry Harbor, and visualize it using a Grafana dashboard.

ESP32 Temperature & Humidity Sensor Monitoring Using Grafana

Imagine having real-time insights into temperature changes, accessible from anywhere in the world. With an ESP32 and a BME280 sensor, you can build a smart, cloud-connected monitoring system that logs environmental data and visualizes it dynamically.

In this project, you’ll configure an ESP32 to read temperature data from a BME280 sensor and transmit it to Telemetry Harbor, a powerful IoT data platform. From there, the data is stored, processed, and displayed on a Grafana dashboard, giving you a live view of temperature trends. Whether you’re tracking climate conditions, monitoring sensitive equipment, or just experimenting with IoT, this setup provides a scalable foundation for automation, alerts, and advanced analytics.

By the end of this guide, you’ll have a fully functional system that not only logs temperature readings but also lays the groundwork for expanding your IoT network with more sensors, automated triggers, and cloud-based intelligence. Let’s dive in!

Hardware Requirements

Software Requirements

  • Arduino IDE (1.8.13 or newer) or PlatformIO
  • Required libraries: 
    • Adafruit BME280 Library 
    • Adafruit Unified Sensor 
    • WiFi Library (built into ESP32 core) 
    • HTTPClient Library (built into ESP32 core)
  • Telemetry Harbor account (free tier available)

Step 1: Setting Up Your Development Environment

Installing ESP32 Board Support

  1. Open Arduino IDE
  2. Go to File > Preferences
  3. Add the following URL to the “Additional Boards Manager URLs” https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
  4. Go to Tools > Board > Boards Manager
  5. Search for “ESP32” and install the ESP32 by Espressif Systems

Installing Required Libraries

  1. Go to Sketch > Include Library > Manage Libraries
  2. Search for and install:
    • Adafruit BME280 Library
    • Adafruit Unified Sensor

Step 2: Wiring the BME280 Sensor to ESP32

The BME280 uses the I2C communication protocol, which requires just four connections:

BME280 Pin ESP32 Pin Function
VCC 3.3V Power
GND GND Ground
SDA GPIO 21 Data
SCL GPIO 22 Clock

Step 3: Setting Up Telemetry Harbor

Telemetry Harbor provides a straightforward platform for collecting, storing, and visualizing IoT sensor data. Follow these steps to set up your account:

  1. Create an Account:
  2. Create a New Harbor:
    • From your dashboard, click Create New Harbor
    • Name it something descriptive like “ESP32_Environmental_Monitor“
    • Select the harbor type as General and Specification Free
  3. Generate an API Key:
    • Navigate to “View Details” for your created harbor
    • Click “View API Key“
    • Copy and save your API Key securely – you’ll need it for your ESP32 code
    • Note your Harbor ID from the API Endpoint

Step 4: Uploading and Testing the Code

#include 
#include 
#include 
#include 
#include 
#include  // For NTP time

// WiFi credentials
const char* ssid = "WIFI_SSID";
const char* password = "WIFI_PASSWORD";

// Telemetry Harbor API info
const String apiUrl = "https://telemetryharbor.com/api/v1/ingest/ingest/Harbor_ID";
const String apiKey = "API_KEY";
const String shipId = "Living Room";

// BME280 setup
Adafruit_BME280 bme; // I2C
#define SEALEVELPRESSURE_HPA (1013.25)

// LED setup
const int ledPin = 2; // Use built-in LED on most ESP32 boards (usually GPIO 2)

// NTP setup
const char* ntpServer = "pool.ntp.org";
const long gmtOffset_sec = 0; // Adjust this for your timezone offset
const int daylightOffset_sec = 0;

// Time management
unsigned long previousMillis = 0;
const unsigned long intervalMillis = 60000; // 1-second interval

// Function to flash the LED
void flashLED(int times, int delayMs) {
  for (int i = 0; i = intervalMillis) {
    previousMillis = currentMillis;


    const float temperatureOffset = 0; // Adjust temperature by -3°C
    const float humidityOffset = 0;    // Adjust humidity by +7.2%
    // Read temperature and humidity
    float temperature = bme.readTemperature() + temperatureOffset;
    float humidity = bme.readHumidity() + humidityOffset;

    // Get current time in ISO8601 format
    time_t now = time(NULL);
    struct tm timeinfo;
    gmtime_r(&now, &timeinfo); // Convert to UTC time structure

    char timeBuffer[30];
    strftime(timeBuffer, sizeof(timeBuffer), "%Y-%m-%dT%H:%M:%SZ", &timeinfo); // Format time

    // Create JSON payload for temperature
    String tempJsonPayload = "{";
    tempJsonPayload += ""time": "" + String(timeBuffer) + "",";
    tempJsonPayload += ""ship_id": "" + shipId + "",";
    tempJsonPayload += ""cargo_id": "Temperature",";
    tempJsonPayload += ""value": " + String(temperature, 2);
    tempJsonPayload += "}";

    // Create JSON payload for humidity
    String humidityJsonPayload = "{";
    humidityJsonPayload += ""time": "" + String(timeBuffer) + "",";
    humidityJsonPayload += ""ship_id": "" + shipId + "",";
    humidityJsonPayload += ""cargo_id": "Humidity",";
    humidityJsonPayload += ""value": " + String(humidity, 2);
    humidityJsonPayload += "}";

    // Send temperature data to API
    HTTPClient http;
    http.begin(apiUrl);
    http.addHeader("X-API-Key", apiKey);
    http.addHeader("Content-Type", "application/json");

    int tempResponseCode = http.POST(tempJsonPayload);
    if (tempResponseCode > 0) {
      Serial.println("Temperature data sent successfully! Response:");
      Serial.println(http.getString());
      flashLED(1, 300); // Flash LED for successful API request
    } else {
      Serial.print("Error sending temperature data. HTTP Response code: ");
      Serial.println(tempResponseCode);
    }
    http.end();

    // Send humidity data to API
    http.begin(apiUrl); // Reinitialize HTTPClient for humidity request
    http.addHeader("X-API-Key", apiKey);
    http.addHeader("Content-Type", "application/json");

    int humidityResponseCode = http.POST(humidityJsonPayload);
    if (humidityResponseCode > 0) {
      Serial.println("Humidity data sent successfully! Response:");
      Serial.println(http.getString());
      flashLED(1, 300); // Flash LED for successful API request
    } else {
      Serial.print("Error sending humidity data. HTTP Response code: ");
      Serial.println(humidityResponseCode);
    }
    http.end();
  }
}
  1. Select the Correct Board:
    • Go to Tools > Board and select your ESP32 board model
    • Select the correct COM port under Tools > Port
  2. Configure the Code:
    • Replace the WiFi SSID and password with your network credentials
    • Update the Telemetry Harbor API URL and API key with your account details
    • Adjust the sensor reading interval if needed (default is 60 seconds)
  3. Upload the Code:
    • Click the Upload button (→) in Arduino IDE
    • Wait for the compilation and upload to complete
  4. Verify Operation:
    • Open the Serial Monitor (Tools > Serial Monitor) set to 115200 baud
    • Check for successful WiFi connection and sensor initialization
    • Confirm data is being sent to Telemetry Harbor

Step 5: Visualizing Data with Telemetry Harbor

Once your ESP32 begins transmitting data, you can create powerful visualizations in Telemetry Harbor through its integrated Grafana dashboards:

  1. Access Grafana Credentials:
    • Go back to the Harbor Details page
    • Copy the Grafana Password shown on this page
    • Click on the Grafana Endpoint link provided
  2. Login to Grafana:
    • Use your Grafana Username (this will be the same as your Telemetry Harbor email)
    • Enter the Grafana Password you copied earlier
  3. Navigate to Dashboards:
    • In the left sidebar, click on Dashboards
    • Select the Comprehensive Telemetry Dashboard (this is the demo dashboard provided by Telemetry Harbor)
  4. Configure Your Dashboard View:
    • Choose your data source (which will be your harbor)
    • Use the filters to view data based on ship_id and cargo_id
    • Select appropriate time ranges to view your sensor history

Conclusion

Your ESP32 is now up and running with the BME280 sensor, streaming live temperature data to Telemetry Harbor. With this setup, you can keep an eye on environmental changes in real time. Want to take it further? Try adding more sensors, setting up alerts for temperature spikes, or even building a full monitoring system. The possibilities are endless.

You Might Also Like

Cult Hit Doki Doki Literature Club Fights Removal From Google Play Store Over ‘Depiction Of Sensitive Themes’

Dead as Disco Launches Into Early Access on May 5th, Groovy New Gameplay Released

Don’t Starve Elsewhere, A New Addition to Klei’s Survival Franchise, Announced for PC

A new Borderlands game just dropped, and it's free

Metal Gear Solid Film Greenlit By Sony, First Look in the Works

TAGGED: Game With PC, pc, xbox
Share This Article
Facebook Twitter Copy Link
Previous Article Thailand’s visa-free stay will soon be cut to 30 days. Here’s what it means for tourists
Next Article Dogecoin Price Recovery Imminent: Key Chart Pattern Hints At A Potential Uptrend
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

- Advertisement -
Ad image

Latest News

JPMorgan CEO Jamie Dimon says he’s ‘learned and relearned’ to not make big decisions when he’s tired on Fridays
Business
Apple AI Pin Specs Leak: Dual Cameras, No Screen & More
Tech News
A ‘glass-like’ battlefield: German Army chief on the future of warfare
World News
Polymarket Sees Record $153M Daily Volume After Chainlink Integration
Crypto
Natasha Lyonne Then & Now: See Before & After Photos of the Actress Here
Celebrity
Cult Hit Doki Doki Literature Club Fights Removal From Google Play Store Over ‘Depiction Of Sensitive Themes’
Gaming News
Dead as Disco Launches Into Early Access on May 5th, Groovy New Gameplay Released
Gaming News

About Us

Welcome to Viraltrendingcontent, your go-to source for the latest updates on world news, politics, sports, celebrity, tech, travel, gaming, crypto news, and business news. We are dedicated to providing you with accurate, timely, and engaging content from around the globe.

Quick Links

  • Home
  • World News
  • Politics
  • Celebrity
  • Business
  • Home
  • World News
  • Politics
  • Sports
  • Celebrity
  • Business
  • Crypto
  • Gaming News
  • Tech News
  • Travel
  • Sports
  • Crypto
  • Tech News
  • Gaming News
  • Travel

Trending News

cageside seats

Unlocking the Ultimate WWE Experience: Cageside Seats News 2024

Investing £5 a day could help me build a second income of £329 a month!

JPMorgan CEO Jamie Dimon says he’s ‘learned and relearned’ to not make big decisions when he’s tired on Fridays

cageside seats
Unlocking the Ultimate WWE Experience: Cageside Seats News 2024
May 22, 2024
Investing £5 a day could help me build a second income of £329 a month!
March 27, 2024
JPMorgan CEO Jamie Dimon says he’s ‘learned and relearned’ to not make big decisions when he’s tired on Fridays
April 10, 2026
Brussels unveils plans for a European Degree but struggles to explain why
March 27, 2024
© 2024 All Rights reserved | Powered by Vraltrendingcontent
  • About Us
  • Contact US
  • Disclaimer
  • Privacy Policy
  • Terms of Service
Welcome Back!

Sign in to your account

Lost your password?