(Solved)Nano RP2040 Compiling errors using the IoT Cloud

I've been following this tutorial closely:

and can't get past step 3: The Sketch

My Code:

#include "thingProperties.h"
#include <Arduino_LSM6DSOX.h>

void setup() {

  Serial.begin(9600);
  delay(1500);

  //define RGB LED as outputs
  pinMode(LEDR, OUTPUT);
  pinMode(LEDG, OUTPUT);
  pinMode(LEDB, OUTPUT);

  initProperties();

  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();

  //init IMU library
  if (!IMU.begin()) {
    Serial.println("Failed to initialize IMU!");
    while (1);
  }
}

void loop() {
  ArduinoCloud.update();

  //read acceleration and store in a_x, a_y, a_z variables
  if (IMU.accelerationAvailable()) {
    IMU.readAcceleration(a_x, a_y, a_z);
  }
}

/*
  the onRgbLightChange() function is triggered
  when the rgb_light variable changes
*/

void onRgbLightChange()  {
  //create r,g,b variables
  uint8_t r, g, b;

  //retrieve values from the cloud
  rgb_light.getValue().getRGB(r, g, b);

  //values on Nano RP2040 Connect are inverted
  //so let's remap them
  int red = map(r, 0, 255, 255, 0);
  int green = map(g, 0, 255, 255, 0);
  int blue = map(b, 0, 255, 255, 0);

  if (rgb_light.getSwitch()) {
    analogWrite(LEDR, red);
    analogWrite(LEDG, green);
    analogWrite(LEDB, blue);
  }
  else {
    analogWrite(LEDR, 255);
    analogWrite(LEDG, 255);
    analogWrite(LEDB, 255);
  }
}

When compiling I get this error:

Start verifying
/tmp/052423176/Watering_mar03a/Watering_mar03a.ino: In function 'void onRgbLightChange()':
/tmp/052423176/Watering_mar03a/Watering_mar03a.ino:56:17: error: 'class CloudColor' has no member named 'getSwitch'
if (rgb_light.getSwitch()) {
^~~~~~~~~
Error during build: exit status 1

/tmp/052423176/Watering_mar03a/Watering_mar03a.ino: In function 'void onRgbLightChange()':
/tmp/052423176/Watering_mar03a/Watering_mar03a.ino:56:17: error: 'class CloudColor' has no member named 'getSwitch'
if (rgb_light.getSwitch()) {
^~~~~~~~~
Error during build: exit status 1

Anything else can I provide in order to get some help?
TIA

Hi!

Instead of CloudColor, as the tutorial says, you have to create the variable of type CloudColoredLight.

You can check the full list of variables with its methods and properties here.

I hope this helps!

Thanks David,

One step closer,

axis shows they work, now I can't get the rgb_light to turn on.

Got it,
Went into things, Device, rgb_light 3 dots, Edit, moved option from "read only" to "Read and write".

1 Like

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