HCSR04 failes randomized in compiler

Hi everyone,

im confused about the usage of the HCSR04 library.

There are several variations at iot and sometimes the definision works, sometimes not.

For example:
#include <HCSR04.h>
UltraSonicDistanceSensor sr04(TRIG_PIN, ECHO_PIN);

Just a view minutes ago the codecheck throw an error at the line
UltraSonicDistanceSensor sr04(TRIG_PIN, ECHO_PIN);
It cant find the library(undefined device) . . .

A view seconds ago the compiler runs clean - no changes made!!!????
It's repeatable!


Post the actual error message, please.

A good example - compiled the whole code 2 times without failures.
No changes made, at third time i get this:

/tmp/167253859/LigthsOnWifi-TreppeUnten_jul22a/LigthsOnWifi-TreppeUnten_jul22a.ino:43:1: error: 'UltraSonicDistanceSensor' does not name a type; did you mean 'CloudContactSensor'? UltraSonicDistanceSensor sr04(TRIG_PIN, ECHO_PIN); ^~~~~~~~~~~~~~~~~~~~~~~~ CloudContactSensor

#include <HCSR04.h>
UltraSonicDistanceSensor sr04(TRIG_PIN, ECHO_PIN);

Post your code in code tags?

Makes no difference between things-editor and full editor.
Sometimes it works, sometimes not . .

If have to post code, i will post it in tags . . .

I dont wonder about this behavior.
The iot-Cloud knows 3 variants of HCSR04.
Guess it can't decide which to use.

// Simple_HCSR04 - Version: Latest
#include <Arduino.h>
// HCSR04 ultrasonic sensor - Version: Latest
#include <HCSR04.h>
// HCSR04 - Version: Latest
#include <HCSR04.h>

@ Idahowalker
Better? :wink:

I'm out. Good luck.

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