Arduino IoT Cloud General

Hello All, I am after some information on how to connect properties on the cloud

I have managed to get an LED to turn on and off from a switch on my dashboard, now I want to add temperature sensing

so I have a DHT11 on the board and added the property, its got a variable name, its read only and it updates on change, I hit edit the code and there are some changes to the sketch and things properties

what I dont really understand is how you construct the sketch and how it updates to the cloud, is it a matter of creating a regular sketch to print the temp/humidity to serial and the board automatically uploads that to the dashboard or are there further steps,

I cannot find any examples on the web that reflect my project adequately enough, there are several that use other platforms or there are Arduino IoT Cloud examples that dont really show enough for me to modify into the use of a DHT11

any explanation of how it all works generally would be much appreciated

although I didnt get any replies I continued on my quest, still having problems though

so when I add a property it does seem to update the skets (sometimes!! it doesnt seem to update the sketch if you edit the property)

I dont get what is actually meant to happen, what part of the sketch is created in properties (of IoT Cloud)?

here is the sketch as it stands (unfinished) I wanted to see what happens when this is uploaded so I can try to understand this whole process but now I am getting an error which I cannot find the reason for

// DHT sensor library - Version: Latest
#include <DHT.h>
#include <DHT_U.h>

/*
  Sketch generated by the Arduino IoT Cloud Thing "Greenhouse_Automation_1"
  https://create.arduino.cc/cloud/things/744d255b-42ba-45ab-ab19-cf0754002aa3

  Arduino IoT Cloud Properties description

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

  float humid;
  bool lED;
  float TempC;
  float tempF;

  Properties 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"
#define LED_PIN LED_BUILTIN
DHT11 dht11(7);  // creating the object sensor on pin 'D7'

int C;   // temperature C readings are integers
float F; // temperature F readings are returned in float format
int H;   // humidity readings are integers


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(LED_PIN, OUTPUT);

  // 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(3);
  delay(5000);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();


  // dht11.update();

  C = dht11.readCelsius();     	// Reading the temperature in Celsius degrees and store in the C variable
  F = dht11.readFahrenheit();  	// Reading the temperature in Fahrenheit degrees and store in the F variable
  H = dht11.readHumidity();     // Reading the humidity index

  // Print the collected data in a row on the Serial Monitor
  Serial.print("H: ");
  Serial.print(H);
  Serial.print("\tC: ");
  Serial.print(C);
  Serial.print("\tF: ");
  Serial.println(F);

  delay(30000);                // Wait one second before get another temperature reading

}

void onLEDChange() {
  digitalWrite(LED_PIN, lED);
  Serial.print("The light is ");
  if (lED) {
    Serial.println("ON");
  } else {
    Serial.println("OFF");
  }
}


void onThermChange() {




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


const char THING_ID[] = "744d255b-42ba-45ab-ab19-cf0754002aa3";

const char SSID[]     = SECRET_SSID;    // Network SSID (name)
const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)

void onLEDChange();

float humid;
bool lED;
float TempC;
float tempF;

void initProperties(){

  ArduinoCloud.setThingId(THING_ID);
  ArduinoCloud.addProperty(humid, READ, ON_CHANGE, NULL);
  ArduinoCloud.addProperty(lED, READWRITE, ON_CHANGE, onLEDChange);
  ArduinoCloud.addProperty(TempC, READ, ON_CHANGE, NULL, 1.000000);
  ArduinoCloud.addProperty(tempF, READ, ON_CHANGE, NULL, 1.000000);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

I am getting the error expected unqualified ID before numeric constant, looking at the output I have a few issues

Multiple libraries were found for "DHT.h"

Used: /home/builder/opt/libraries/latest/dht_sensor_library_1_3_8

Not used: /home/builder/opt/libraries/latest/nanoplayboard_0_1_1

Not used: /home/builder/opt/libraries/latest/grove_temperature_and_humidity_sensor_1_0_1

Multiple libraries were found for "Adafruit_Sensor.h"

Used: /home/builder/opt/libraries/latest/adafruit_unified_sensor_1_1_2

Not used: /home/builder/opt/libraries/latest/arduav_1_3_1

Using library dht_sensor_library_1_3_8 at version 1.3.8 in folder: /home/builder/opt/libraries/latest/dht_sensor_library_1_3_8

Using library adafruit_unified_sensor_1_1_2 at version 1.1.2 in folder: /home/builder/opt/libraries/latest/adafruit_unified_sensor_1_1_2

Using library arduinoiotcloud_0_10_0 at version 0.10.0 in folder: /home/builder/opt/libraries/latest/arduinoiotcloud_0_10_0

Using library arduinocloudthing_1_7_3 at version 1.7.3 in folder: /home/builder/opt/libraries/latest/arduinocloudthing_1_7_3

Using library arduino_connectionhandler_0_4_6 at version 0.4.6 in folder: /home/builder/opt/libraries/latest/arduino_connectionhandler_0_4_6

Using library wifinina_1_5_0 at version 1.5.0 in folder: /home/builder/opt/libraries/latest/wifinina_1_5_0

Using library arduino_debugutils_1_0_0 at version 1.0.0 in folder: /home/builder/opt/libraries/latest/arduino_debugutils_1_0_0

Using library arduinobearssl_1_4_0 at version 1.4.0 in folder: /home/builder/opt/libraries/latest/arduinobearssl_1_4_0

Using library arduinomqttclient_0_1_4 at version 0.1.4 in folder: /home/builder/opt/libraries/latest/arduinomqttclient_0_1_4

Using library rtczero_1_6_0 at version 1.6.0 in folder: /home/builder/opt/libraries/latest/rtczero_1_6_0

Using library arduinoeccx08_1_3_3 at version 1.3.3 in folder: /home/builder/opt/libraries/latest/arduinoeccx08_1_3_3

Using library Wire at version 1.0 in folder: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.4/libraries/Wire

Using library SPI at version 1.0 in folder: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.4/libraries/SPI

In file included from /tmp/827791176/Greenhouse_Automation_1_mar25a/Greenhouse_Automation_1_mar25a.ino:3:0:

/home/builder/opt/libraries/latest/dht_sensor_library_1_3_8/DHT.h:37:15: error: expected unqualified-id before numeric constant

#define DHT11 11 /**< DHT TYPE 11 */

^

/tmp/827791176/Greenhouse_Automation_1_mar25a/Greenhouse_Automation_1_mar25a.ino:26:1: note: in expansion of macro 'DHT11'

DHT11 dht11(7); // creating the object sensor on pin 'D7'

^~~~~

/tmp/827791176/Greenhouse_Automation_1_mar25a/Greenhouse_Automation_1_mar25a.ino: In function 'void loop()':

/tmp/827791176/Greenhouse_Automation_1_mar25a/Greenhouse_Automation_1_mar25a.ino:65:7: error: 'dht11' was not declared in this scope

C = dht11.readCelsius(); // Reading the temperature in Celsius degrees and store in the C variable

^~~~~

/tmp/827791176/Greenhouse_Automation_1_mar25a/Greenhouse_Automation_1_mar25a.ino: At global scope:

/tmp/827791176/Greenhouse_Automation_1_mar25a/Greenhouse_Automation_1_mar25a.ino:98:1: error: expected declaration before '}' token

}

^

exit status 1

again I am not trying to fix this specific code I am trying to understand each part of the process of setting up a sensor thats connected to the cloud

thanks

Dan

Get rid of the #define that the compiler is complaining about. You're trying to define DHT11 which is already in use by the library.

For best results post all your code.

wildbill:
Get rid of the #define that the compiler is complaining about. You’re trying to define DHT11 which is already in use by the library.

For best results post all your code.

you mean this part in the output?

#define DHT11 11 /**< DHT TYPE 11 */

there is only one define in the code #define LED_PIN LED_BUILTIN

this whole thing is confusing the crap out of me, I just think there is not enough information on this process and what is there is ambiguous

ok so I have gone back a step

just the LED working and the DHT11 connected to PIN7

the sketch is missing anything to do with the DHT11 other than what is in the THingProperties Tab

main code

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Greenhouse_Automation_1"
  https://create.arduino.cc/cloud/things/744d255b-42ba-45ab-ab19-cf0754002aa3 

  Arduino IoT Cloud Properties description

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

  float humid;
  bool lED;
  float TempC;
  float tempF;

  Properties 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"
#define LED_PIN LED_BUILTIN

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();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
  
}

void onLEDChange() {
  // Do something
    digitalWrite(LED_PIN, lED);
    Serial.print("The light is ");
    if (lED) {
        Serial.println("ON");
    } else {
        Serial.println("OFF");
    }
}

ThingProperties

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


const char THING_ID[] = "744d255b-42ba-45ab-ab19-cf0754002aa3";

const char SSID[]     = SECRET_SSID;    // Network SSID (name)
const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)

void onLEDChange();

float humid;
bool lED;
float TempC;
float tempF;

void initProperties(){

  ArduinoCloud.setThingId(THING_ID);
  ArduinoCloud.addProperty(humid, READ, ON_CHANGE, NULL);
  ArduinoCloud.addProperty(lED, READWRITE, ON_CHANGE, onLEDChange);
  ArduinoCloud.addProperty(TempC, READ, ON_CHANGE, NULL, 1.000000);
  ArduinoCloud.addProperty(tempF, READ, ON_CHANGE, NULL, 1.000000);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

I think everything in the IoT cloud is set up properly

I have added the DHT11 code and its printing to serial fine, the bit that I am completely missing is how this updates the dashboard in the cloud, any assistance would be greatly appreciated

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Greenhouse_Automation_1"
  https://create.arduino.cc/cloud/things/744d255b-42ba-45ab-ab19-cf0754002aa3 

  Arduino IoT Cloud Properties description

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

  float humid;
  bool lED;
  float TempC;

  Properties 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 "DHT.h" 
#define LED_PIN LED_BUILTIN
#define DHTPIN 7                    //define DHT pin
#define DHTTYPE DHT11          //define DHTTYPE DHT11/DHT22
DHT dht(DHTPIN, DHTTYPE);

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); 
    dht.begin(); 

  // 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(4);
  ArduinoCloud.printDebugInfo();
  delay(30000);
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
   float TempC = dht.readTemperature();
   Serial.print("Temperature");
   Serial.println(TempC);
  float humid = dht.readHumidity();
  Serial.print("Humidity");
  Serial.println(humid);
  delay(10000);
}

void onLEDChange() {
 digitalWrite(LED_PIN, lED);
    Serial.print("The light is ");
    if (lED) {
        Serial.println("ON");
    } else {
        Serial.println("OFF");
    }  
}
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>


const char THING_ID[] = "744d255b-42ba-45ab-ab19-cf0754002aa3";

const char SSID[]     = SECRET_SSID;    // Network SSID (name)
const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)

void onLEDChange();

float humid;
bool lED;
float TempC;

void initProperties(){

  ArduinoCloud.setThingId(THING_ID);
  ArduinoCloud.addProperty(humid, READ, 30 * SECONDS, NULL);
  ArduinoCloud.addProperty(lED, READWRITE, ON_CHANGE, onLEDChange);
  ArduinoCloud.addProperty(TempC, READ, 30 * SECONDS, NULL);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

ahha getting there

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Greenhouse_Automation_1"
  https://create.arduino.cc/cloud/things/744d255b-42ba-45ab-ab19-cf0754002aa3 

  Arduino IoT Cloud Properties description

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

  float humid;
  bool lED;
  float TempC;

  Properties 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 "DHT.h" 
#define LED_PIN LED_BUILTIN
#define DHTPIN 7                    //define DHT pin
#define DHTTYPE DHT11          //define DHTTYPE DHT11/DHT22
DHT dht(DHTPIN, DHTTYPE);

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); 
    dht.begin(); 

  // 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(4);
  ArduinoCloud.printDebugInfo();
  delay(30000);
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
    TempC = dht.readTemperature();
   float TempC = dht.readTemperature();
   Serial.print("Temperature");
   Serial.println(TempC);
  humid = dht.readHumidity();
  float humid = dht.readHumidity();
  Serial.print("Humidity");
  Serial.println(humid);
  delay(10000);
}

void onLEDChange() {
 digitalWrite(LED_PIN, lED);
    Serial.print("The light is ");
    if (lED) {
        Serial.println("ON");
    } else {
        Serial.println("OFF");
    }  
}

this works!! can someone please clarify the steps though just for my own sanity

does anyone understand the history download from the dashboard? I am getting some strange output that I cannot seem to translate

its also only exporting two days data from a week ago, what am I doing wrong here??

Date and time,Soil Sensor
2020-04-14T17:03:07.408Z,126
2020-04-14T17:03:10.481Z,128
2020-04-14T17:03:13.553Z,134
2020-04-14T17:03:16.317Z,126
2020-04-14T17:03:22.462Z,128
2020-04-14T17:03:25.534Z,127
2020-04-14T17:03:28.605Z,128
2020-04-14T17:03:34.749Z,127
2020-04-14T17:03:37.515Z,126
2020-04-14T17:03:40.588Z,128
2020-04-14T17:03:43.658Z,129
2020-04-14T17:03:46.73Z,126
2020-04-14T17:03:52.874Z,125
2020-04-14T17:03:55.946Z,129
2020-04-14T17:03:58.724Z,128
2020-04-14T17:04:07.926Z,127
2020-04-14T17:04:11.006Z,128
2020-04-14T17:04:14.071Z,127
2020-04-14T17:04:16.835Z,126
2020-04-14T17:04:19.907Z,125
2020-04-14T17:04:22.979Z,127
2020-04-14T17:04:29.124Z,126
2020-04-14T17:04:35.268Z,129
2020-04-14T17:04:38.339Z,131
2020-04-14T17:04:41.104Z,125
2020-04-14T17:04:44.176Z,128
2020-04-14T17:04:47.248Z,129
2020-04-14T17:04:50.322Z,126
2020-04-14T17:04:53.392Z,127
2020-04-14T17:04:59.229Z,126
2020-04-14T17:05:02.304Z,128
2020-04-14T17:05:08.457Z,127
2020-04-14T17:05:11.517Z,126
2020-04-14T17:05:14.282Z,127
2020-04-14T17:05:17.367Z,129
2020-04-14T17:05:20.427Z,125
2020-04-14T17:05:26.57Z,128
2020-04-14T17:05:32.514Z,126
2020-04-14T17:06:02.832Z,128
2020-04-14T17:06:05.892Z,126
2020-04-14T17:06:08.964Z,125
2020-04-14T17:06:11.729Z,127
2020-04-14T17:06:17.873Z,126
2020-04-14T17:06:20.946Z,125
2020-04-14T17:06:24.016Z,126
2020-04-14T17:06:27.089Z,128
2020-04-14T17:06:30.162Z,127
2020-04-14T17:06:33.232Z,129

data removed because of text limits

2020-04-14T18:22:42.434Z,7
2020-04-14T18:23:02.397Z,6
2020-04-14T18:23:07.62Z,7
2020-04-14T18:23:27.588Z,6
2020-04-14T18:23:32.503Z,7
2020-04-14T18:23:47.556Z,6
2020-04-14T18:23:57.693Z,8
2020-04-14T18:24:02.622Z,6
2020-04-14T18:24:07.524Z,7
2020-04-14T18:25:07.736Z,6
2020-04-14T18:25:17.873Z,7
2020-04-14T18:25:32.926Z,6
2020-04-14T18:25:42.757Z,7
2020-04-14T18:25:47.979Z,6
2020-04-14T18:25:52.894Z,7
2020-04-14T18:26:07.962Z,6
2020-04-14T18:26:12.867Z,7
2020-04-14T18:26:27.914Z,6
2020-04-14T18:26:33.141Z,7
2020-04-14T18:26:48.19Z,6
2020-04-14T18:26:53.105Z,7
2020-04-14T18:27:38.263Z,6
2020-04-14T18:27:43.184Z,7
2020-04-14T18:27:48.093Z,6
2020-04-14T18:27:53.316Z,7
2020-04-14T18:28:13.285Z,6
2020-04-14T18:28:18.2Z,7
2020-04-14T18:29:33.464Z,6
2020-04-14T18:29:38.379Z,7
Date and time,Temperature Celsius
2020-04-14T12:09:51.41Z,22
2020-04-14T12:10:36.861Z,23

data removed because of text limits

2020-04-15T06:38:06.505Z,22

getting some time discrepancies also