Thing variables not indicating on Dashboard

I'm controlling 2 relays with a MKR1010 and Relay Shield using this code: Arduino Cloud
The sensors DS18B20 and a DFROBOT 139 are in a water tank.

However I do not get the values of these sensors to show on my Dashboard. I can see them on my LCD and the relays open and close as they should.

@sregormij post your code here please.

It can be you are shadowing your properties with local variables but it is only a guess without reading the code.

I am having a similar problem. Everything seems to be working properly and even getting the values I intend in the Serial Monitor. But when it comes to viewing these values in the dashboard, I am getting values of "0"

/*
  Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
  https://create.arduino.cc/cloud/things/4fbdca4b-9386-4744-94cc-5da4fac5209f 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float temp_Sensor;
  int pH_Sensor;
  int tDS_Sensor;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include <Arduino.h>
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is connected to the Arduino digital pin
#define ONE_WIRE_BUS 17 // change this to your sensor's pin if it's not 17

// Setup a oneWire instance to communicate with any OneWire device
OneWire oneWire(ONE_WIRE_BUS);

// Pass oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);

const int pHSensorPin = 36;
const int tdSensorPin = 34;

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 
  pinMode(pHSensorPin, INPUT);
  pinMode(tdSensorPin, INPUT);
  sensors.begin();
  sensors.setResolution(12);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  int pHValue = readPHValue();
  float temperature = readTemperature();
  int tdValue = readTDValue();
  
  Serial.print("pH Value: ");
  Serial.println(pHValue);
  
  Serial.print("Temperature: ");
  Serial.println(temperature);
  
  Serial.print("TDS Value: ");
  Serial.println(tdValue);
  
  delay(1000); // Wait for 1 second before reading again
}

int readPHValue() {
  int sensorValue = analogRead(pHSensorPin);
  // Convert the sensor value to pH value using your calibration formula or library
  // Replace the code below with your actual conversion logic
  int pH = sensorValue * 0.004;
  return pH;
}

float readTemperature() {
  sensors.requestTemperatures();
  float temperature = sensors.getTempCByIndex(0);
  return temperature;
}

int readTDValue() {
  int tdValue = analogRead(tdSensorPin);
  // Convert the sensor value to TDS value using your calibration formula or library
  // Replace the code below with your actual conversion logic
  // int tds = ... ;
  return tdValue;
}



Here is the thingProperties.h code

// Code generated by Arduino IoT Cloud, DO NOT EDIT.

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

const char DEVICE_LOGIN_NAME[]  = "0aa3fa2c-1501-4bcc-b07b-b5d84ecbd613";

const char SSID[]               = SECRET_SSID;    // Network SSID (name)
const char PASS[]               = SECRET_OPTIONAL_PASS;    // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[]  = SECRET_DEVICE_KEY;    // Secret device password


float temp_Sensor;
int pH_Sensor;
int tDS_Sensor;

void initProperties(){

  ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
  ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
  ArduinoCloud.addProperty(temp_Sensor, READ, ON_CHANGE, NULL);
  ArduinoCloud.addProperty(pH_Sensor, READ, ON_CHANGE, NULL);
  ArduinoCloud.addProperty(tDS_Sensor, READ, ON_CHANGE, NULL);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

Thank you in advance for any help!

@noahwaldron1235 you are using local variables

instead of the declared cloud properties

this is the reason why your dashboard is showhing "0"

Thank You!! This did the trick!


#include "thingProperties.h"
int ANALOG_PIN = A1;//2
int RELAY_PIN = 2;//13
#define RANGE 5000 // Depth measuring range 5000mm (for water)
#define VREF 5000 // ADC's reference voltage on your Arduino,typical value:5000mV
#define CURRENT_INIT 4.00 // Current @ 0mm (uint: mA)
#define DENSITY_WATER 1  // Pure water density normalized to 1
#define DENSITY_GASOLINE 0.74  // Gasoline density
#define PRINT_INTERVAL 2000 // changed from 1000 642023

int16_t dataVoltage;
float dataCurrent, depth; //unit:mA
// paste end
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal_I2C.h>

#define TEMP_UPPER_THRESHOLD  40 // upper temperature threshold
#define TEMP_LOWER_THRESHOLD  34 // lower temperature threshold

#define SENSOR_PIN     A2  //  23 ESP32 pin connected to DS18B20 sensor's DQ pin
#define RELAY_TEMP_PIN  1  // 27 ESP32 pin connected to relay

OneWire oneWire(SENSOR_PIN);
DallasTemperature DS18B20(&oneWire);
LiquidCrystal_I2C lcd(0x3F, 16, 2); // I2C address 0x27, 16 column and 2 rows

float tempC; // temperature in Celsius
float tempF; // temperature in Fahrenheit

void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  // Defined in thingProperties.h
  initProperties();

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

  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
  */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();

  DS18B20.begin();    // initialize the DS18B20 sensor
  pinMode(RELAY_TEMP_PIN, OUTPUT);
  lcd.init();         // initialize the lcd
  lcd.backlight();    // open the backlight
  // paste begin
  pinMode(ANALOG_PIN, INPUT);
  pinMode(RELAY_PIN, OUTPUT);//paste end
}

void loop() {
  ArduinoCloud.update();
  delay(2000);// added to see if this would update Remote APP
  // Your code here
  DS18B20.requestTemperatures();                  // send the command to get temperatures
  float temperature = DS18B20.getTempFByIndex(0); // read temperature in Fahrenheit
  tempC = DS18B20.getTempCByIndex(0);  // read temperature in Celsius
  tempF = tempC * 9 / 5 + 32; // convert Celsius to Fahrenheit
  //paste begin
  dataVoltage = analogRead(ANALOG_PIN) / 1024.0 * VREF;
  dataCurrent = dataVoltage / 120.0; //Sense Resistor:120ohm
  depth = ((dataCurrent - CURRENT_INIT) * (RANGE / DENSITY_WATER / 16.0) * .0114); //Calculate depth from current readings and convert to inches

  if (depth < 0)
  {
    depth = 0.0;
  }
  //Serial print results
  Serial.print("depth:");
  Serial.print(depth);
  Serial.println("inches");

  // Check if depth is low, and turn on the relay if it is
  if (depth < 15.5) {
    Serial.println("Relay 2 closed");// turn pump on
    digitalWrite(RELAY_PIN, HIGH);
  } else if (depth >= 16.6) {
    Serial.println("Relay 2 open");// turn pump off
    digitalWrite(RELAY_PIN, LOW);
  } //paste end
  lcd.clear();
  lcd.setCursor(0, 0);  // display position
  lcd.print(depth);     // display the depth reading from sensor

  lcd.print(" Inches");
  lcd.setCursor(0, 1);  // display position
  lcd.print(tempF);     // display the temperature in Fahrenheit
  lcd.print((char)223); // display ° character
  lcd.print("F");

  if (temperature > TEMP_UPPER_THRESHOLD) {
    Serial.println(DS18B20.getTempFByIndex(0));
    Serial.println("Relay 1 open");// relay 1 controls temperature by starting pump
    digitalWrite(RELAY_TEMP_PIN, LOW); // turn off
  } else if (temperature < TEMP_LOWER_THRESHOLD) {
    Serial.println(DS18B20.getTempFByIndex(0));
    Serial.println("Relay 1 closed");
    digitalWrite(RELAY_TEMP_PIN, HIGH); // turn on
  }

  delay(1500);
}

Here is the code I'm using however it won't display values in IOT Remote dashboard

@sregormij i need also the "thingProperties.h file otherwise it is impossible to know the properties names that you have used.