Unable to verify MKR_ENV sketch

Hi,

I've attempted to verify the sketch example in the tutorial - https://docs.arduino.cc/tutorials/mkr-env-shield/mkr-env-shield-basic

I've just copied & pasted the sketch after connecting the MKR 1010 with MKR_ENV shield attached to Arduino.cc IOT Cloud which provided the "connect to IOT Cloud" part of the sketch - it shows up as a Device with a Thing ID

Hoping for assistance - thanks

I get this error on Line 53:

/usr/local/bin/arduino-cli compile --fqbn arduino:samd:mkrwifi1010 --libraries /home/builder/opt/libraries/latest --build-cache-path /tmp --output-dir /tmp/004756163/build --build-path /tmp/arduino-build-D4B1E6A391A5D6CEE48DCC184FD58E6D --library /home/builder/opt/libraries/arduino_mkrenv_1_2_1 --library /home/builder/opt/libraries/arduinocloudthing_1_7_3 /tmp/004756163/Untitled_jan21a

Using library adafruit_sleepydog_library_1_6_0 at version 1.6.0 in folder: /home/builder/opt/libraries/adafruit_sleepydog_library_1_6_0

Using library SPI at version 1.0 in folder: /home/builder/.arduino15/packages/arduino/hardware/samd/1.8.12/libraries/SPI

/tmp/004756163/Untitled_jan21a/Untitled_jan21a.ino: In function 'void loop()':

/tmp/004756163/Untitled_jan21a/Untitled_jan21a.ino:53:14: error: a function-definition is not allowed here before '{' token

void setup() {

^

/tmp/004756163/Untitled_jan21a/Untitled_jan21a.ino:64:13: error: a function-definition is not allowed here before '{' token

void loop() {

^

/tmp/004756163/Untitled_jan21a/Untitled_jan21a.ino:105:1: error: expected '}' at end of input

}

^

Error during build: exit status 1

This is the Sketch:

// Arduino_MKRENV - Version: 1.2.1
#include <Arduino_MKRENV.h>

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/46709497-1584-4135-aed3-e05951c26154 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  float humidity;
  float illuminance;
  float pressure;
  float temperature;
  float uVA;

  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); 

  // 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 
#include <Arduino_MKRENV.h>

void setup() {
  Serial.begin(9600);
  while (!Serial);

  if (!ENV.begin()) {
    Serial.println("Failed to initialize MKR ENV shield!");
    while (1);
  }
}

void loop() {
  // read all the sensor values
  float temperature = ENV.readTemperature();
  float humidity    = ENV.readHumidity();
  float pressure    = ENV.readPressure();
  float illuminance = ENV.readIlluminance();
  float uva         = ENV.readUVA();
  float uvb         = ENV.readUVB();
  float uvIndex     = ENV.readUVIndex();     

  // print each of the sensor values
  Serial.print("Temperature = ");
  Serial.print(temperature);
  Serial.println(" °C");

  Serial.print("Humidity    = ");
  Serial.print(humidity);
  Serial.println(" %");

  Serial.print("Pressure    = ");
  Serial.print(pressure);
  Serial.println(" kPa");

  Serial.print("Illuminance = ");
  Serial.print(illuminance);
  Serial.println(" lx");

  Serial.print("UVA         = ");
  Serial.println(uva);

  Serial.print("UVB         = ");
  Serial.println(uvb);

  Serial.print("UV Index    = ");
  Serial.println(uvIndex);

  // print an empty line
  Serial.println();

  // wait 1 second to print again
  delay(1000);
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.