I am building a Thing made of:
- Arduino MKR1000 Wifi
- Grove SHT31 Temperature and Humidity Sensor board
- Arduino Grove Connector Carrier
The sketch is as follows,
// SHT31 - Version: Latest
#include <Wire.h>
#include <SHT31.h>
/*
Sketch generated by the Arduino IoT Cloud Thing "Rua Haiti 366 Pinhais PR"
https://create.arduino.cc/cloud/things/92327cab-e5ca-4779-86f1-1d07770aff79
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float outdoor_Temperature;
float outdoor_Humidity;
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"
SHT31 sht;
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
Wire.begin();
sht.begin(0x44);
Wire.setClock(100000);
Serial.print("Read Status: ");
Serial.println(sht.readStatus(), HEX);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(12000);
// 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();
// Wait for connection with Arduino IoT Cloud
while (!ArduinoCloud.connected()) {
delay(3000);
Serial.println("NOT connected to the cloud yet...");
ArduinoCloud.update();
}
}
void loop() {
ArduinoCloud.update();
if (sht.isConnected() && sht.dataReady()) {
Serial.println("Getting data!");
sht.read();
outdoor_Humidity = sht.getHumidity();
outdoor_Temperature = sht.getTemperature();
Serial.print("Temperature (deg C): ");
Serial.println(outdoor_Temperature, 1);
Serial.print("Humidity (%): ");
Serial.println(outdoor_Humidity, 1);
delay(10000);
}
}
The thingProperties.h is below,
// Code generated by Arduino IoT Cloud, DO NOT EDIT.
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
const char THING_ID[] = "92327cab-e5ca-4779-86f1-1d07770aff79";
const char SSID[] = SECRET_SSID; // Network SSID (name)
const char PASS[] = SECRET_PASS; // Network password (use for WPA, or use as key for WEP)
float outdoor_Temperature;
float outdoor_Humidity;
void initProperties(){
ArduinoCloud.setThingId(THING_ID);
ArduinoCloud.addProperty(outdoor_Temperature, READ, 30 * SECONDS, NULL, 1);
ArduinoCloud.addProperty(outdoor_Humidity, READ, 30 * SECONDS, NULL, 1);
}
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);
The Dashboard has never displayed any measurements. It only sits there, stuck at 0 for the Humidity and 22 for the Temperature.
The Device appears as Online.
After resetting the Device, the serial logs were obtained, like shown below:
***** Arduino IoT Cloud - configuration info *****
Device ID: e7478ab1-dcd7-484a-b8d2-f21a3b4a4748
Thing ID: 92327cab-e5ca-4779-86f1-1d07770aff79
MQTT Broker: mqtts-sa.iot.arduino.cc:8883
NOT connected to the cloud yet...
WiFi.status(): 0
Current WiFi Firmware: 1.4.5
NOT connected to the cloud yet...
Connected to "Policia Federal"
NOT connected to the cloud yet...
NOT connected to the cloud yet...
ArduinoIoTCloudTCP::handle_SubscribeMqttTopics could not subscribe to /a/t/92327cab-e5ca-4779-86f1-1d07770aff79/e/i
Check your thing configuration, and press the reset button on your board.
Getting data!
Temperature (deg C): 15.5
Humidity (%): 45.3
ArduinoIoTCloudTCP::handle_SubscribeMqttTopics could not subscribe to /a/t/92327cab-e5ca-4779-86f1-1d07770aff79/e/i
Check your thing configuration, and press the reset button on your board.
Getting data!
Temperature (deg C): 15.5
Humidity (%): 44.8
ArduinoIoTCloudTCP::handle_SubscribeMqttTopics MQTT client connection lost
After the last line, the ArduinoCloud.update() keeps printing that it could not subscribe to the MQTT topic.
Has anyone had the same problem?
Thank you for your inputs,
-nu