Code Monkey home page Code Monkey logo

esp32-thingsboard-sht40's Introduction

Monitoring SHT4x Sensor Data with ESP32 and ThingsBoard

This project involves an IoT application that uses ESP32 and the ThingsBoard platform to collect data from an SHT4x temperature and humidity sensor and send this data to a ThingsBoard server.

Required Libraries

#include <ThingsBoard.h>
#include <Arduino_MQTT_Client.h>
#include <WiFiClient.h>
#include <ArduinoJson.h>
#include "Adafruit_SHT4x.h"

This section includes the libraries required for the project. ThingsBoard.h, Arduino_MQTT_Client.h, and WiFiClient.h are necessary for connecting your IoT device to the ThingsBoard server over the internet. ArduinoJson.h is used for data processing and MQTT messages. Adafruit_SHT4x.h is the library required to interact with the SHT4x sensor.

Settings and Constants

#define WIFI_AP_NAME        "Vodafonenet_Wifi_8047"
#define WIFI_PASSWORD       "U5DerrGGDUEz"
#define TOKEN               "pHYZ7VkKvoxTOyy6LDc1"
#define THINGSBOARD_SERVER  "demo.thingsboard.io"

constexpr uint16_t MAX_MESSAGE_SIZE = 128;
constexpr uint16_t THINGSBOARD_PORT = 1883;

This section defines settings like the name and password of the WiFi network, and the ThingsBoard server and connection port.

Global Variables

WiFiClient espClient;
Arduino_MQTT_Client mqttClient(espClient);
ThingsBoard tb(mqttClient, MAX_MESSAGE_SIZE);
int status = WL_IDLE_STATUS;

Adafruit_SHT4x sht4 = Adafruit_SHT4x();

Here, variables required for the WiFi and MQTT client, ThingsBoard object, and SHT4x sensor are defined.

Helper Functions and Structures

Functions like InitWiFi, reconnect, shtBegin, and readTemperatureAndHumidity are used for initiating WiFi connection, reconnecting, initializing the SHT4x sensor, and reading temperature and humidity data from the sensor, respectively. The SHT40Data structure is defined to store temperature and humidity data.

Main Functions

setup and loop are the main functions. The setup function runs once when the program starts and does the necessary initial setups. The loop function runs continuously and reads sensor data and sends it to ThingsBoard.

esp32-thingsboard-sht40's People

Contributors

mustafaayilmas avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.