Variables not updating from Android with IoT

I'm trying to control a motor through IoT, and was able to get the motor to work on its own, and the IoT from the IoT Remote app to work on its own, but not both of them together and I'm stumped.

The dashboard looks like this:

image

The scheduler isn't being used yet.

Here is my code:

/*
  Sketch generated by the Arduino IoT Cloud Thing "Coop Control"
  https://create.arduino.cc/cloud/things/4217e43c-751f-4f0f-9f0c-3b0e77887e97

  Arduino IoT Cloud Variables description

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

  CloudSchedule schedule_variable;
  bool door_Motor;

  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"

#define ENCA 2 // YELLOW
#define ENCB 3 // WHITE
#define PWM 5
#define IN2 6
#define IN1 7

volatile int posi = 0; // specify posi as volatile: https://www.arduino.cc/reference/en/language/variables/variable-scope-qualifiers/volatile/
long prevT = 0;
float eprev = 0;
float eintegral = 0;
int dir;
int pos;
int target;
float pwr;

void setup() {
  Serial.begin(9600);
  delay(500);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(ENCA,INPUT);
  pinMode(ENCB,INPUT);
  attachInterrupt(digitalPinToInterrupt(ENCA),readEncoder,RISING);
  
  pinMode(PWM,OUTPUT);
  pinMode(IN1,OUTPUT);
  pinMode(IN2,OUTPUT);
  
  Serial.println("target pos");
  
  
  // 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();
  
  //This uses the scheduler to turn the LED on at a set time and duration every day. Use to toggle the door open
//and close every day at a specific time.
  
//   if(schedule_variable.isActive()){
// digitalWrite(LED_BUILTIN, HIGH);
// }
// // whenever the job is "not active", turn off the LED
// else{
// digitalWrite(LED_BUILTIN, LOW);  
// }

  
  // set target position
  //target = 7000;

  // PID constants
  float kp = 1;
  float kd = 0.025;
  float ki = 0.0;

  // time difference
  long currT = micros();
  float deltaT = ((float) (currT - prevT))/( 1.0e6 );
  prevT = currT;

  // Read the position
  pos = 0; 
  noInterrupts(); // disable interrupts temporarily while reading
  pos = posi;
  interrupts(); // turn interrupts back on
  
  // error
  int e = target - pos;

  // derivative
  float dedt = (e-eprev)/(deltaT);

  // integral
  eintegral = eintegral + e*deltaT;

  // control signal
  float u = (kp*e + kd*dedt + ki*eintegral);

  // motor power
  pwr = fabs(u);
  if(pwr > 255){
    pwr = 255;
  }

  // motor direction
    //int dir = 1; //Clockwise
    //if(u<0){
    //  dir = -1;
    //}
    
  checkTarget(target);
    


  // signal the motor
  
  if (door_Motor == 1) {
    target = 7000;
    dir = 1;
    setMotor(dir,pwr,PWM,IN1,IN2);
  } else if (door_Motor == 0) {
    target = 0;
    dir = -1;
    setMotor(dir,pwr,PWM,IN1,IN2);
  }
  


  //On door open or close
  onDoorMotorChange();
  Serial.println(door_Motor);

  // store previous error
  eprev = e;


if (e < 15) {
  //Serial.print("Motor off");
  dir = 0;
  //pwr = 0;
}


if (e > 15) {
  Serial.print(target);
  Serial.print(" ");
  Serial.print(pos);
  Serial.println();
}
 
}

void checkTarget(int target) {
  
  if (target == 7000 && pos == 0) {
    dir = 1; //CW
  } else if (pos > 6500){
    delay(1000);
    target = 0;
    dir = -1; //CCW
  } else if (pos < 0) {
    dir = 0;
  }
}

void setMotor(int dir, int pwmVal, int pwm, int in1, int in2){
  analogWrite(pwm,pwmVal);
  if(dir == 1){
    digitalWrite(in1,HIGH);
    digitalWrite(in2,LOW);
  }
  else if(dir == -1){
    digitalWrite(in1,LOW);
    digitalWrite(in2,HIGH);
  }
  else{
    digitalWrite(in1,LOW);
    digitalWrite(in2,LOW);
    
  }  
}

void readEncoder(){
  int b = digitalRead(ENCB);
  if(b > 0){
    posi++;
  }
  else{
    posi--;
  }
}

/*
  Since DoorMotor is READ_WRITE variable, onDoorMotorChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onDoorMotorChange()  {
  // Add your code here to act upon DoorMotor change
  if (door_Motor == 1) {
  digitalWrite(LED_BUILTIN, HIGH);
  } else if (door_Motor == 0) {
    digitalWrite(LED_BUILTIN, LOW);
}
}

/*
  Since ScheduleVariable is READ_WRITE variable, onScheduleVariableChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onScheduleVariableChange()  {
  // Add your code here to act upon ScheduleVariable change
}

I'm pretty sure how I have the motor set up currently doesn't work, but that's okay I'm just trying to iron out this IoT thing. At the very least the motor should be turning on and off when I toggle the switch on the dashboard. I'm printing the door_Motor variable to serial and it just shows a constant 0 no matter what the switch is set to.

When I was testing the IoT part on its own, the variable would update almost instantly. Maybe something with the loop and motor is preventing that speedy update? I saw one other forum post that said their variables took 7-30 minutes to update. I think I also don't quite understand how the onDoorMotorChange function is being used, but I tried a couple different things with that too and it didn't seem to change anything. Any suggestions are appreciated, thanks.

Hi @rookiepresent

This is not the case! you should see the change in a couple of seconds.

Management of variables between your thing(s) and a dashboard takes a bit of understanding. You are correct that the door control needs to be read/write to send the value of the on off switch to your thing. So that we can help you, please post your thingProperties.h from the full editor and your dashboard setup? What is the variable linked to Door Control? Should be a Boolean
I presume under Devices you can see your device is online to the cloud?

Sure, I can put together those things. Yes, everything looked normal as far as connection to the Cloud.

Here is the Door Control variable:

image

The Dashboard:

image

I'm not using the scheduler at the moment. For right now I'm just trying to, essentially, be able to control the motor from my phone. Before when I was testing IoT with the same dashboard and the onboard LED, I could toggle the switch on the dashboard and see the LED light on and off at at almost the same time. I thought the scheduler was interfering so made sure it was disabled, and I am 99% sure it's completely disabled and doing nothing at the moment.

Something I noticed too is a lot of variance in how quickly the serial readout begins and let's me know it's connected not only to the Nano, but also to the wifi. Maybe hesitancy there is a factor? To rule that out I let it run for several minutes and ensured I got all the proper "Connected to Wifi" messages, and it didn't change anything but I thought it was worth mentioning.

Here is the code from thingProperties.h:

// 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_PASS;    // Network password (use for WPA, or use as key for WEP)

void onScheduleVariableChange();
void onDoorMotorChange();

CloudSchedule schedule_variable;
bool door_Motor;

void initProperties(){

  ArduinoCloud.addProperty(schedule_variable, READWRITE, ON_CHANGE, onScheduleVariableChange);
  ArduinoCloud.addProperty(door_Motor, READWRITE, ON_CHANGE, onDoorMotorChange);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

Thank you!

Hi @rookiepresent

I don’t think you should need this code in your loop?
Put the debug print in the function.
It will be called automatically on change from the

In the loop.

Hi @rookiepresent
Just a structure/style observation, this code:

Could be achieved with:


void onDoorMotorChange()  
{
  digitalWrite(LED_BUILTIN, door_Motor);
}

Thanks for that, I appreciate the style tip because that is a much nicer way of writing that!

I am still having issues getting this program to work. I ran it and got this serial output:

0
ArduinoIoTCloudTCP::handle_ConnectMqttBroker could not connect to mqtts-sa.iot.arduino.cc:8883
ArduinoIoTCloudTCP::handle_ConnectMqttBroker 1 connection attempt at tick time 28549
0
0
0
0
0
0
0
0
0
0
Connected to Arduino IoT Cloud
Thing ID: 4217e43c-751f-4f0f-9f0c-3b0e77887e97
0
0
0
0
0
0
0
0
0
0

So there was a struggle to connection, but also once the connection was there it didn't change anything.
The 0 meaning the value of the boolean in false, but when I look at the "last value" for the variable on the website, it says it's true. I watch the output spit out zeros as I am toggling the switch on the dashboard and there is just a disconnect somewhere. Any idea why I'm experiencing this?

I just discovered something else that I think is related:

Because the IoT isn't working, I am trying to be able to control the motor with a button. I made a separate program to test the button, and it works fine and toggles the builtin LED just fine. But when I transfer that code into my main program, it doens't work as expected. Here is the full code again:

/*
  Sketch generated by the Arduino IoT Cloud Thing "Coop Control"
  https://create.arduino.cc/cloud/things/4217e43c-751f-4f0f-9f0c-3b0e77887e97

  Arduino IoT Cloud Variables description

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

  CloudSchedule schedule_variable;
  bool door_Motor;

  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"

#define ENCA 2 // YELLOW
#define ENCB 3 // WHITE
#define PWM 5
#define IN2 6
#define IN1 7


int Btn = 20;

volatile int posi = 0; // specify posi as volatile: https://www.arduino.cc/reference/en/language/variables/variable-scope-qualifiers/volatile/
long prevT = 0;
float eprev = 0;
float eintegral = 0;
int dir;
int pos;
int target;
float pwr;

void setup() {
  Serial.begin(9600);
  delay(500);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(ENCA,INPUT);
  pinMode(ENCB,INPUT);
  attachInterrupt(digitalPinToInterrupt(ENCA),readEncoder,RISING);
  
  pinMode(PWM,OUTPUT);
  pinMode(IN1,OUTPUT);
  pinMode(IN2,OUTPUT);
  pinMode(Btn, INPUT_PULLUP);
  
  Serial.println("target pos");
  
  
  // 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();
  
  //This uses the scheduler to turn the LED on at a set time and duration every day. Use to toggle the door open
//and close every day at a specific time.
  
//   if(schedule_variable.isActive()){
// digitalWrite(LED_BUILTIN, HIGH);
// }
// // whenever the job is "not active", turn off the LED
// else{
// digitalWrite(LED_BUILTIN, LOW);  
// }

  
  // set target position
  //target = 7000;

  // PID constants
  float kp = 1;
  float kd = 0.025;
  float ki = 0.0;

  // time difference
  long currT = micros();
  float deltaT = ((float) (currT - prevT))/( 1.0e6 );
  prevT = currT;

  // Read the position
  pos = 0; 
  noInterrupts(); // disable interrupts temporarily while reading
  pos = posi;
  interrupts(); // turn interrupts back on
  
  // error
  int e = target - pos;

  // derivative
  float dedt = (e-eprev)/(deltaT);

  // integral
  eintegral = eintegral + e*deltaT;

  // control signal
  float u = (kp*e + kd*dedt + ki*eintegral);

  // motor power
  pwr = fabs(u);
  if(pwr > 255){
    pwr = 255;
  }

  // motor direction
    //int dir = 1; //Clockwise
    //if(u<0){
    //  dir = -1;
    //}
    
  checkTarget(target);
  int buttonValue = digitalRead(Btn);
  if (buttonValue == LOW) {
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.println("button press");
  } else {
    digitalWrite(LED_BUILTIN, LOW);
  }

  // signal the motor
  
  if (door_Motor == 1) {
    target = 7000;
    dir = 1;
    setMotor(dir,pwr,PWM,IN1,IN2);
  } else if (door_Motor == 0) {
    target = 0;
    dir = -1;
    setMotor(dir,pwr,PWM,IN1,IN2);
  }
  


  //On door open or close
  onDoorMotorChange();
  

  // store previous error
  eprev = e;


if (e < 15) {
  //Serial.print("Motor off");
  dir = 0;
  //pwr = 0;
}


if (e > 15) {
  Serial.print(target);
  Serial.print(" ");
  Serial.print(pos);
  Serial.println();
}
 
}

void checkTarget(int target) {
  
  if (target == 7000 && pos == 0) {
    dir = 1; //CW
  } else if (pos > 6500){
    delay(1000);
    target = 0;
    dir = -1; //CCW
  } else if (pos < 0) {
    dir = 0;
  }
}

void setMotor(int dir, int pwmVal, int pwm, int in1, int in2){
  analogWrite(pwm,pwmVal);
  if(dir == 1){
    digitalWrite(in1,HIGH);
    digitalWrite(in2,LOW);
  }
  else if(dir == -1){
    digitalWrite(in1,LOW);
    digitalWrite(in2,HIGH);
  }
  else{
    digitalWrite(in1,LOW);
    digitalWrite(in2,LOW);
    
  }  
}

void readEncoder(){
  int b = digitalRead(ENCB);
  if(b > 0){
    posi++;
  }
  else{
    posi--;
  }
}

/*
  Since DoorMotor is READ_WRITE variable, onDoorMotorChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onDoorMotorChange()  {
  // Add your code here to act upon DoorMotor change
  if (door_Motor == 1) {
  digitalWrite(LED_BUILTIN, HIGH);
  } else if (door_Motor == 0) {
    digitalWrite(LED_BUILTIN, LOW);
}
  Serial.println(door_Motor);
  delay(1000);
}

/*
  Since ScheduleVariable is READ_WRITE variable, onScheduleVariableChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onScheduleVariableChange()  {
  // Add your code here to act upon ScheduleVariable change
}

The part that I added is here:


void setup() {
  Serial.begin(9600);
  delay(500);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(ENCA,INPUT);
  pinMode(ENCB,INPUT);
  attachInterrupt(digitalPinToInterrupt(ENCA),readEncoder,RISING);
  
  pinMode(PWM,OUTPUT);
  pinMode(IN1,OUTPUT);
  pinMode(IN2,OUTPUT);
  pinMode(Btn, INPUT_PULLUP);
  
  Serial.println("target pos");
  
  
  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}


  int buttonValue = digitalRead(Btn);
  if (buttonValue == LOW) {
    digitalWrite(LED_BUILTIN, HIGH);
    Serial.println("button press");
  } else {
    digitalWrite(LED_BUILTIN, LOW);
  }

What I don't understand is that the LED doesn't turn on, but the "button press" shows up in the serial. So I know the code works but the LED isn't turning on, and something is blocking it. I think something about my code is blocking certain features, and what is blocking this LED is blocking the IoT from working. But I can't figure out why, I am not great at programming and I am just more confused. What is going on here?

Good observation! So I can think of two things that could cause this
1). The device is so busy with other tasks that it is not picking up the change of state
2) something in your code is overwriting the value from cloud with 0.

So to find out set the value true in your setup
If it stays true then 1) is likely. (This could be the cause of your sluggish connection also).

So this may indicate 2)!

Rather than adding new code simplify your current code - by commenting out // until it works and gradually add lines back in until it fails.

I messed around with variations of the code that I've already shared with no success, so I decided to first get the IoT connection to work and then add stuff to that. However, even with the simplest code I could muster I cannot get it to work.

My main program is this:

/*
  Sketch generated by the Arduino IoT Cloud Thing "Coop Control"
  https://create.arduino.cc/cloud/things/4217e43c-751f-4f0f-9f0c-3b0e77887e97

  Arduino IoT Cloud Variables description

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

  bool door_Motor;

  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() {
  Serial.begin(9600);
  delay(100);
  pinMode(LED_BUILTIN, OUTPUT);

  

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection, false);

  /*
     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();
  onDoorMotorChange();

}


/*
  Since DoorMotor is READ_WRITE variable, onDoorMotorChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onDoorMotorChange()  {


if(door_Motor){
 
    digitalWrite(LED_BUILTIN,HIGH);
 
  }else{
 
    digitalWrite(LED_BUILTIN,LOW);
 
  }

}


And the header file hasn't changed I think, but it's here:

// 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_PASS;    // Network password (use for WPA, or use as key for WEP)

void onDoorMotorChange();

bool door_Motor;

void initProperties(){

  ArduinoCloud.addProperty(door_Motor, READWRITE, ON_CHANGE, onDoorMotorChange, 5);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

When I first got my Arduino I did a similar test and got it to work, but now I cannot replicate it. I toggle the switch on the dashboard from the phone and the LED doesn't do anything. I get the message "Connected to IoT" and the ediot shows my Nano is online. It must be a programming issue. What am I doing wrong?

The call to onDoorMotorChange(); should not be required. It will be called when the update detects a change.

Serial.println("Door Changed");

to your onDoorMotorChange() routine and you should see it getting called

@rookiepresent - Your code is fundamentally OK

I have just created a similar sketch and connected to AIoTC ok.
Here is my serial output

{$␀l��|␀�d�|␃␌␄␌�␌l�␌#|��␃�␛�s�b�␌c��'o�$g'���␄c␜p��dsdsdp�'�␐␂␄␌�␄l␄��␄␌␄c␌o�|␃l�␄␌�c��g'�␀lćd`␂�␛␒'o␌$`␃␎␃gs���o␌␄b␄�␏$␏r��g␄␌c␌�␇l�␓l�x␃���␓�`␃��'�␃***** Arduino IoT Cloud - configuration info *****
Device ID: e56cabf4-331b-4870-957a-13c770d2ee1e
MQTT Broker: mqtts-up.iot.arduino.cc:8884
WiFi status ESP: 0
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connection to "iiNet3F932B" failed
Retrying in  "500" milliseconds
Connected to "iiNet3F932B"
Connected to Arduino IoT Cloud
Thing ID: 0e0faf3f-612c-44fc-844e-b18b3961399d
Door Motor Changed :0
ArduinoIoTCloudTCP::setTimeZoneData tz_offset: [-14400]
ArduinoIoTCloudTCP::setTimeZoneData tz_dst_unitl: [1667714400l]
Door Motor Changed :1
Door Motor Changed :0
Door Motor Changed :1
Door Motor Changed :0
Door Motor Changed :1
Door Motor Changed :0

The initial garbage after restart is due to me using a ESP8322 and initially the baud rate is an odd value. Then I have set it to 115200 and the rest is OK.
You will see it takes several seconds to connect to my WiFi and then it takes several to fully initialise the AIoTC connection.

The LED and message were responding to the switch on the dashboard within a second.
image

Here is the code:

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Door Motor Test"
  https://create.arduino.cc/cloud/things/0e0faf3f-612c-44fc-844e-b18b3961399d 

  Arduino IoT Cloud Variables description

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

  bool doorMotor;

  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(115200);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500); 
   pinMode(LED_BUILTIN, OUTPUT);
   digitalWrite(LED_BUILTIN,doorMotor);

  // 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(4);
  ArduinoCloud.printDebugInfo();
}

void loop() {
  ArduinoCloud.update();
  // Your code here 
  
  
}

/*
  Since DoorMotor is READ_WRITE variable, onDoorMotorChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onDoorMotorChange()  {
  // Add your code here to act upon DoorMotor change
  digitalWrite(LED_BUILTIN,!doorMotor);
  //DEBUG 
  Serial.print("Door Motor Changed :");
  Serial.println(doorMotor);
}

Although I have used the same Arduino Web as you have on this occasion, I prefer to use PlatformIO as my IDE.  I find it much more informative and easier to debug code.  However, there is ,as always, a learning curve.

I think you need to be looking to your hardware set up and WiFi connection.

In wrote up a long reply about how it wasn't working, but I noticed something as I was comparing my code to your example: I was missing the function call for initPropeties()!

I added that back in, and now I am able to toggle the switch and get the proper change show up in the serial. Added that to the original code and I can control the motor from my phone no problem. Thank you for all your help, I really appreciate it!

void setup() {
  Serial.begin(115200);
  delay(1500);
  pinMode(LED_BUILTIN, OUTPUT);

  // Defined in thingProperties.h
  initProperties();                          // <--- VERY IMPORTANT

  // 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();
}

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