Arduino could dashboard not shown temperature data

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
#include <Wire.h>
#include <hd44780.h>                     // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header


const char SSID[] = "XXXX";        // Replace with your network SSID (WiFi name)
const char PASS[] = "XXXX";         // Replace with your network password

void onLED1D2Change();

bool lED1D2;
CloudTemperatureSensor t1; // Cloud variable for the first temperature sensor
CloudTemperatureSensor t2; // Cloud variable for the second temperature sensor

// Define the analog pins for the LM35 sensors
const int LM35Pin1 = A0;
const int LM35Pin2 = A1;

// Timing variables
unsigned long previousMillis = 0;
const long interval = 60000;  // Interval at which to read temperatures (milliseconds)

// Initialize the LCD (hd44780_I2Cexp object)
hd44780_I2Cexp lcd;

void initProperties() {
  ArduinoCloud.addProperty(lED1D2, READWRITE, ON_CHANGE, onLED1D2Change);
  ArduinoCloud.addProperty(t1, READ, 60 * 1000); // Update every minute
  ArduinoCloud.addProperty(t2, READ, 60 * 1000); // Update every minute
}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

void setup() {
  // Initialize serial and wait for port to open
  Serial.begin(9600);
  delay(1500); 

  // Initialize cloud properties
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  // Set debug message level
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
  
  // Initialize pin 2 as an output
  pinMode(2, OUTPUT);

  // Initialize the LCD
  lcd.begin(16, 2);  // Set up the LCD's number of columns and rows
  lcd.backlight();   // Turn on the backlight

  // Print initial debug information
  Serial.println("Setup complete. Beginning loop...");
}

void loop() {
  ArduinoCloud.update();
  
  // Check if the interval time has passed
  unsigned long currentMillis = millis(); // Get the current time
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis; // Update the last time temperatures were read

    // Read temperatures from the LM35 sensors
    float temperature1 = readTemperature(LM35Pin1); // Read temperature from the first sensor
    float temperature2 = readTemperature(LM35Pin2); // Read temperature from the second sensor
    
    // Print temperature readings to the Serial Monitor for debugging
    Serial.print("Temperature 1: ");
    Serial.println(temperature1);
    Serial.print("Temperature 2: ");
    Serial.println(temperature2);
    
   

    // Explicitly update cloud variables
    ArduinoCloud.update();
    
    // Debugging cloud sync
    Serial.print("Updated Cloud t1: ");
    Serial.println(t1);
    Serial.print("Updated Cloud t2: ");
    Serial.println(t2);

    // Update the LCD display
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("Temp1: ");
    lcd.print(temperature1);
    lcd.print(" C");
    lcd.setCursor(0, 1);
    lcd.print("Temp2: ");
    lcd.print(temperature2);
    lcd.print(" C");
     // Update the cloud variables
    t1 = temperature1;
    t2 = temperature2;
  }
}

// Function to read temperature from an LM35 sensor
float readTemperature(int pin) {
  int reading = analogRead(pin); // Read the analog value from the specified pin
  float voltage = reading * (5.0 / 1023.0); // Convert the analog value to a voltage
  float temperatureC = voltage * 100.0; // Convert the voltage to temperature in Celsius
  return temperatureC; // Return the temperature
}

// Function to handle changes in the lED1D2 variable
void onLED1D2Change() {
  // Write to pin 2 based on the lED1D2 value from the cloud
  digitalWrite(2, lED1D2 ? HIGH : LOW);
}

void ont1Change()  {
  Serial.println("t1 changed on the cloud");
}

void ont2Change()  {
  Serial.println("t2 changed on the cloud");
}
 ''

I updated my sketch to arduino r4 wifi The temperature can show on LCD and Serial monitor but show 0.00 in my dashboard Can anyone help me. Please.

I moved your topic to an appropriate forum category @warachai.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

Hi @warachai. I'm going to ask you to provide some additional information that might help us to identify the problem.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. If you are not already, log in to your Arduino account:
    https://login.arduino.cc/login
  2. Click the following link to open the list of your Arduino Cloud Things in the web browser:
    https://app.arduino.cc/things
  3. Click the name of your project's Thing.
    The "Setup" page for the Thing will open.
  4. Look under the "Associated Device" section of the page, there you will see a "Status" field.

Please add a reply here on this forum thread to tell us whether the "Status" field said "Online" or "Offline".

Thank you for your answer. My Arduino uno online and I can control 1 LED. via my dashboard however the data of temperature shown 0.00 but in serial monitor and LCD can show the actual temperature.

Thank you for your help. I am sorry for my mistake.

1 Like

I don't spot any problems in your code.

I have found that sometimes the connection between the dashboard widget and the Arduino Cloud Variable can get broken. Try deleting the nonfunctional widgets from the dashboard and then add them back again. Hopefully they will start working after that.

Thank you for your suggestion. I checked and found the mistake with my parameter which I declare may concern with autometic generate form variable configulation in could.
after I delete and using the parameter from autometic generate the dashboard shown my temperature data. Thank you.

You are welcome. I'm glad it is working now.

Regards,
Per

A post was split to a new topic: Variables always have zero value in dashboard

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.