ArduinoCloud.update(); Causing problem

So I am taking input from Joystick and printing on serial monitor. Next I use the value to control motor through BTS79680 motor driver. The board I'm using is ESP32 DO IT DEV KIT. Everything works fine. But when I try to connect to cloud using ArduinoCloud.update(); in Arduino IoT platform. The values of X and Y potentiometer goes to 0.

code:
<CODE

/*

Sketch generated by the Arduino IoT Cloud Thing "Untitled"

https://create.arduino.cc/cloud/things/441bf62b-e252-4e42-8611-87de516d573e



Arduino IoT Cloud Variables description



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



bool backward;

bool forward;



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 xPin 4

#define yPin 15



int xVal;

int yVal;



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



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



pinMode(13,OUTPUT);

pinMode(12,OUTPUT);

pinMode(xPin,INPUT);

pinMode(yPin,INPUT);



}



void loop (){

ArduinoCloud.update();

// Analog readings

xVal = analogRead(xPin);

yVal = analogRead(yPin);



// Map xVal and yVal to a suitable range for your application

xVal = map(xVal, 0, 1023, 0, 255);

yVal = map(yVal, 0, 1023, 0, 255);



Serial.print("xVal= ");

Serial.print(xVal);

Serial.print(" yVal= ");

Serial.println(yVal);



delay(500);



// Digital output based on xVal

if (xVal > 500) {

digitalWrite(13, HIGH);

} else {

digitalWrite(13, LOW);

}



if (xVal < 400) {

digitalWrite(12, HIGH);

} else {

digitalWrite(12, LOW);

}

}





/*

Since Forward is READ_WRITE variable, onForwardChange() is

executed every time a new value is received from IoT Cloud.

*/

void onForwardChange() {



// Add your code here to act upon Forward change

}



/*

Since Backward is READ_WRITE variable, onBackwardChange() is

executed every time a new value is received from IoT Cloud.

*/

void onBackwardChange() {



// Add your code here to act upon Backward change

}



/*

Since Forward is READ_WRITE variable, onForwardChange() is

executed every time a new value is received from IoT Cloud.

*/

Serial Monitor:
***** Arduino IoT Cloud - configuration info *****

Device ID: 07553d19-0555-4b77-9686-2a445fc79397

MQTT Broker: mqtts-up.iot.arduino.cc:8884

WiFi.status(): 255

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

Connection to "Rajesh-2.4G" failed

Retrying in "4000" milliseconds

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

Connected to "Rajesh-2.4G"

xVal= 0 yVal= 0

TimeServiceClass::sync Drift: -1704724969 RTC value: 1704724981

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

xVal= 0 yVal= 0

@icarewheel are you sure this is not related to this ? Conflict Between Wifi & analogRead()? · Issue #102 · espressif/arduino-esp32 · GitHub

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