Hello everyone, this is my first post in this forum and I need help
I want to display temp and humidity in my IoT dashboard but i keep getting this error, I admit that I'm not a programmer but this issue is a headache, and I'll attach the entire code and a screenshot of the error for your review.
error message: expected primary-expression before ')' token
in this line: DHT22 dht22_sensor (DHT22_SENSOR_PIN, DHT22_SENSOR_TYPE);
Thanks in advance
Yusuf.
// DHT22 - Version: 1.0.6
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/4aa1dbdb-13be-4258-8cf6-e57e44c8cc33
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
CloudSwitch motor_Switch;
CloudTemperatureSensor temp;
CloudRelativeHumidity humi;
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 <DHT22.h>
#define MOTOR_PIN 27
#define DHT22_SENSOR_PIN 25
#define DHT22_SENSOR_TYPE DHT22
DHT22 dht22_sensor (DHT22_SENSOR_PIN, DHT22_SENSOR_TYPE);
void setup() {
pinMode(DHT22_SENSOR_PIN, INPUT);
pinMode(MOTOR_PIN, OUTPUT);
DHT22_SENSOR.begin();
// 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
humi = DHT22_sensor.readHumidity();
temp = DHT22_sensor.readTemperature();
if(isnan(humi) || isnan(temp)){
Serial.println("Failed to read from dht22 Sensor|");
}else{
Serial.print("Humidity: "); Serial.print(humi); Serial.print("%"); Serial.print(" | ");
Serial.print("Temperature: "); Serial.print(temp); Serial.println("â°");
}
delay(2000);
}
/*
Since MotorSwitch is READ_WRITE variable, onMotorSwitchChange() is
executed every time a new value is received from IoT Cloud.
*/
void onMotorSwitchChange() {
// Add your code here to act upon MotorSwitch change
if(motor_Switch){
digitalWrite(MOTOR_PIN, HIGH);
}else{
digitalWrite(MOTOR_PIN, LOW);
}
}