Non responsive pins on IoT Cloud

Hello,

I'm beginning with Arduino IoT Cloud, and I have difficulties with it.

I started using my new Arduino Nano 33 IoT on the classic IDE. I added a LED with a resistor on one pin (14) and a potentiometer on an other pin (A2). Everything work nicely on the IDE on the computer. I can read the value of the potentiometer and make the LED blinks. So my circuit seems to be correct.

I started having issue when I tried to use the IoT Cloud. I have followed this tutorial. I manage to turn ON and OFF the built in led on pin 13 using the dashboard.

However I'm unable to turn on the LED on pin 14. I defined the variable light14 with the same parameter as the variable light for pin 13, copied and adjusted the function in the program. I added a button on the dashboard. But when I click on it, nothing happens. I checked the pin with a voltmeter, who indicates 0V no matter the position of the switch on the dashboard.

I have a similar issue with the potentiometer. I created a variable as read only, with periodic update. I added a gauge on the dashboard and connected it to the variable. But the gauge always shows the same value - apparently the first measurement after uploading the program in the card. I also checked with the voltmeter. The tension of the pin varies with the position of potentiometer.

Does anyone have a clue ?

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Simple Blink"
  https://create.arduino.cc/cloud/things/7ae591fd-5e0b-445b-a44d-09b9b742e5fe 

  Arduino IoT Cloud Variables description

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

  bool light;
  float potentiometre;
  bool light14;

  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"

int PINLED = 13;
int PINLED_14 = 14;
byte PIN_POTENTIOMETER = A2;

void setup() {
  
  pinMode(PINLED, OUTPUT);
  pinMode(PINLED_14, OUTPUT);
  pinMode(PIN_POTENTIOMETER, INPUT);
  
  // 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 
  
  
}

void onLightChange() {
  // Do something
  digitalWrite(PINLED, light);
  Serial.print("The light is ");
  if (light) {
    Serial.println("ON");
  } else {
    Serial.println("OFF");
  }
}



void onLight14Change() {
  digitalWrite(PINLED_14, light14);
  Serial.print("The light 14 is ");
  if (light14) {
    Serial.println("ON");
  } else {
    Serial.println("OFF");
  }
}


void onPotentiometreChange() {
  // Do something
  int val = analogRead(PIN_POTENTIOMETER);
  potentiometre = val / 1024. * 100.;
}

The definition of the variables :



The dashboard :



Hi

I kept trying to use my Nano Arduino 33 IoT with the IoT Cloud. I'm sharing with you my results :

  • You can control most of the pins of the cards, except 3 : pin 14, pin 18 and 19 (their voltage seems to remain on some value, lower than 3V3, higher than 2V). Maybe it comes from the special roles of theses pins (pin 14 -> DAC0, pin 17 and 18 -> SDA and SCL)

  • I wasn't using a correct method for reading the potentiometer. You just need to add "potentiometer = analogRead(pin)" inside the loop for updating a value in the dashboard. The "OnChange" functions allow you to transmit a variable from the cloud to the card, but not the other way.

  • the most common variable names are forbidden. You need to be a bit inventive by choosing the name of the variables (you cannot use PIN_LED, PIN_LED_13, switch, for example)

I hope this may help someone else.

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