BLE.h not found on conversion to iot platform

I have a fairly complicated spa controller running well on a Nano RP2040 connect. Its connected to the internet and talks to me one-way. I'd like to incorporate the iot platform to utilize 2 way communication with the controller. After creating a Thing and the passable variables and moving my code to the web editor I get the following compile error ... which I can't make heads or tails out of. An include in a library added in the background I assume. Don't know how to solve.

/usr/local/bin/arduino-cli compile --fqbn arduino:mbed_nano:nanorp2040connect --build-cache-path /tmp --output-dir /tmp/4214009066/build --build-path /tmp/arduino-build-227AE20ACE85AF39B053A416BDAB7052 /tmp/4214009066/Spa_Controller_iot

In file included from /home/builder/Arduino/libraries/phyphox_ble_1_2_0/src/phyphoxBle.h:51:0,

from /home/builder/Arduino/libraries/phyphox_ble_1_2_0/src/experiment.cpp:3:

/home/builder/Arduino/libraries/phyphox_ble_1_2_0/src/phyphoxBLE_NRF52.h:7:10: fatal error: ble/BLE.h: No such file or directory

#include <ble/BLE.h>

^~~~~~~~~~~

compilation terminated.

........
If i try to take the iot code pre-placed in the web editor to the local IDE, I get the following compile error. Which is even more perplexing. Ideally for me I'd like to stick to the IDE and add what it takes to interface with the dashboard.

panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x0 pc=0x7855fb]

disregard the second half ... that error is not related to the iot code. I did get a simple example to work with the dashboard after compiling and uploading from the local IDE. Am I correct in understanding that as the Device is linked to the Thing, that is how the data is routed to the correct dashboard?

I think you made a good guess. The error is coming from the "phyphox BLE" library. That library doesn't have explicit support for the Nano RP2040 Connect board you are using. It is using code that is intended for the Nano 33 BLE, which is the cause of the error.

The root cause is not clear to me at this time.

Every one of the thousands of libraries in the Arduino Library Manager are pre-installed in Arduino Cloud. This is very convenient because it means you don't need to worry about installing or updating the libraries. However, it can sometimes cause issues. The problem is that, for any common filename used in an #include directive in your sketch program, there may be multiple libraries that contain a file of that name. When this occurs, Arduino Cloud attempts to automatically pick the best library to use when compiling your sketch. It is pretty smart about this, but unfortunately doesn't always make the right choice. When that happens, we can get confusing errors. I'm not certain that is the cause, but if I had to guess I would say it is.

OK. Thanks for taking the time to post an update.

I see you expressed a preference to use Arduino IDE instead of Arduino Cloud for your sketch development. Since you now seem to have fixed the problem with Arduino IDE, do you consider the problem you reported in your first post to be resolved?

I am happy to help you investigate the problem you experienced with the "phyphox BLE" library while compiling the sketch in Arduino Cloud, but if you are already satisfied with using Arduino IDE instead then there isn't any benefit to you in doing such an investigation.

That is correct.

Appreciate the response. While the IDE is familiar and comfortable the web editor allows OTA updates which is hard to just pass on. With said, I would be interested in moving my code there if a solution is available.
Thank you.

OK. I'm going to ask you to post the full verbose output from compiling the sketch in Arduino Web Editor.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select "Preferences" from the menu on the left side of the "Arduino Web Editor" window.
    The preferences panel will open to the right of the menu.
  2. Check the box next to "☐ Always show output panel**" in the preferences panel.
  3. Check the box next to "☐ Console: Show verbose output**" in the preferences panel.
  4. Open the sketch that produced the error.
  5. Click the button ("Verify") in the sketch panel.
  6. Wait for the compilation to fail.
  7. Click the icon in the top right corner of the black console panel at the bottom of the "Arduino Web Editor" window that looks like two pieces of paper.
    Icon in the output panel
  8. Open a forum reply here by clicking the "Reply" button.
  9. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code tags icon on toolbar
  10. Press Ctrl+V.
    This will paste the compilation output into the code block.
  11. Move the cursor outside of the code tags before you add any additional text to your reply.
  12. Click the "Reply" button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:
    Upload icon on toolbar
    A dialog will open.
  6. In the dialog, select the .txt file you saved.
  7. Click the "Open" button.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

verbose output.txt (751.3 KB)

for what its worth .... I did create a new sketch in the web editor with just the raw spa code that is currently running successfully, without any of the iot prebuilt code that makes all the magic happen and .... it complies without error. So the problematic library must be external to my code.

While this is a question off topic I'm anxious to know .... but should I dump my wifinina code in my sketch since that is getting done behind the scenes by the connectionhandler? RTC code too?

OK, great. This is the information I was looking for:

Multiple libraries were found for "defines.h"

Used: /home/builder/opt/libraries/phyphox_ble_1_2_0

Not used: /home/builder/opt/libraries/crmui3_1_4_0

Not used: /home/builder/opt/libraries/vidorperipherals_1_1_0

Not used: /home/builder/opt/libraries/helios_0_4_1

Not used: /home/builder/opt/libraries/p1am_1_0_6

Not used: /home/builder/opt/libraries/spimemory_3_4_0

Not used: /home/builder/opt/libraries/vidorgraphics_1_1_0

Not used: /home/builder/opt/libraries/esp32_codec2_1_0_4

Not used: /home/builder/opt/libraries/escapeautomate_0_0_29

Not used: /home/builder/opt/libraries/eloquentesp32cam_1_1_2

Somewhere in your sketch program there is an #include directive for the filename defines.h. You can see that many of the libraries that are pre-installed in Arduino Cloud contain a file with this common name. The Arduino build system had chose one of those libraries while compiling the sketch. It picked the "phyphox BLE" library, but that wasn't necessarily the right one.

So the task now is to find this #include directive for defines.h in your sketch program and determine where it was intended to obtain that file from. Unfortunately even the verbose compilation output isn't giving me a lead on that. Would it be possible for you to share your sketch code so I can try to reproduce the error myself to proceed with the investigation?

Code attached.

I believe I built my sketch around a RP2040_RTC library example: RP2040_RTC_Time_WiFiNINNA and moved all that code to a tab: utilities. defines.h is a part of that example. Seems like a lot of heavy lifting to get on the wifi and get the time from the internet at startup. Its does work!

As I questioned above, I'm not sure any of that code is required given that the connection is established via the connectionhandler? Seems like I read somewhere that the RTC is also initialized in the background via the iot code? - but can't find it when I Iook to verify what I read. Seems too good to be true.

I suspect if I remove all that code the problem will resolve. I'll give that a test.

defines.h (2.3 KB)
Hot_Tub_RP2040_3.ino (25.1 KB)
utilities.h (8.2 KB)

Please see above ....
With defines.h and utilities.h removed alone with all the wifi and RTC code - the same error received.

/usr/local/bin/arduino-cli compile --fqbn arduino:mbed_nano:nanorp2040connect --build-cache-path /tmp --output-dir /tmp/3015952377/build --build-path /tmp/arduino-build-227AE20ACE85AF39B053A416BDAB7052 /tmp/3015952377/Spa_Controller_iot

In file included from /home/builder/Arduino/libraries/phyphox_ble_1_2_0/src/phyphoxBle.h:51:0,

from /home/builder/Arduino/libraries/phyphox_ble_1_2_0/src/experiment.cpp:3:

/home/builder/Arduino/libraries/phyphox_ble_1_2_0/src/phyphoxBLE_NRF52.h:7:10: fatal error: ble/BLE.h: No such file or directory

#include <ble/BLE.h>

^~~~~~~~~~~

compilation terminated.

Multiple libraries were found for "defines.h"

Used: /home/builder/opt/libraries/phyphox_ble_1_2_0

Not used: /home/builder/opt/libraries/vidorgraphics_1_1_0

Not used: /home/builder/opt/libraries/crmui3_1_4_0

Not used: /home/builder/opt/libraries/escapeautomate_0_0_29

Not used: /home/builder/opt/libraries/vidorperipherals_1_1_0

Not used: /home/builder/opt/libraries/helios_0_4_1

Not used: /home/builder/opt/libraries/spimemory_3_4_0

Not used: /home/builder/opt/libraries/eloquentesp32cam_1_1_2

Not used: /home/builder/opt/libraries/esp32_codec2_1_0_4

Not used: /home/builder/opt/libraries/p1am_1_0_6

Multiple libraries were found for "WiFiNINA.h"

Used: /home/builder/opt/libraries/wifinina_1_8_14

Not used: /home/builder/opt/libraries/vega_wifinina_1_0_1

Multiple libraries were found for "SPI.h"

Used: /home/builder/.arduino15/packages/arduino/hardware/mbed_nano/4.0.2/libraries/SPI

Not used: /home/builder/opt/libraries/eventethernet_1_0_0

Multiple libraries were found for "ArduinoECCX08.h"

Used: /home/builder/opt/libraries/arduinoeccx08_1_3_7

Not used: /home/builder/opt/libraries/rak5814_atecc608a_1_0_0

Multiple libraries were found for "Adafruit_I2CDevice.h"

Used: /home/builder/opt/libraries/adafruit_busio_1_14_4

Not used: /home/builder/opt/libraries/vegaiot_busio_1_0_0

Error during build: exit status 1

It looks like there is a bug in Arduino Web Editor that causes the header files in a sketch to be lost when you import a sketch. You should see three tabs in Arduino Web Editor when you open this sketch:

  • Hot_Tub_RP2040_3.ino
  • defines.h
  • utilities.h

But when I imported it, I only saw the first one.

I was able to work around the bug by adding each of the header files to the sketch individually:

  1. Click the button on the tabs bar of the Arduino Web Editor.
    A menu will open.
  2. Select "Import File into Sketch" from the menu.
    An "Open" dialog will open.
  3. Select the defines.h file on your hard drive in the "Open" dialog.
  4. Click the "Open" button.
  5. Click the button on the tabs bar of the Arduino Web Editor.
    A menu will open.
  6. Select "Import File into Sketch" from the menu.
    An "Open" dialog will open.
  7. Select the utilities.h file on your hard drive in the "Open" dialog.
  8. Click the "Open" button.

Now compile the sketch again. I still encountered some errors, but those errors were caused by actual bugs in the sketch (you might have introduced them when you were redacting private info from the sketch before posting it on the forum). Once I had fixed those bugs, the sketch compiles for me without any problem.


Please let me know if you have any questions or problems while following those instructions.

Interestingly I never imported the sketch from the IDE. I created a template by adding a new thing and then placed my code in the web editor via copy-paste from the IDE. I created the utilites.h and defines.h tab myself and copied in the respective code. Given the attention to defines.h, the code I sent up yesterday was straight from the IDE - not the web editor (my mistake).

As stated in my last post, with defines.h & utilities.h completely stripped from the code I still get the BLE.h error. Here is that stripped down code from the web editor.

Well the BLE.h error arrives out of the include to defines.h whether I have defines.h in my code or not! While I removed the tab defines.h - I forgot to remove the include statement in the main program and got the same error. With the include commented out - that error resolves.

If I understand this correctly, the web editor is going out and getting something called defines.h despite that code is no longer being a component of my sketch? If that is true then it was picking the wrong defines.h over the one that was in my sketch as well, which is undesirable for sure.

So I'll assume I can solve my issue by using distinct tab names so that no imposters are loaded ... and will test this out soon.

I assume I do not need the WifiNINNA code which is what defines.h was about. I'll assume I still need utilities.h to execute the NTP time grab?

I will add a note here that I believe the Arduino Cloud team fixed this bug yesterday. I am no longer able to reproduce it.

Thanks for taking the time to post an update. I'm glad you were able to find the remaining #include directive for defines.h.

That is incorrect. It was getting it because there was still an #include directive for defines.h in your sketch at line 28:

#include "defines.h"

That is correct. As I mentioned in my previous reply, I did originally experience the problem after I imported a ZIP file of the sketch containing all three files into my Arduino Cloud sketchbook. I then noticed that only the .ino file had actually been imported. If the header files are missing from the sketch, it would cause the error you experienced, since if the Arduino build system is unable to find the header file in the sketch folder, it will then go looking for files of that name in the libraries.

My experience led me to the conclusion that you had been affected by the same sketch import bug as I had been and that this was the cause of the bug.

But now I see you say you were experiencing the error even when the files were present in your sketch:

I decided to try again using a different Arduino Cloud account I have access to and strangely I am able to reproduce the problem of the header files in the sketch not being recognized in that account even though the identical sketch compiles just fine using the original account. While I was tinkering around I stumbled across the workaround for the bug.

I know you already have already found a sufficient workaround by avoiding the use of supplemental header files in your sketch, but in case it might be of use to someone else affected by the bug, or in case you later decide you want to add such header files to your sketch once again, I'll provide instructions for the workaround I found:

  1. Open the sketch in Arduino Web Editor.
  2. Click the ●●● button in the sketch panel of Arduino Web Editor.
    A menu will open.
  3. Select "Rename Sketch..." from the menu.
    The "Rename Sketch" dialog will open.
  4. Enter any new name for the sketch in the field of the "Rename Sketch" dialog.
  5. Click the "OK" button.
  6. Wait for the renamed sketch to open in Arduino Web Editor.

Now when you compile the renamed sketch you should find that the header files in the sketch are correctly recognized. If you want to go back to using the original sketch name, just repeat the procedure above, this time renaming the sketch back to the original name. The fix will continue to work even after you have changed the sketch name back to the original.

That should not be necessary. The build system looks for the file in the sketch folder first, so even if libraries contain a header file of the same name, the one in the sketch folder will always be used by the build system as long as things are working correctly.

When things are not working correctly, the header files in the sketch folder are not recognized at all, regardless of their names. The only benefit you will get from unique filenames in this case is that you will get the less confusing error message like:

/tmp/1282964274/FooSketch/FooSketch.ino:1:10: fatal error: SomeUniqueFilename.h: No such file or directory

#include "SomeUniqueFilename.h"

^~~~~~~~~~~~~~~~~~~~~~

compilation terminated.

Error during build: exit status 1

The Thing sketches that are automatically generated by Arduino IoT Cloud use the "ArduinoIoTCloud" library, which in turn uses the "Arduino_ConnectionHandler" library. That library provides the network connectivity code that is needed for communication with Arduino IoT Cloud. In the case of boards such as your Nano RP2040 Connect that use a "NINA" module for Wi-Fi connectivity, the "Arduino_ConnectionHandler" library uses the "WiFiNINA" library for that communication. For this reason, you won't see any "WiFiNINA" library code in the sketch itself, even though it is in use under a couple of layers of abstraction in dependent libraries.

You will need some code in your sketch to obtain the time. That code doesn't necessarily need to be in the file utilities.h. You could just as well put it directly in the .ino sketch. Supplemental code files in the sketch simply allow you to organize the code into multiple files, which might make it more convenient to work with in the case of a large or complex sketch.

You should be aware that the "ArduinoIoTCloud" actually provides a convenient function to get the time, which is documented here:

https://docs.arduino.cc/arduino-cloud/getting-started/technical-reference#local-time

Understand all said above. Thanks very much! I've learned a lot. I look forward to getting this up and running on the iot!

Also appreciate the link to the local-time function. That will be much easier than what I've been doing.

You are welcome. I'm glad if I was able to be of assistance. Best wishes for success and enjoyment in incorporating Arduino IoT Cloud into your project!

Regards,
Per