I'm getting use to the IoT cloud, doing a very simple sketch with a dht22 sensor. As the sensor has a long delay of 2 seconds, I'm trying to create a call function instead of putting it in the main loop. Im getting an error when the lcd trys to set the position of the cursor on the lcd display. The error is as follows:
error: no matching function for call to 'LiquidCrystal_I2C::cursor(int, int)'
lcd.cursor(1,0);
I'm sure it is something simple I'm missing either in the call function itself or in the configuration of the lcd display, But the display works in the Setup function of the sketch. Any ideas?
If this is in the wrong catagory, sorry. Getting use to the Forum as well.
// LiquidCrystal I2C - Version: 1.1.2
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
// DHT sensor library - Version: Latest
#include <DHT.h>
#include <DHT_U.h>
DHT dht(6,DHT22);
//################################################
//LED's on GPIO PINS for Relay & led 1=2,led2=3,led3=4,led4=5/pins 2-5
const byte led1 = 2;
const byte led2 = 3;
const byte led3 = 4;
const byte led4 = 5;
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/5f2a9e4e-1fb3-4592-b012-3e3f1a13bdb4
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float h;
float humidity;
float t;
float temperature;
CloudSwitch zone1;
CloudSwitch zone2;
CloudSwitch zone3;
CloudSwitch zone4;
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"
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();
delay(2000);
//***************** Sets up Output pins for relay GPIO 2,3,4,5
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
// ************NOTE: Relay module activates when Pin is low.
digitalWrite(led1, HIGH);//Sets LED's to LOW
digitalWrite(led2, HIGH);//Sets LED's to LOW
digitalWrite(led3, HIGH);//Sets LED's to LOW
digitalWrite(led4, HIGH);//Sets LED's to LOW
//******************************************************
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
lcd.clear();
lcd.setCursor(1,0);
lcd.print("SYSTEM BOOTING");
// 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
}
//
/******************* Zone 1 Routine ************************
Since Zone1 is READ_WRITE variable, onZone1Change() is
executed every time a new value is received from IoT Cloud.
*/
void onZone1Change() {
// Add your code here to act upon Zone1 change
if (zone1 == true) {
digitalWrite(led1, LOW);
lcd.clear();
lcd.setCursor(3,0);
lcd.print("Zone 1 On");
}
else
digitalWrite(led1, HIGH);
// Add your code here to act upon Zone1 change
}
/*
//
/******************* Zone 2 Routine ************************
Since Zone2 is READ_WRITE variable, onZone2Change() is
executed every time a new value is received from IoT Cloud.
*/
void onZone2Change() {
if (zone2 == true) {
digitalWrite(led2, LOW);
}
else
digitalWrite(led2, HIGH);
// Add your code here to act upon Zone2 change
}
/*
//
/******************* Zone 3 Routine ************************
Since Zone3 is READ_WRITE variable, onZone3Change() is
executed every time a new value is received from IoT Cloud.
*/
void onZone3Change() {
if (zone3 == true) {
digitalWrite(led3, LOW);
}
else
digitalWrite(led3, HIGH);
// Add your code here to act upon Zone3 change
}
/*
//
/******************* Zone 4 Routine ************************
Since Zone4 is READ_WRITE variable, onZone4Change() is
executed every time a new value is received from IoT Cloud.
*/
void onZone4Change() {
if (zone4 == true) {
digitalWrite(led4, LOW);
}
else
digitalWrite(led4, HIGH);
// Add your code here to act upon Zone4 change
}
void readdht(){
float h = dht.readHumidity();
float t = dht.readTemperature(true);
humidity = h;
temperature = t;
lcd.clear();
lcd.cursor(0,0);
lcd.print("Temp: "); lcd.print(temperature);
lcd.cursor(0,1);
lcd.print("Humd: "); lcd.print(humidity);
}