Sweep script for servo not uploading to Nano 33 BLE Sense

Hello guys,
I need to use servo motors with Arduino Nano 33 BLE Sense. But, on compiling the ‘Sweep’ code, i receive the following error. I have the latest(1.1.7) version of the Servo library.

WARNING: library Servo claims to run on avr, megaavr, sam, samd, nrf52, stm32f4, mbed architecture(s) and may be incompatible with your current board which runs on mbed_nano architecture(s).

C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'void ServoImpl::start(uint32_t)':

C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp:25:66: warning: 'void mbed::TickerBase::attach(Mbed_F&&, float) [with Mbed_F = mbed::Callback<void()>]' is deprecated: Pass a chrono duration, not a float second count. For example use `10ms` rather than `0.01f`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]

       ticker.attach(mbed::callback(this, &ServoImpl::call), 0.02f);

                                                                  ^

In file included from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.0.0\cores\arduino/mbed/mbed.h:83:0,

                 from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.0.0\cores\arduino/mbed.h:14,

                 from C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp:5:

C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.0.0\cores\arduino/mbed/drivers/include/drivers/Ticker.h:92:10: note: declared here

     void attach(F &&func, float t)

          ^~~~~~

C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'void ServoImpl::call()':

C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp:29:80: warning: 'void mbed::TickerBase::attach(Mbed_F&&, float) [with Mbed_F = mbed::Callback<void()>]' is deprecated: Pass a chrono duration, not a float second count. For example use `10ms` rather than `0.01f`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]

         timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration / 1e6);

                                                                                ^

In file included from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.0.0\cores\arduino/mbed/mbed.h:83:0,

                 from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.0.0\cores\arduino/mbed.h:14,

                 from C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp:5:

C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed_nano\2.0.0\cores\arduino/mbed/drivers/include/drivers/Ticker.h:92:10: note: declared here

     void attach(F &&func, float t)

          ^~~~~~

libraries\Servo\mbed\Servo.cpp.o: In function `Servo::attach(int, int, int)':

C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed/Servo.cpp:65: undefined reference to `digitalPinToPinName(unsigned char)'

collect2.exe: error: ld returned 1 exit status

Multiple libraries were found for "Servo.h"

 Used: C:\Users\my_username\Documents\Arduino\libraries\Servo

 Not used: C:\Program Files (x86)\Arduino\libraries\Servo

exit status 1

Error compiling for board Arduino Nano 33 BLE.

Any help whatsoever would be appreciated.

Cheers. :slight_smile:

Hi @the_zombie. It seems that an incompatibility was introduced in the 2.0.0 release of the Arduino Mbed OS board platform.

You can resolve this by using the previous version. Please try this:

  1. Select Tools > Board > Boards Manager from the Arduino IDE"s menus.
  2. Wait for the update to finish.
  3. Scroll down through the list of available boards platforms until you see “[Deprecated - Please install standalone packages] Arduino Mbed OS Boards”. Click on it.
  4. Click the “Install” button.
  5. Wait for the installation to finish.
  6. Click the “Close” button.
  7. Select Tools > Board > Arduino Mbed OS Boards (nRF52840 / STM32H747 > Arduino Nano 33 BLE from the Arduino IDE’s menus.

Now try compiling the Sweep sketch again.

Note that, due to the current unique circumstances where the Arduino Mbed OS Boards platform was split into board -specific variants, you will still have the new “Arduino Mbed OS Nano Boards” platform available under the Tools > Board menu, so you can decide when you want to use the old 1.3.2 version or the new 2.0.0 version of the boards platform at will. If you eventually decide you want to uninstall one, you can do that by clicking the “Remove” button in Boards Manager.

Hello @pert ! Thanks a lot for the quick reply.

I tried the solution you posted and while I was able to compile and upload the ‘Sweep’ script to the Nano 33 BLE Sense board, I got the following message after compilation:

C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'void ServoImpl::start(uint32_t)':
C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp:25:66: warning: 'void mbed::TickerBase::attach(Mbed_F&&, float) [with Mbed_F = mbed::Callback<void()>]' is deprecated: Pass a chrono duration, not a float second count. For example use `10ms` rather than `0.01f`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
       ticker.attach(mbed::callback(this, &ServoImpl::call), 0.02f);
                                                                  ^
In file included from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/mbed/mbed.h:82:0,
                 from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/mbed.h:14,
                 from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/Arduino.h:42,
                 from C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp:3:
C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/mbed/drivers/Ticker.h:92:10: note: declared here
     void attach(F &&func, float t)
          ^~~~~~
C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'void ServoImpl::call()':
C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp:29:80: warning: 'void mbed::TickerBase::attach(Mbed_F&&, float) [with Mbed_F = mbed::Callback<void()>]' is deprecated: Pass a chrono duration, not a float second count. For example use `10ms` rather than `0.01f`. [since mbed-os-6.0.0] [-Wdeprecated-declarations]
         timeout.attach(mbed::callback(this, &ServoImpl::toggle), duration / 1e6);
                                                                                ^
In file included from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/mbed/mbed.h:82:0,
                 from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/mbed.h:14,
                 from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/Arduino.h:42,
                 from C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp:3:
C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/mbed/drivers/Ticker.h:92:10: note: declared here
     void attach(F &&func, float t)
          ^~~~~~
In file included from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\variants\ARDUINO_NANO33BLE/pins_arduino.h:3:0,
                 from C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/Arduino.h:90,
                 from C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp:3:
C:\Users\my_username\Documents\Arduino\libraries\Servo\src\mbed\Servo.cpp: In member function 'uint8_t Servo::attach(int, int, int)':
C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/macros.h:28:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define digitalPinToPinName(P)      (P >= PINS_COUNT ? NC : g_APinDescription[P].name)
C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino/macros.h:28:40: note: in definition of macro 'digitalPinToPinName'
 #define digitalPinToPinName(P)      (P >= PINS_COUNT ? NC : g_APinDescription[P].name)
                                        ^~
C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino\USB\USBCDC.cpp: In member function 'virtual const uint8_t* arduino::USBCDC::configuration_desc(uint8_t)':
C:\Users\my_username\AppData\Local\Arduino15\packages\arduino\hardware\mbed\1.3.2\cores\arduino\USB\USBCDC.cpp:543:35: warning: narrowing conversion of '((((arduino::USBCDC*)this)->arduino::USBCDC::extraDescriptor != 0) ? 5 : 0)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]
         (extraDescriptor != NULL) ? 0x5 : 0x0, // iInterface
         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
Sketch uses 88032 bytes (8%) of program storage space. Maximum is 983040 bytes.
Global variables use 46240 bytes (17%) of dynamic memory, leaving 215904 bytes for local variables. Maximum is 262144 bytes.

These just seem like warnings. I wanted to know, if this a cause for any concern, and if I can do something to take care of this.

Now, although, i have uploaded the ‘Sweep’ script to Arduino and have got the servo to rotate, the rotations are incorrect. After uploading the script, the servo rotates for more than 2 full rotations instead of just 180 degrees.

I tried to test by sending just a single position to the servo with a delay of 1000ms inside the void loop(), but in this case the servo just keeps rotating continuously without any delay. When I test with the ‘Blink’ script, the delay works fine at that time

I am using the 360 degree version of the SG90 servo; the RED wire has been connected to the 3.3V pin as 5V isn’t enabled by default in the Nano 33 BLE Sense(we have to solder the two pads near the 5V pins together).

Is this issue related to the servo issue on this particular board or should I post it as a question, elsewhere?

Thanks again for helping out. Cheers :slight_smile:

That’s correct. It’s just the compiler telling you “the code is perfectly valid, but there are some things that might or might not indicate a problem, maybe take a look at them”.

Unfortunately, I don’t know enough about this code to give a definitive answer. It’s probably fine though.

You’ll encounter compiler warnings a lot when compiling Arduino code. It is definitely an art to know when you need to pay attention to it. My approach is to always pay attention to compiler warnings from the code I wrote and make sure to fix ever single one, even when it doesn’t indicate a serious problem. When it comes to warnings from code other people wrote, I usually just try to ignore them and hope for the best. It seems to work out well enough.

It sounds like you have a continuous rotation servo, rather than a standard positional servo. If so, this is normal behavior. There is some information about it here:
https://www.arduino.cc/reference/en/libraries/servo/write/

This same error seems to occur with the Web Editor. It fails to compile indicating

"/home/builder/opt/arduino-builder/arduino-builder -compile -core-api-version 10611 -hardware /home/builder/opt/arduino-builder/hardware -hardware /home/builder/.arduino15/packages -tools /home/builder/opt/arduino-builder/tools -tools /home/builder/.arduino15/packages -built-in-libraries /home/builder/opt/libraries/latest -logger humantags -fqbn arduino:mbed:nano33ble -build-cache /tmp -build-path /tmp/985906336/build -verbose -prefs runtime.tools.arm-none-eabi-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4 -prefs runtime.tools.bossac.path=/home/builder/.arduino15/packages/arduino/tools/bossac/1.9.1-arduino2 -prefs runtime.tools.dfu-util.path=/home/builder/.arduino15/packages/arduino/tools/dfu-util/0.10.0-arduino1 -prefs runtime.tools.openocd.path=/home/builder/.arduino15/packages/arduino/tools/openocd/0.11.0-arduino1 -prefs runtime.tools.rp2040tools.path=/home/builder/.arduino15/packages/arduino/tools/rp2040tools/1.0.2 -prefs runtime.tools.flashpack.path=/home/builder/.arduino15/packages/Intel/tools/flashpack/2.0.0 -prefs runtime.tools.avr-gcc.path=/home/builder/.arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7 -prefs runtime.tools.CMSIS-Atmel.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS-Atmel/1.2.0 -prefs runtime.tools.esptool.path=/home/builder/.arduino15/packages/esp8266/tools/esptool/2.5.0-3-20ed2b9 -prefs runtime.tools.mkspiffs.path=/home/builder/.arduino15/packages/esp8266/tools/mkspiffs/2.5.0-3-20ed2b9 -prefs runtime.tools.core2-32-poky-linux.path=/home/builder/.arduino15/packages/Intel/tools/core2-32-poky-linux/1.6.2+1.0 -prefs runtime.tools.i586-poky-linux-uclibc.path=/home/builder/.arduino15/packages/Intel/tools/i586-poky-linux-uclibc/1.6.2+1.0 -prefs runtime.tools.sketchUploader.path=/home/builder/.arduino15/packages/Intel/tools/sketchUploader/1.6.2+1.0 -prefs runtime.tools.CMSIS.path=/home/builder/.arduino15/packages/arduino/tools/CMSIS/4.5.0 -prefs runtime.tools.avrdude.path=/home/builder/.arduino15/packages/arduino/tools/avrdude/6.3.0-arduino8 -prefs runtime.tools.ctags.path=/home/builder/.arduino15/packages/builtin/tools/ctags/5.8-arduino11 -prefs runtime.tools.arc-elf32.path=/home/builder/.arduino15/packages/Intel/tools/arc-elf32/1.6.9+1.0.1 -prefs runtime.tools.arm-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/arm-linux-gcc/4.9.3 -prefs runtime.tools.arduinoOTA.path=/home/builder/.arduino15/packages/arduino/tools/arduinoOTA/1.3.0 -prefs runtime.tools.linuxuploader.path=/home/builder/.arduino15/packages/arduino/tools/linuxuploader/1.5.1 -prefs runtime.tools.arduino101load.path=/home/builder/.arduino15/packages/Intel/tools/arduino101load/2.0.1 -prefs runtime.tools.x86-linux-gcc.path=/home/builder/.arduino15/packages/arduino/tools/x86-linux-gcc/7.2.0 -prefs runtime.tools.nrf5x-cl-tools.path=/home/builder/.arduino15/packages/arduino/tools/nrf5x-cl-tools/9.3.1 -prefs runtime.tools.serial-discovery.path=/home/builder/.arduino15/packages/builtin/tools/serial-discovery/1.1.0 -prefs runtime.tools.xtensa-lx106-elf-gcc.path=/home/builder/.arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9 -libraries /tmp/985906336/custom -libraries /tmp/985906336/pinned /tmp/985906336/Servo_go

Multiple libraries were found for "Servo.h"

Used: /home/builder/opt/libraries/latest/servo_1_1_7

Not used: /home/builder/opt/libraries/latest/servoesp32_1_0_3

Not used: /home/builder/opt/libraries/latest/rokitsmart_1_0_9

Not used: /home/builder/opt/libraries/latest/printoo_library_1_0_2

Not used: /home/builder/opt/libraries/latest/evive_2_0_3

Using library servo_1_1_7 at version 1.1.7 in folder: /home/builder/opt/libraries/latest/servo_1_1_7

/tmp/985906336/build/libraries/servo_1_1_7/mbed/Servo.cpp.o: In function `Servo::attach(int, int, int)':

/home/builder/opt/libraries/latest/servo_1_1_7/src/mbed/Servo.cpp:65: undefined reference to `digitalPinToPinName(unsigned char)'

collect2: error: ld returned 1 exit status

exit status 1

Any thoughts on a workaround using the Web editor?

@bthornburg, I just ran into this same issue as well. It seems there’s a core library not being included.

ah Sweep script for servo not uploading to Nano 33 BLE Sense - #2 by pert

Unfortunately, there is no way to install a specific version of the Mbed OS Boards platform in the Arduino Web Editor. You always get the latest version. So the workaround I described above can only be done with the Arduino IDE.

These are the only workarounds I can think of:

  • Somehow update the Servo library to fix the issue, then import your custom version of Servo.
  • Search for a 3rd party Servo library in Library Manager that is compatible with Nano 33 BLE, then adapt your sketch to use that library instead of Servo.

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