I’m currently working on a project using the Arduino IoT Cloud platform. As part of the project, I tried using a slider control to manage a servo motor. However, I’ve encountered an issue: it seems that the Servo library on Arduino IoT Cloud is not compatible with the Arduino Uno R4.
Has anyone else experienced this problem? Are there any workarounds or alternative solutions I could try?
#include <Servo.h>
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/0eec3bb8-2aac-4c0a-b147-1cb2f3f264d4
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
int servoAngle;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
const int servoPin = 9; // Define the servo pin
Servo servo; // Create a servo object
void setup() {
// 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);
servo.attach(servoPin);
// 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();
// Your code here
}
/*
Since ServoAngle is READ_WRITE variable, onServoAngleChange() is
executed every time a new value is received from IoT Cloud.
*/
void onServoAngleChange() {
// Add your code here to act upon ServoAngle change
servo.write(servoAngle);
}
Here is the console output:
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 renesas_uno architecture(s).
In file included from /run/arduino/sketches/Servo_jan06a/Servo_jan06a.ino:1:0:
/var/run/arduino/custom-libraries/Servo/src/Servo.h:77:2: error: #error "This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor."
#error "This library only supports boards with an AVR, SAM, SAMD, NRF52 or STM32F4 processor."
^~~~~
Did you take note of the error message when it said
The Uno R4 WiFi has a Renasas processor. Hence the error
Having said that, the Servo Sweep example compiles OK for me with the Uno R4 WiFi as the target board in the IDE on my PC so I don't know what is going on
Hi @wulu. The Servo library does support the UNO R4 WiFi board. However, the older versions of the library from before the time the UNO R4 WiFi board was created do not support it. The reason for the error is that you have imported an older incompatible version of the Servo library to your Arduino Cloud account. Arduino Cloud Editor uses the imported "custom" library instead of the version that is preinstalled on Arduino Cloud.
The solution will be to configure your sketch to use the latest version of the "Servo" library instead of the incompatible one you imported. I'll provide instructions you can follow to do that:
Click the following link to open the list of your Arduino Cloud sketches in the web browser: https://app.arduino.cc/sketches
Select the sketch for which you want to configure the library to be used.
The sketch will open in Arduino Cloud Editor.
Click the icon that looks like shelved books ("Libraries") in the bar on the left side of the Cloud Editor page.
The "Libraries" panel will open.
Type Servo in the "Search libraries" field near the top of the panel.
Find the entry for the "Servo" library in the list of search results.
You will see a drop-down menu in the library's entry. Click on it.
The menu will open.
Select "1.2.2" from the menu. You must select the "1.2.2" menu item, not the "Latest (1.2.2)" item at the top of the menu.
The menu will close.
Click the "INCLUDE" button in the "Servo" library entry. ⓘ Clicking this button configures the sketch to use the "Servo" library, at the specific version selected from the menu.
You will now see a "Library already included" notification. This is expected and doesn't indicate any problem.
Now try compiling the sketch again. This time the expected library should be used.
Note that the library configuration achieved via the above procedure was specific to the sketch you had open in Arduino Cloud Editor. If you want to make the same configuration for another sketch, open it in Cloud Editor and repeat the procedure.
The above procedure configured the sketch to always use the version you selected from the menu. Important enhancements or bug fixes might be made to the library in future releases of the library, so it is a good idea to periodically check for the availability of newer versions. You can repeat the procedure above to configure the sketch to use a different version of the library.
Please let me know if you have any questions or problems while following those instructions.