Warning
The RemoteXY application is free, but it is limited to a maximum of 5 elements. To add more elements, you will need to move to the Pro version, which is paid.
Control your microcontroller remotely
RemoteXY
This page guides you through using RemoteXY to control your robot remotely.
RemoteXY is a platform for creating user interfaces to control microcontrollers (such as Arduino, ESP32, STM32 and so on) from mobile devices (smartphones or tablets). These interfaces can include buttons, sliders, joysticks, indicators and more.
RemoteXY thus makes it simple to create interactive applications without advanced mobile development skills.
1. Generating the interface
With RemoteXY, you easily create a graphical user interface (GUI) by dragging and dropping elements such as buttons, sliders or gauges in its online builder. Once the interface is ready, preconfigured source code is generated, adapted to the microcontroller used (Arduino, ESP32 and so on).
2. Communication
RemoteXY connects the mobile application to the microcontroller over:
3. Generated code
The generated code contains:
4. Interaction
The microcontroller exchanges data with the mobile application:
It sends information to update the interface (e.g. display a temperature).
This makes it possible to develop interactive, scalable systems quickly.
First, download the application to your phone, either from your mobile system’s app store or directly from the project web page.
Next, go to the interface editor page. You will find all the tools needed to design your interface there. To begin with, we will create a simple application to test a servo motor with a slider.
To do so, drag and drop a slider onto the interface and place it where you want. On your right, you will notice information about this slider, such as the variable name or graphical options.
Change the variable name to slider_servo_D7, then set the Center position option to Middle.
Under Configuration, at the top right, select Bluetooth. A window opens to guide you through the configuration of your project.
Under Board, select your board, here ESP32 based board. Under Module, choose Integrated Bluetooth.
Once these parameters are set, click Apply to confirm.
In the Settings tab, you can configure the connection parameters of your device. Here are the available options:
Device name in app: The name of your device as it will appear in the mobile application.Access password: The access password. It is not mandatory, but strongly recommended to secure the connection.Bluetooth name: The name of your device as seen when searching for Bluetooth devices.Mode: The type of Bluetooth connection used, either classic or LE (Low Energy), depending on what your device supports.Then click Get Source Code at the top right. A new page opens with code generated for your application. Click download code to download your code and open it in the Arduino IDE, or copy and paste your code into a new project.
The code generated by RemoteXY already contains a lot of useful information. Before modifying it or adapting it to your needs, let us take the time to look at its structure and understand how it works, step by step.
Here is a detailed, line-by-line analysis to help you get to grips with each part of the code:
//#define REMOTEXY__DEBUGLOG
#define REMOTEXY_MODE__ESP32CORE_BLE
#include <BLEDevice.h>
REMOTEXY_MODE__ESP32CORE_BLE: Configures RemoteXY to work in Bluetooth Low Energy (BLE) mode, which the ESP32 supports.#include <BLEDevice.h>: Includes the library that handles BLE communication.#define REMOTEXY_BLUETOOTH_NAME "Otto-BLE"
#define REMOTEXY_ACCESS_PASSWORD "**************"
REMOTEXY_BLUETOOTH_NAME: Sets the name of the device as it will appear in a Bluetooth search. Here, the device will be visible under the name “Otto-BLE”.REMOTEXY_ACCESS_PASSWORD: Sets a password to secure access. This field is strongly recommended to avoid unauthorised connections.#include <RemoteXY.h>
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] = // 42 bytes
{ 255,1,0,0,0,35,0,19,0,0,0,79,116,116,111,45,71,114,111,117,
112,101,32,48,50,0,31,1,106,200,1,1,1,0,4,45,37,13,100,32,
2,26 };
#pragma pack(pop)
RemoteXY_CONF[]: An automatically generated configuration that defines the layout and properties of the elements of the graphical user interface (GUI).
#pragma pack(push, 1): Ensures the data is aligned in memory in a way that optimises communication between the mobile device and the microcontroller.struct {
// input variables
int8_t slider_servo_D7; // from -100 to 100
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
struct RemoteXY: A structure holding the variables tied to the interface elements:
slider_servo_D7: The variable for the position of the slider. It ranges from -100 to 100, which can be used to control a servo motor.connect_flag: Gives the state of the Bluetooth connection:
1: The device is connected.0: No device is connected.setup() functionvoid setup()
{
RemoteXY_Init ();
// TODO you setup code
}
RemoteXY_Init(): Initialises Bluetooth communication and sets up the GUI elements defined in RemoteXY_CONF[].loop() functionvoid loop()
{
RemoteXY_Handler ();
// TODO you loop code
// use the RemoteXY structure for data transfer
// do not call delay(), use instead RemoteXY_delay()
}
RemoteXY_Handler():
TODO comments: These sections are where you add your own instructions to work with the variables (for example, moving a servo motor according to the position of the slider).Important: The classic delay() function is not compatible with RemoteXY, because it blocks operation. Use RemoteXY_delay() instead to handle delays.
RemoteXY.slider_servo_D7.setup() and loop() sections.In general, if you modify the interface, you do not need to redo the whole code. Only the part related to the configuration of the graphical user interface (GUI) has to be updated to reflect the changes made.
// RemoteXY GUI configuration
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] = // 42 bytes
{ 255,1,0,0,0,35,0,19,0,0,0,79,116,116,111,45,71,114,111,117,
112,101,32,48,50,0,31,1,106,200,1,1,1,0,4,45,37,13,100,32,
2,26 };
// this structure defines all the variables and events of your control interface
struct {
// input variables
int8_t slider_servo_D7; // from -100 to 100
// other variable
uint8_t connect_flag; // =1 if wire connected, else =0
} RemoteXY;
#pragma pack(pop)
To add control of a servo motor connected to pin D7 of an ESP32, using the value of the slider generated by RemoteXY, here are the lines to add or change in the code:
Add the ESP32Servo.h library at the top of the code to allow control of the servo motor.
#include <ESP32Servo.h>
Declare an object to represent the servo motor and a constant for pin D7.
Servo servoD7; // Creates a Servo object
const int servoPinD7 = D7; // Defines pin D7
setup()Add the instruction that attaches the servo motor to pin D7 in the setup() function.
void setup()
{
RemoteXY_Init();
servoD7.attach(servoPinD7); // Attaches the servo motor to pin D7
servoD7.write(90); // Moves the servo to the middle (90°) at start-up
}
loop()Add code to the loop() function to read the slider value and use it to control the servo motor. Convert the slider value (from -100 to 100) into an angle (from 0° to 180°).
void loop()
{
RemoteXY_Handler();
// Convert the slider value (-100 to 100) into an angle (0° to 180°)
int angle = map(RemoteXY.slider_servo_D7, -100, 100, 0, 180);
// Drive the servo motor with the matching angle
servoD7.write(angle);
}
Once the program is modified, you can upload the code to the board and start the application. Do not forget to install the RemoteXY library in the Arduino IDE.
On your phone, open the RemoteXY application. Tap + - Add new device, then select Bluetooth. Choose the Bluetooth technology that matches the one configured earlier in the editor (classic or BLE). Your device should appear in the list of Bluetooth connections. Tap its name to connect, then enter the password if needed.
Once connected, your application should appear on your phone. Try moving the slider: the servo motor should respond by following the movements of the slider, adjusting its position accordingly.
In the previous chapters, we saw how to get the distance from the ultrasonic sensor. Here we will adapt the interface to display this distance on your phone.
Add the lines of code needed to get the distance measured by the sensor. Make sure you replace delay() calls with RemoteXY_delay() where needed. Avoid using the serial link in this case. We will use the variable RemoteXY.distance_sensor.
Restart the application. You should see the distance measured by your sensor displayed below.