Receive Data from Arduino via Hardware UART in Cloud and display it as a Graph

I have read various articles for days in the forum and went through the documentation but have not been able to come up with a way to send data from Arduino to Cloud via Bolt.

I have downloaded the boltiot-arduino-helper and even put my credentials in the BoltDeviceCredentials.
I have a DHT11 and an LDR, I want to be able to read the data received in arduino from these two sensors regarding temperature, humidity and light, and send it to the cloud to make a graph out of it.

Please send me step-by-step instructions. I have even tried the DHT2Cloud but could not implement it. Please help me as I am using Bolt in my Final Year Project.

This is a code I tried to develop but didn’t work.


Please provide help as soon as possible.

Here are the step-by-step instructions to send data from Arduino to Cloud via Bolt.

  1. Connect your Arduino board to your computer via USB cable.
  2. Open the Arduino IDE on your computer and create a new sketch.
  3. Add the following libraries to your sketch by going to Sketch > Include Library > Manage Libraries:
  • BoltIoT-Arduino-Helper
  • DHT Sensor Library
  1. Define the pins for your sensors and initialize them in the setup() function. For example:
#define DHTPIN 2 // Pin for DHT11 sensor
#define LDRPIN A0 // Pin for LDR sensor

// Initialize DHT11 sensor
DHT dht(DHTPIN, DHT11);

  1. In the loop() function, read the data from your sensors and store it in variables. For example:
float temperature = dht.readTemperature(); // Read temperature from DHT11 sensor
float humidity = dht.readHumidity(); // Read humidity from DHT11 sensor
int light = analogRead(LDRPIN); // Read light intensity from LDR sensor

  1. Use the BoltIoT-Arduino-Helper library to send the data to the Bolt Cloud. To do this, you’ll need to initialize the Bolt device, connect to the Bolt Cloud, and send the data using the Bolt Cloud API. Here’s an example code snippet:
#include <BoltIoT-Arduino-Helper.h>

// Define your Bolt device credentials
char deviceName[] = "BOLTXXXXXXX"; // Replace XXXXXXX with your device ID
char apiKey[] = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"; // Replace X with your API key

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize Bolt device
  boltiot.begin(deviceName, apiKey, &Serial);

  // Connect to Bolt Cloud
  boltiot.connectWiFi("YOUR_WIFI_SSID", "YOUR_WIFI_PASSWORD");

  // Wait for Bolt Cloud connection
  while (!boltiot.isWiFiConnected()) {
    delay(100);
  }
}

void loop() {
  // Read sensor data
  float temperature = dht.readTemperature(); // Read temperature from DHT11 sensor
  float humidity = dht.readHumidity(); // Read humidity from DHT11 sensor
  int light = analogRead(LDRPIN); // Read light intensity from LDR sensor

  // Send data to Bolt Cloud
  boltiot.setCommandString("{\"temperature\":" + String(temperature) +
                           ",\"humidity\":" + String(humidity) +
                           ",\"light\":" + String(light) + "}");
  boltiot.triggerEvent("sensor_data");
  
  // Wait for next reading
  delay(10000); // 10 seconds
}

  1. Replace the deviceName, apiKey, YOUR_WIFI_SSID, and YOUR_WIFI_PASSWORD placeholders in the code with your actual device ID, API key, Wi-Fi network SSID, and Wi-Fi network password, respectively.
  2. Upload the sketch to your Arduino board.
  3. Open the Bolt Cloud dashboard and create a new product with a device. Make sure to note down the API key and device ID.
  4. In the Bolt Cloud dashboard, create a new event with the name “sensor_data”.
  5. Wait for the data to be sent from the Arduino board to the Bolt Cloud.
  6. In the Bolt Cloud dashboard, go to the “sensor_data” event and click on “View Data”. You should see a graph of the sensor data.

I hope these instructions help you send data from Arduino to Cloud via Bolt. Let me know

No such directory or file.

No matching function or member in class BoltIoT.

Sorry but either the library I downloaded from docs of bolt is wrong. I have received only errors from the code.

@vishesh.agarwal20121
Hi ,
Boltiot Arduino helper library is renamed to boltiot.h

Kindly change the header file to boltiot.h

And do let us know about output. Is it works ?

Final Code To Push the data to the Cloud with the help of Bolt Library which has to be typed in Arduino IDE:

// Include the Bolt Library:
#include <BoltDeviceCredentials.h>
#include <boltiot.h>

// Include DHT Library:
#include <DHT.h>

// Define the digital pin connected to the DHT sensor - DHT 11:
#define DHTTYPE DHT11    
#define DHTPIN 2         
DHT dht(DHTPIN, DHTTYPE);

// Initialize the Analog pin connected to the LDR sensor:
const int ldrPin = A0;    

// Whenever we are using the Bolt Library, we have to use “boltiot.begin(Serial);” instead of “Serial.begin(9600);” :
void setup() {
  boltiot.begin(Serial);
  //Serial.begin(9600); 
  dht.begin();
}

// Read humidity and temperature from DHT, Read light intensity from LDR sensor and Send the Data to the cloud:
void loop() {
  float humidity = dht.readHumidity();   
  float temperature = dht.readTemperature();   
  float lightIntensity = analogRead(ldrPin);  
 
  boltiot.processPushDataCommand(dht.readHumidity(),dht.readTemperature(),analogRead(ldrPin));

  Serial.print("Humidity: ");
  Serial.print(humidity);
  Serial.print("%\t");
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.print("C\t");
  Serial.print("Light Intensity: ");
  Serial.print(lightIntensity);
  Serial.println();

  delay(2000);   
}

This code should be compiled & uploaded.

The following steps are to be followed in the Bolt Cloud:

  1. Go to Bolt Cloud Account and Login/Signup using your Credentials.
  2. You will be able to View your device ID on the Dashboard.
  3. Go to Products —> Click on Add Product —> Click on Create new Product —> Enter the Product name —> Mark as “Input Device”—> Mark as “UART”.
  4. Go to Configure this product —> Go to Hardware —> Choose the Data field Positions as 3 —> On the right hand side, enter the variable names in lower cases (example: temp, humi, light).
  5. Go to Code —> Give a file name —> Choose the extension as JS.
  6. When you are having more than 2 variables to be printed in the cloud it is better to use a Table graph rather than Line graph, The code below is for a Table graph where the values of Temp, Humidity and Light Intensity are being printed in a table. Save the code once written.
var Graph1 = new boltGraph();
Graph1.setChartType("tableGraph");
Graph1.setAxisName('X-Axis Name','Y-axis Name');
Graph1.plotChart('time_stamp','temp','humi','light');
  1. Click on Link device to this product —> Select your device to link it —> Click on Done.
  2. Click on Deploy Configuration —> Click on View Device.
  3. You will be able to view the Data in the table.
  4. Click on Push Data to Cloud if your want to get the current values.

I HOPE THIS WORKS !!

I followed all your steps but I am not able to receive the data on the graph.

I guess there is some issue by which data is not being received in the cloud properly.


As you can see not a single data point has been pushed into the graph.

You are able to view the data in the serial Monitor ? YES or NO (attach a screenshot)
Could you please attach a picture of the hardware configuration and the code which you have written in the Bolt Cloud.

//INCLUDE BOLT LIBRARY
#include <BoltDeviceCredentials.h>
#include <boltiot.h>

// Download the library DF ROBOT DHT11
#include <DFRobot_DHT11.h>
DFRobot_DHT11 DHT;
#define DHT11_PIN 10

 //WHENEVER WE USE BOLT LIBRARY, WE HAVE TO COMMENT OUT serial.begin()and instead use boltiot.begin(Serial);
void setup(){
  boltiot.begin(Serial);
  //Serial.begin(9600);
}

void loop(){
  float Temperature = DHT.temperature;
  float Humidity = DHT.humidity;
  int Light = analogRead(A0); 
  //PUSH THE DATA TO CLOUD EXAMPLE
  boltiot.processPushDataCommand(DHT.temperature,DHT.humidity,analogRead(A0));
  DHT.read(DHT11_PIN);
  Serial.print("temp:");
  Serial.print(Temperature);
  Serial.print("  humi:");
  Serial.println(Humidity);
  Serial.print("  light:");
  Serial.println(Light);
  
  delay(1000);
}

TRY USING THIS CODE INSTEAD FOR ARDUINO