Iot cloud strange problem

Hi, I'm having problem with andruino iot cloud,
I've made simple test sketch, for measuring distance with ultrasonic sensor.
It works good as a standalone sketch (without arduino iot cloud), but, when it's used in iotcloud, I get problems, it connects, everything works but I'm getting value 0 returned as a distance at the dashboard, and also in serial monitor...
I could swear the sketch worked 10 days ago, it's frustrating..
Btw I tried the same with esp32 and esp8226.

Welcome @noobmastha!

We may need a bit more info to help!
In the the Things tab of the IOT portal can you see your device and that it is online?
What is your serial monitor showing?
While you get it going, I would recommend increasing the debug level to 4

  setDebugMessageLevel(4);
  ArduinoCloud.printDebugInfo();

It adds useful data about your connection

Yes, the device is online.
Let me clear a bit, when I measure distance in separate sketch, on the serial monitor I see 35cm printing over and over as it should, maybe,one in a 20 printing values is 0cm.
Now when I do that same exact thing, over the colud iot, on the serial monitor I get value 0cm printing, maybe one of the 50 prints is correct, 35cm.

I'm using Hc-sr04 and NewPing library, simple sketch for measuring distance with few lines of code..

Is your variable set for read and write? It should be read only
Also, on change or period?

Yes it's read only and is set to update on change.
When I set Debug level 4 nothing appears.
The strange thing is I tried this last week with esp8266 and it worked as it should.

I would try updating periodically (>2 seconds) and how are you time slicing between reading your sensor and sending to the cloud?

I had difficulty with an IC2 device because I was not allowing sufficient time to read

Only thing i have in void loop is
ArduinoCloud. update() ;
distance=sonar. ping_cm() ;

So you are not limiting the sonar? How many times a second does it trigger? Do a Serial.println(distance);
I would expect it to flood out!
I would introduce a timer (not delay) to trigger the sonar

Well I tried same exact sketch on Thiger.io cloud and it works. I'm new to coding, so maybe I'm missing something..

Hi @noobmastha
I’m glad you got your project to work with another IOT cloud.
Your project ‘should’ work with Arduino. You seem to be missing something in the configuration or code.
There are thousands of others who are successful but to help you further we would need to have more details and in particular your full sketch with thing properties.

Your serial port should show the device ID and thing ID and the attempt to connect etc.

I got time for ma hobby :grinning:
Thanks man, you were right, I used millis timer to do the measurement only once a second and now works fine.
Btw I think I've seen somewhere that there is a limit with sending data to arduino cloud of 10 times/s, if you use a free version.

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