I am very new to Arduino. I am trying the 2nd project in on-line tutorial one gets when registering IoT kit. Project is called "Graphing Data in the Cloud".
My sketch compiles ok, and it loads ok. The display on MKR IoT Carrier first seems to indicate it found the WiFi SSID, but then continues to say "Waiting for Connection....
I have entered the SSID and Password for my WiFi network into the SECRET tab on the on-line editor: Arduino Cloud. I have reviewed many of the postings that seem to be related to this problem, but have not found the solution (but i'll continue to read more of them).
Hardware:
MKR WIFI 1010 with MKR IoT Carrier; laptop running Google Chrome
Here are error messages from Monitor:
Connection to "SummerPlaceGoogle" failed
Retrying in "500" milliseconds
Connection to "SummerPlaceGoogle" failed
Retrying in "500" milliseconds
Connection to "SummerPlaceGoogle" failed
Retrying in "500" milliseconds
Connection to "SummerPlaceGoogle" failed
Retrying in "500" milliseconds
Connected to "SummerPlaceGoogle"
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-sa.iot.arduino.cc:8883
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 1 connection attempt at tick time 42418
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-sa.iot.arduino.cc:8883
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 2 connection attempt at tick time 57537
Here is the sketch, (I have tried to use the code formatting, but not sure if i have that right.)
// BSEC Software Library - Version: 1.6.1480
#include <bsec.h>
/* Sketch generated by the Arduino IoT Cloud Thing "Untitled 2"
https://create.arduino.cc/cloud/things/4f977c30-c624-4b8c-8af6-6905f899ce7e
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
float humidity;
float temperature;
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 <Arduino_MKRIoTCarrier.h>
MKRIoTCarrier carrier;
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);
CARRIER_CASE = false;
carrier.begin();
/*
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();
//Wait to get cloud connection to init the carrier
while (ArduinoCloud.connected() != 1) {
ArduinoCloud.update();
carrier.display.setTextSize(3);
carrier.display.setCursor(20, 70);
carrier.display.println("Waiting For");
carrier.display.setCursor(5, 110);
carrier.display.println("Connection...");
delay(500);
}
}
void loop() {
ArduinoCloud.update();
// Your code here
carrier.Env.readTemperature();
carrier.Env.readHumidity();
temperature = carrier.Env.readTemperature();
humidity = carrier.Env.readHumidity();
Serial.print(temperature);
Serial.print(",");
Serial.println(humidity);
delay(1000);
}
And here is code autogenerated by Arduino IoT Cloud
// Code generated by Arduino IoT Cloud, DO NOT EDIT.
#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
const char SSID[] = SECRET_SSID; // Network SSID (name)
const char PASS[] = SECRET_OPTIONAL_PASS; // Network password (use for WPA, or use as key for WEP)
float humidity;
float temperature;
void initProperties(){
ArduinoCloud.addProperty(humidity, READ, 1 * SECONDS, NULL);
ArduinoCloud.addProperty(temperature, READ, 1 * SECONDS, NULL);
}
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);