Jump to content
Electronics-Lab.com Community

Search the Community

Showing results for tags 'espressif'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Electronics Forums
    • Projects Q/A
    • Datasheet/Parts requests
    • Electronic Projects Design/Ideas
    • Power Electronics
    • Service Manuals
    • Theory articles
    • Electronics chit chat
    • Microelectronics
    • Electronic Resources
  • Related to Electronics
    • Spice Simulation - PCB design
    • Inventive/New Ideas
    • Mechanical constructions/Hardware
    • Sell/Buy electronics - Job offer/requests
    • Components trade
    • High Voltage Stuff
    • Electronic Gadgets
  • General
    • Announcements
    • Feedback/Comments
    • General
  • Salvage Area

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Yahoo


Skype


Location


Interests

Found 4 results

  1. Introduction The ESP32 is a versatile and inexpensive microcontroller that has taken the hobbyist and professional world by storm. It’s a powerful tool with built-in Wi-Fi and Bluetooth capabilities, making it an ideal choice for Internet of Things (IoT) projects. One of its many features is the ability to communicate over serial, which can be extended to the web using WebSerial. This blog post will delve into setting up an ESP32 with WebSerial. Understanding WebSerial WebSerial is a web standard that allows websites to communicate with serial devices. It bridges the web and the physical world, enabling web applications to interact with hardware devices. This opens up a world of possibilities for IoT projects, allowing real-time interaction between web applications and physical devices. Get PCBs for Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Also, check out this useful blog on PCBWay Plugin for KiCad from here. Using this plugin, you can directly order PCBs in just one click after completing your design in KiCad. Setting Up the ESP32 Before we can use WebSerial with the ESP32, we need to set up the ESP32 development environment. Here are the steps: Install the Arduino IDE: The Arduino IDE is a popular platform for writing and uploading code to the ESP32. You can download it from the official Arduino website. Install the ESP32 Board in Arduino IDE: You can add the ESP32 board to the Arduino IDE by going to File > Preferences > Additional Boards Manager URLs and adding the ESP32 board manager URL. This will allow the Arduino IDE to recognize the ESP32 board and provide the appropriate options for programming it. Select the ESP32 Board: Go to Tools > Board > ESP32 Arduino and select your ESP32 board. This tells the Arduino IDE that you will be programming an ESP32 board. Install WebSerial for ESP32 Next, we need to install the WebSerial library. Here’s how: Go to Sketch > Include Library > Manage Libraries. In the search bar, type WebSerial. Click Install. Programming the ESP32 for WebSerial Once the ESP32 is set up, we can write a program to enable WebSerial communication. Here’s a simple example: /* WebSerial Demo ------ This example code works for both ESP8266 & ESP32 Microcontrollers WebSerial is accessible at your ESP's <IPAddress>/webserial URL. Author: Ayush Sharma Checkout WebSerial Pro: https://webserial.pro */ #include <Arduino.h> #if defined(ESP8266) #include <ESP8266WiFi.h> #include <ESPAsyncTCP.h> #elif defined(ESP32) #include <WiFi.h> #include <AsyncTCP.h> #endif #include <ESPAsyncWebServer.h> #include <WebSerial.h> #define Relay 2 AsyncWebServer server(80); const char* ssid = "ELDRADO"; // Your WiFi SSID const char* password = "amazon123"; // Your WiFi Password /* Message callback of WebSerial */ void recvMsg(uint8_t *data, size_t len){ WebSerial.println("Received Data..."); String d = ""; for(int i=0; i < len; i++){ d += char(data[i]); } WebSerial.println(d); if (d == "ON"){ digitalWrite(Relay, HIGH); } if (d=="OFF"){ digitalWrite(Relay, LOW); } } void setup() { Serial.begin(115200); pinMode(Relay, OUTPUT); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); if (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.printf("WiFi Failed!\n"); return; } Serial.print("IP Address: "); Serial.println(WiFi.localIP()); // WebSerial is accessible at "<IP Address>/webserial" in browser WebSerial.begin(&server); /* Attach Message Callback */ WebSerial.msgCallback(recvMsg); server.begin(); } void loop() { } in this above sketch, I have added a relay control part with GPIO Pin2, if the serial input data is "ON" the really will on if it's "OFF" it will turn off the relay. Once you upload the code to ESP32, look for the serial terminal to know the IP address of the ESP32. In my case here is the response. Final Results Open the IP with /WebSerial in the end. In this type ON and OFF and look at the ESP32. Conclusion The ESP32 with WebSerial opens up a world of possibilities for IoT projects. By bridging the gap between the web and the physical world, we can create interactive, real-time applications that communicate with hardware devices. Whether you’re a hobbyist or a professional developer, the ESP32 with WebSerial is a powerful tool in your IoT toolkit. With this detailed guide, you should now have a solid understanding of how to set up and use the ESP32 with WebSerial. Happy coding!
  2. Cryptocurrency: A New Era of Money Money is one of the most important inventions in human history. It is a medium of exchange, a store of value, and a unit of account. Money enables trade, commerce, and economic growth. However, money also has its limitations and challenges. For example, money can be counterfeited, stolen, or inflated. To overcome these problems, some people have invented a new form of money: cryptocurrency. Cryptocurrency is a type of digital currency that uses cryptography to secure and verify transactions. Cryptocurrency is decentralized, meaning that it is not controlled by any central authority or government. Cryptocurrency transactions are recorded on a distributed ledger called a blockchain, which ensures transparency and immutability. Some examples of cryptocurrencies are: Bitcoin: The first and most popular cryptocurrency, created in 2009 by an anonymous person or group using the pseudonym Satoshi Nakamoto. Bitcoin has a limited supply of 21 million coins and uses a proof-of-work algorithm to validate transactions and create new blocks. Ethereum: A platform that allows developers to create decentralized applications (dApps) and smart contracts using its native cryptocurrency, ether. Ethereum uses a proof-of-stake algorithm to secure its network and enable faster transactions. Cryptocurrencies have many advantages over traditional money. They are: Secure: Cryptocurrencies use cryptography to protect transactions from fraud and hacking. Cryptocurrencies also have no single point of failure, as they are distributed across many nodes on the network. Transparent: Cryptocurrencies allow anyone to view the history and details of every transaction on the blockchain. Cryptocurrencies also have no hidden fees or charges, as they are based on peer-to-peer transactions. Inclusive: Cryptocurrencies enable anyone with an internet connection and a digital wallet to access the global financial system. Cryptocurrencies also have no barriers to entry or discrimination, as they are open to anyone regardless of their identity or location. Innovative: Cryptocurrencies foster innovation and creativity, as they allow developers to create new applications and services using blockchain technology. Cryptocurrencies also have the potential to disrupt various industries and sectors, such as banking, e-commerce, healthcare, education, and more. Cryptocurrencies are not without challenges and risks, however. They are: Volatile: Cryptocurrencies are subject to high price fluctuations due to supply and demand dynamics, market sentiment, regulatory uncertainty, and technical issues. Cryptocurrencies can also be affected by external factors, such as geopolitical events, cyberattacks, media coverage, and public opinion. Complex: Cryptocurrencies require a steep learning curve for users to understand how they work and how to use them safely and effectively. Cryptocurrencies also involve technical jargon and concepts that may be confusing or intimidating for beginners. Unregulated: Cryptocurrencies operate in a legal gray area, as they are not recognized or regulated by most governments and authorities. Cryptocurrencies may face legal restrictions or bans in some areas, which may limit their adoption and usage. Cryptocurrencies may also pose ethical and social issues, such as tax evasion, money laundering, terrorism financing, and environmental impact. Cryptocurrency is a new era of money that offers many opportunities and challenges for the future. Cryptocurrency is not just a technology or a currency; it is a social phenomenon that reflects the values and aspirations of its users. Cryptocurrency is not perfect or flawless; it is an experiment that evolves and improves over time. Cryptocurrency is not for everyone or everything; it is a choice that depends on one’s preferences and needs. Get PCBs For Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Crypto mining: It is the process of creating new units of cryptocurrency by solving complex mathematical problems. Crypto mining is essential for securing and verifying transactions on the blockchain, which is a distributed ledger that records the history and details of every transaction. Crypto mining also rewards miners with newly minted coins, which increases the supply and circulation of cryptocurrency. There are several types of crypto mining, depending on the algorithm and consensus mechanism used by the cryptocurrency network. The most common type is proof-of-work (PoW) mining, which requires miners to use their computing power to compete to find the solution to a cryptographic puzzle. The first miner who solves the puzzle gets to add a new block to the blockchain and claim the block reward. Some examples of cryptocurrencies that use PoW mining are Bitcoin, Ethereum, Litecoin, and Monero. Another type of crypto mining is proof-of-stake (PoS) mining, which requires miners to stake a certain number of coins to participate in the validation process. PoS mining does not involve solving puzzles but rather selecting validators based on their stake and other factors. Validators then take turns to propose and confirm new blocks and receive rewards based on their stake and performance. Some examples of cryptocurrencies that use PoS mining are Cardano, Polkadot, Binance Coin, and Tezos. Crypto mining can be profitable or unprofitable, depending on several factors such as the price of the cryptocurrency, the difficulty of the mining algorithm, the cost of electricity and hardware, and the competition from other miners. Crypto mining can also have environmental and social impacts, such as energy consumption, carbon emissions, waste generation, noise pollution, and regulatory issues. If you want to mine cryptocurrency, you will need some specialized hardware that can perform complex calculations and consume a lot of electricity. There are several types of hardware for mining different cryptocurrencies, but the most common ones are ASIC (application-specific integrated circuit) devices, which are designed to mine a specific algorithm or coin. Some of the best ASIC devices for mining cryptocurrency in 2023 are: Antminer S19 Pro: This is one of the most powerful and efficient Bitcoin mining hardware, with a hash rate of 110 TH/s and a power consumption of 3,250 W. WhatsMiner M30S++: This is another top Bitcoin mining hardware, with a hash rate of 112 TH/s and a power consumption of 3,472 W. AvalonMiner 1246: This is heavy-duty Bitcoin mining hardware, with a hash rate of 90 TH/s and a power consumption of 3,420 W. WhatsMiner M32-62T: This is a new Bitcoin mining hardware, with a hash rate of 62 TH/s and a power consumption of 3,360 W. You can see these are some of the high-power and costly miners, also their power consumption is extremely high. In this tutorial, you will see how to mine crypto with low-power ESP32 microcontrollers. Duco Coin: A Simple and Eco-Friendly Crypto Coin Duco coin is a unique crypto coin that can be mined using low-powered devices, such as Arduino boards, ESP32, Raspberry Pi, and even old computers. Duco coin aims to provide a simple, accessible, and eco-friendly way of participating in the crypto world, without the need for expensive and energy-intensive hardware. Duco coin uses its own blockchain and consensus algorithm, called DUCO-S1, which is based on SHA-1. DUCO-S1 is designed to be fast, secure, and adaptable to different devices and mining methods. Duco coin also uses a reward system called theKolka system, which adjusts the mining difficulty and rewards based on the device’s performance and network conditions. The Kolka system ensures that low-powered devices have a fair chance of earning coins while preventing abuse and spam. The Duco coin has an infinite supply of coins, but it also has a burning mechanism that reduces circulation by destroying some coins every time a transaction is made. This creates a balance between inflation and deflation and maintains the value of the coin. The Duco coin also has no transaction fees, as the miners are rewarded by the Kolka system. The Duco coin is a crypto coin that offers many advantages over traditional coins. It is: Simple: Duco coin is easy to mine, use, and understand. It does not require any complex setup or configuration. It also has a user-friendly web wallet and a mobile app that allows users to manage their funds and transactions. Eco-friendly: Duco coin is environmentally friendly, as it uses low-powered devices that consume minimal electricity and generate less heat and noise. It also reduces electronic waste by giving new life to old devices. Inclusive: Duco coin is inclusive, as it enables anyone with an internet connection and a cheap device to join the crypto world. It also has no barriers to entry or discrimination, as it is open to anyone regardless of their identity or location. Innovative: Duco coin is innovative, as it fosters creativity and experimentation among its users and developers. It also has the potential to disrupt various industries and sectors, such as education, gaming, IoT, and more. Duco coin is a new era of crypto coin that offers simplicity, sustainability, accessibility, and diversity. Duco coin is not just a technology or a currency; it is a community that shares the same vision and values. How to mine Duco coin with ESP32: To mine Duco coin with ESP32, you will need the following steps: Step 1: Register an account on the Duino-Coin website and create a wallet. You will need your username and wallet address for mining. Step 2: Download and install the Arduino IDE and the ESP32 board support package. You will also need to install some libraries, such as WiFiClientSecure, ArduinoJson, and DHT (if you want to use a DHT sensor). Step 3: Download the Duino-Coin ESP32 code from GitHub and open it in the Arduino IDE. Edit the code to enter your Wi-Fi name, password, username, and mining key (if you enabled it in the wallet). You can also change the rig identifier and the LED pin if you want. Step 4: Connect your ESP32 board to your computer via a USB cable and select the correct port and board settings in the Arduino IDE. Upload the code to your ESP32 board and wait for it to connect to the Duino-Coin server. Step 5: You can monitor your mining status and earnings on the Duino-Coin web wallet or the mobile app. You can also use the serial monitor in the Arduino IDE to see the debug messages from your ESP32 board. That’s it! You are now mining Duco coin with your ESP32 board. You can also use multiple ESP32 boards or other devices, such as Arduino, Raspberry Pi, or PC, to increase your hash rate and earnings. However, be aware of the Kolka system, which adjusts the mining difficulty and rewards based on your device’s performance and network conditions.
  3. ESP-NOW is a wireless communication protocol based on the data-link layer that enables the direct, quick, and low-power control of smart devices without the need for a router. Espressif defines it and can work with Wi-Fi and Bluetooth LE. ESP-NOW provides flexible and low-power data transmission to all interconnected devices. It can also be used as an independent protocol that helps with device provisioning, debugging, and firmware upgrades. ESP-NOW is a connectionless communication protocol developed by Espressif that features short packet transmission. This protocol enables multiple devices to talk to each other in an easy way. It is a fast communication protocol that can be used to exchange small messages (up to 250 bytes) between ESP32 or ESP8266 boards. ESP-NOW supports the following features: Encrypted and unencrypted unicast communication; Mixed encrypted and unencrypted peer devices; Up to 250-byte payload can be carried; Sending callback function that can be set to inform the application layer of transmission success or failure. Get PCBs for Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. How is it different from existing protocols? ESP-NOW is a wireless communication protocol that is different from Wi-Fi and Bluetooth in that it reduces the five layers of the OSI model to only one1. Additionally, ESP-NOW occupies fewer CPU and flash resources than traditional connection protocols while co-exists with Wi-Fi and Bluetooth LE. Bluetooth is used to connect short-range devices for sharing information, while Wi-Fi is used for providing high-speed internet access2. Wi-Fi provides high bandwidth because the speed of the internet is an important issue. Max Distance: The range of ESP-NOW is up to 480 meters when using the ESP-NOW protocol for bridging between multiple ESP32s1. The range can be further increased by enabling long-range ESP-NOW. When enabled, the PHY rate of ESP32 will be 512Kbps or 256Kbps. Maximum nodes: ESP-NOW supports various series of Espressif chips, providing a flexible data transmission that is suitable for connecting “one-to-many” and “many-to-many” devices. Applications: ESP-NOW is widely used in smart-home appliances, remote controlling, sensors, etc. In this tutorial, will see how to implement a basic ESP NOW communication between ESP32 Microcontrollers. Step: 1 ESPNOW communication works based on the MAC address of the nodes. So, we need to find the Mac address of our slave or receiver node. ]For that just upload the following sketch to the ESP32 board and look for the Mac address in the serial monitor. #include "WiFi.h" void setup(){ Serial.begin(115200); WiFi.mode(WIFI_MODE_STA); Serial.println(WiFi.macAddress()); } void loop(){ } Once you uploaded the code, press the EN button and wait for the serial monitor results. It will show you the Mac address. Note that. Step-2: Next, we need to prepare the transmitter, for that use this example sketch which can send multiple data types of data to the particular slave node. #include <esp_now.h> #include <WiFi.h> // REPLACE WITH YOUR RECEIVER MAC Address uint8_t broadcastAddress[] = {0x94, 0xB5, 0x55, 0x26, 0x27, 0x34}; // Must match the receiver structure typedef struct struct_message { char a[32]; int b; float c; bool d; } struct_message; // Create a struct_message called myData struct_message myData; esp_now_peer_info_t peerInfo; // callback when data is sent void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) { Serial.print("\r\nLast Packet Send Status:\t"); Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail"); } void setup() { // Init Serial Monitor Serial.begin(115200); // Set device as a Wi-Fi Station WiFi.mode(WIFI_STA); // Init ESP-NOW if (esp_now_init() != ESP_OK) { Serial.println("Error initializing ESP-NOW"); return; } // Once ESPNow is successfully Init, we will register for Send CB to // get the status of Trasnmitted packet esp_now_register_send_cb(OnDataSent); // Register peer memcpy(peerInfo.peer_addr, broadcastAddress, 6); peerInfo.channel = 0; peerInfo.encrypt = false; // Add peer if (esp_now_add_peer(&peerInfo) != ESP_OK){ Serial.println("Failed to add peer"); return; } } void loop() { // Set values to send strcpy(myData.a, "I'm alive"); myData.b = random(1,20); myData.c = 1.2; myData.d = false; // Send message via ESP-NOW esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData)); if (result == ESP_OK) { Serial.println("Sent with success"); } else { Serial.println("Error sending the data"); } delay(2000); } Here are the serial monitor results, it show sent success but not delivered. Because we don't have the receiver. Let's try to implement the receiver. Step-3: Step-3:d example sketch which can receive the data from the master and it will print that into the serial monitor. #include <esp_now.h> #include <WiFi.h> // Structure example to receive data typedef struct struct_message { char a[32]; int b; float c; bool d; } struct_message; // Create a struct_message called myData struct_message myData; // callback function that will be executed when data is received void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) { memcpy(&myData, incomingData, sizeof(myData)); Serial.print("Bytes received: "); Serial.println(len); Serial.print("Char: "); Serial.println(myData.a); Serial.print("Int: "); Serial.println(myData.b); Serial.print("Float: "); Serial.println(myData.c); Serial.print("Bool: "); Serial.println(myData.d); Serial.println(); } void setup() { // Initialize Serial Monitor Serial.begin(115200); // Set device as a Wi-Fi Station WiFi.mode(WIFI_STA); // Init ESP-NOW if (esp_now_init() != ESP_OK) { Serial.println("Error initializing ESP-NOW"); return; } // get recv packer info esp_now_register_recv_cb(OnDataRecv); } void loop() { } Serial monitor results. Wrap Up: We have seen how to implement the ESP NOW in ESP32 microcontroller, in upcoming tutorials will see how to transmit sensor data via ESPNOW.
  4. What is Qubitro? Qubitro is an IoT (Internet of Things) platform that provides tools and services for connecting, managing, and analyzing IoT devices and data. It provides a cloud-based platform where users can securely connect their IoT devices and collect data from sensors and actuators. It supports a wide range of communication protocols and provides device management capabilities, monitoring device data, linking with third-party webhooks, and creating rules to trigger based on conditions, etc. All of it with a Great UI ❤ Get PCBs for Your Projects Manufactured You must check out PCBWAY for ordering PCBs online for cheap! You get 10 good-quality PCBs manufactured and shipped to your doorstep for cheap. You will also get a discount on shipping on your first order. Upload your Gerber files onto PCBWAY to get them manufactured with good quality and quick turnaround time. PCBWay now could provide a complete product solution, from design to enclosure production. Check out their online Gerber viewer function. With reward points, you can get free stuff from their gift shop. Getting Started To get started with Qubitro, we will first need to create an account. Go to the Qubitro website (https://www.qubitro.com/) and click on the "Sign Up" button. You will be prompted to enter Full Name, Email Address,Country, and password to create your account. Once, we have created the account, we can log in from https://portal.qubitro.com/login. However, we shall automatically be logged in to our account. Create a New Project Once you have logged in, you will be prompted to create a project. Enter a name for your project and mention a description for your project. Add Devices Next, you will need to add devices to your application. Go to the Project (if not already open), there we can see a button [+ New Source]. From this section, we will have 3 major sections - 1. Communication Protocol With a prompt to choose between LoRaWAN, MQTT, & Cellular. We can choose the protocol that best suits our use-case. I choose MQTT to get started with the platform basics. And since I shall be using Arduino IDE for programming the board, I went ahead with the MQTT Broker (Qubitro has its own broker - we shall see it in the upcoming section). In case you wish to know how the Toit platform works, you can check my Tutorial on Toit.io 2. Device Details I shall be using an ESP32 Dev Board, and therefore entered the details as per the image below - 3. Credentials In the next step, we receive credentials, to connect to the MQTT Broker. We can use this detail to connect to the broker as a client - to Publish or Subscribe. Now that we have the server, port, username and password we are all ready to send data to the Qubitro Cloud. Copy these details in a safe place (We can view them later in the device settings as well though) Hardware - From Device to Cloud Once you have configured your devices, you can start collecting data. Qubitro provides a range of tools for data collection and analysis, including real-time data visualization, data logging, and data filtering. We shall upload a code on ESP32 using Arduino IDE to send data to Qubitro - #include <WiFiClientSecure.h> #include <PubSubClient.h> #include <HTTPClient.h> #include <ArduinoJson.h> These are the necessary libraries for establishing an MQTT connection, handling HTTP requests, and working with JSON data. const char* ssid = "xxxxxxxxx"; const char* password = "xxxxxxxxx"; String topic = "xxxxx"; String mqtt_server = "broker.qubitro.com"; String mqttuser = "xxxxxxxxxxxxxxxxxxxxxx"; String mqttpass = "xxxxxxxxxxxxxxxxxxxxxx"; String clientId = "xxxxxxxxxxxxxxxxxxxxxx"; These variables store the Wi-Fi credentials (ssid and password), MQTT broker server address (mqtt_server), MQTT authentication credentials (mqttuser and mqttpass), MQTT client ID (clientId), and the MQTT topic (topic) to which the data will be published. WiFiClientSecure espClient; PubSubClient client(espClient); float humidity = 0; float temp = 0; Create an instance of WiFiClientSecure and PubSubClient classes to establish a secure connection with the MQTT broker. Also, initializing default value of temperature and humidity. #define MSG_BUFFER_SIZE (500) char msg[MSG_BUFFER_SIZE]; char output[MSG_BUFFER_SIZE]; Define the size of the message buffer for storing MQTT messages. void device_setup() { // ... Wi-Fi connection setup ... } This function sets up the Wi-Fi connection by connecting to the specified Wi-Fi network (ssid and password). void reconnect() { // ... MQTT reconnection logic ... } This function handles the reconnection to the MQTT broker in case of disconnection. void setup() { // ... Initialization code ... } The setup() function is the entry point of the code. It initializes the serial communication, sets up the device, establishes a connection with the MQTT broker, and prepares the secure connection using WiFiClientSecure and PubSubClient objects. void loop() { // ... Main code loop ... } The loop() function is the main execution loop of the code. It checks the MQTT connection, publishes the simulated temperature and humidity data to the MQTT topic, and then waits for a delay of 1 second before repeating the process. Inside the loop() function, you'll notice the following steps: if (!client.connected()) checks if the MQTT client is connected. If not, it calls the reconnect() function to establish the connection. client.loop() allows the MQTT client to maintain the connection and handle any incoming messages. The temp and humidity variables are randomly generated simulated values. A JSON document is created using the ArduinoJson library to store the temperature and humidity data. The JSON document is serialized into a string format using the serializeJson() function and stored in the output variable. The client.publish() function is used to publish the serialized JSON data to the specified MQTT topic. The serialized JSON data is printed to the serial monitor using Serial.println(). A delay of 1 second is added before repeating the loop. Full version of the code available in the Code Section. Now that we have written the code, upload it to the ESP32 board and wait for it to send data to cloud. To check data, go to Device Name that you created, and check for any incoming data in the table. (refresh the table in case data not retrieved) Create Dashboard Now that we were able to fetch for real-time data from the ESP32 board and view it on the table of Qubitro. Let us use the visualization feature to plot a graph of the data. Trust me, it takes seconds to setup the whole thing. Go to Dashboards, and create a New Dashboard. Give it a name. Once created, open it and go to Edit > Add Widget > Charts. Click on the new widget > three dots (settings) > Customization. Accordingly, select the data source, chart type and colour for data variables. Follow the below images for reference, and final Graph. Data source example above Data Point example above Finally, I received the above graph based on a 30-minute data logging. If we head back to the main dashboard page, we can have a proper view, and with a view configuration, receive live data in realtime on Qubitro. In the dashboard, click on the chart widget we created, click on edit and drag it to the middle. Stretch and play with the widget according to the need. Resizing it for proper viewing. Remember to save it. If you are facing trouble with viewing the data with 4 points in the graph period, you can change it in the View Mode's configuration of the graph widget. Now, using this we can view the data of our device based on our needs! Rules to Trigger and Integration Services Finally, Qubitro allows you to integrate with other services such as Twilio, Slack, MailGun, and SendGrid. We can also use the trigger for Webhooks (RAW HTTP request) triggering, You can do this by clicking on the "Rules" tab in the Device section and selecting the service you want to integrate with. Congratulations! You have now completed the Qubitro IoT Platform documentation tutorial. We hope that this tutorial has provided you with the information you need to get started with Qubitro and create your own IoT application. If you have any questions or need further assistance, please visit the Qubitro website or contact their support team. Hurray! 🎉 We have learned another IoT Platform - Qubitro Device Data Platform esp32_mqtt_qubitro.ino
×
  • Create New...