Fast counter problem IOT CLOUD

hey im having a problem with the arduino cloud counter, i did a simmilar code on the arduino ide and it works, but when it comes to the cloud IOT it thosent work, i think it's because the iot cloud serial is to slow or something like this, please help :slight_smile:
'''

int millisVeloc;
int veloc;
int Metrosveloc;
int Metrosveloc1;
boolean metros = false;
boolean metrosant;
int metrosacu = 0;
const int PushButton =18;
void setup()
{
pinMode(18, INPUT);//Defina o pino 18 como entrada.
Serial.begin (115200);
}
void loop()
{
metros=digitalRead(PushButton);
if(metros != metrosant){// verifica se mudou a leitura do encoder1
if (metros== HIGH){
metrosacu=metrosacu+1;

}}
metrosant = metros;

// Verifica se já passou 200 milisegundos- faz calculo de velocidade
if((millis() - millisVeloc) > 200){
Serial.print ("veloc = ");
Metrosveloc1 = (metrosacu - Metrosveloc);
Serial.print (Metrosveloc1*0.6);// Velocidade leitura a cada 200ms
Serial.print (" metros = ");
Serial.println (metrosacu/500);// Metragem acumulada
millisVeloc = millis();
Metrosveloc = metrosacu;
}}
'''

this code above is the one that is working on the arduino ide.

the code im trying to use on the iot cloud
'''
/*

float metrosacu;

*/
int millisVeloc;
int veloc;
int Metrosveloc;
int Metrosveloc1;
boolean metros = false;
boolean metrosant;
const int PushButton =18;
#include "thingProperties.h"

void setup() {
pinMode(18, 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);
metrosacu=10;
// 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();
metros=digitalRead(PushButton);
if(metros != metrosant){// verifica se mudou a leitura do encoder1
if (metros== HIGH){
metrosacu=metrosacu+1;

}}
metrosant = metros;

// Verifica se já passou 200 milisegundos- faz calculo de velocidade
if((millis() - millisVeloc) > 200){
Serial.print ("veloc = ");
Metrosveloc1 = (metrosacu - Metrosveloc);
Serial.print (Metrosveloc1*0.6);// Velocidade leitura a cada 200ms
Serial.print (" metros = ");
Serial.println (metrosacu/500);// Metragem acumulada
millisVeloc = millis();
Metrosveloc = metrosacu;
}

}
'''

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