Hello,
I am new in Arduino`s world. I want to do some project using MKR1000 and the IOT section.
After that my board is recognized from "Devices" I starded to create some "Thing".
I have all my sensor connected but after creating the dashboard it display nothing.
In each chart is appearing: "No data received yet".
here to code:
/*
Sketch for automatic indoor garden project. More info: https://www.makerguides.com
Arduino IoT Cloud Properties description
The following variables are automatically generated and updated when changes are made to the Thing properties
float soilMoistureContent;
CloudTemperatureSensor temperature;
CloudRelativeHumidity humidity;
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"
#include "LiquidCrystal_I2C.h"
#define DHTPIN A1
#define DHTTYPE DHT21
#define RELAYPIN 1
#define SOILPIN A2
DHT dht = DHT(DHTPIN, DHTTYPE);
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 20, 4);
const unsigned long pumpPeriod = 20000;
const unsigned long waitPeriod = 120000;
unsigned long previousMillis;
float moistureSensorData;
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(4);
ArduinoCloud.printDebugInfo();
pinMode(LED_BUILTIN, OUTPUT);
pinMode(RELAYPIN, OUTPUT);
dht.begin();
lcd.init();
lcd.backlight();
}
void loop() {
ArduinoCloud.update();
// Your code here
temperature = dht.readTemperature();
humidity = dht.readHumidity();
lcd.setCursor(0, 0);
lcd.print("Temperature:");
lcd.setCursor(13, 0);
lcd.print(temperature);
lcd.print("\xDf" "C");
lcd.setCursor(0, 1);
lcd.print("Humidity:");
lcd.setCursor(10, 1);
lcd.print(humidity);
lcd.print("%");
moistureSensorData = analogRead(SOILPIN);
//Serial.println(moistureSensorData);
soilMoistureContent = map(moistureSensorData, 883, 469, 0, 100);
soilMoistureContent = constrain(soilMoistureContent, 0, 100);
lcd.setCursor(0, 2);
lcd.print("Soil moisture:");
lcd.setCursor(15, 2);
lcd.print(soilMoistureContent, 0);
lcd.print("% ");
if (soilMoistureContent <= 30 && millis() - previousMillis >= waitPeriod) {
digitalWrite(RELAYPIN, HIGH);
digitalWrite(LED_BUILTIN, HIGH);
delay(pumpPeriod);
digitalWrite(RELAYPIN, LOW);
digitalWrite(LED_BUILTIN, LOW);
previousMillis = millis();
}
}
thanks for your support