Part 3: unleash your code
The first two parts of the Get started tutorial are now done. Good work! 💪
In this part, we will learn how to configure Luos engine to access to multiple boards in your physical network. Then, we will run our first example into these boards.
We will use the same board from the first two parts, but you also need a second board to create a network. Supported boards are listed here.
2. Create a physical network
As we saw in Part 1, Luos engine allows you to define services and use them together on one MCU. What really sets Luos apart and makes it special is that you can also make services work together on separated MCUs.
Let's make a network with two boards!
In this part, we will use the “default wiring” defined by Luos to create a network of two MCUs. We will use a OneWire network, limiting the circuit to simple wires and pins:
- Tx and Rx pins, which are connected together and wired to the Tx and Rx pins of the other board (see the next image).
- One PTP wire.
💡 Luos Point-To-Point (PTP) connection allows you to find your board's physical position. Luos engine can deal with up to 8 PTP lines on each board to connect as many boards as you want.
To prevent any mistakes, unplug the USB cables from the boards before wiring.
To create your network, you have to identify the pins used to perform Luos communication:
|Function name||Arduino pin||STM32L432KC pin||STM32F072RB pin||STM32F401RE pin||STM32F410RB pin||STM32G431KB pin||Seeeduino XIAO pin||ESP32 WROOM 32 Dev Kit|
|TX||Tx||PA9 (D0)||PA9 (D8)||PB7(21)||PB7 (21)||PA9 (D0)||D6||Tx (SD2)|
|RX||Rx||PA10 (D1)||PA10 (D2)||PB6 (D10)||PB6 (D10)||PA10 (D1)||D7||Rx (SD3)|
|PTP||D6||PB5 (D12)||PA8 (D7)||PB5 (D5)||PB5 (D5)||PB5 (D12)||D1||IO26|
Below are the schematics of various boards and how to wire them:
- Arduino MKR
- Arduino Classic
- Seeeduino Xiao
- NUCLEO 32
- NUCLEO 64
- ESP32 WROOM-32 DevKit
You should now be able to wire the two boards together. From now on, we will call these boards board 1 and board 2.
After wiring the boards together, you will have to power both of them for the network to work correctly. In the next steps of this tutorial, board 1 will already be plugged to the computer with the USB cable. To power board 2, you can either connect the power output pin of board 1 (5V pin) to the power input pin of board 2 (Vin pin), or simply plug board 2 to another USB cable so that both boards are powered by the computer. In the first case, do not forget to wire the GND pins together on both boards.
3. Build a Luos distributed system
In Part 1, you have downloaded or cloned the Get started code folder in your computer. We will use this code to demonstrate how Luos engine works using a network. We will begin by moving the blinker app service from board 1 to board 2 and see what happens next.
Flash board 1
Connect the USB cable of board 1 and leave the USB cable of board 2 disconnected.
In VS Code, open the folder Get_started that corresponds to your board 1:
From the left panel, locate and open the file src/main.c or src/Arduino.ino.
Comment the following two lines to remove the blinker service from this board:
//Blinker_Init(); <== comment this line
//Blinker_Loop(); <== comment this line
These lines trigger the initialization and looping execution of all the packages in your project.
- Check whether the proper board environnement is selected depending on your board:
Flash board 2
You should now unplug the USB cable of board 1 and connect the USB cable of board 2.
In VS Code, open the folder Get_started project corresponding to your board 2,
file/open folder. (If you have the same boards twice, you can open the same folder.)
From the left panel, find and open the file src/main.c (or src/Arduino.ino for Arduino users).
This time, comment the following six lines to remove all of the services except the blinker:
//Led_Init(); <== comment this line
//Pipe_Init(); <== comment this line
//Gate_Init(); <== comment this line
//Led_Loop(); <== comment this line
//Pipe_Loop(); <== comment this line
//Gate_Loop(); <== comment this line
In order to keep using Luos engine in your MCU, don't comment
- Check if the right board environment is selected depending on your board:
We are done!
To check if everything is OK, plug a USB cable into board 1, and power board 2 according to your previous choice (power pins from board 1 or USB cable from computer).
The LED of board 1 should blink thanks to the blinker app in board 2.
Congratulation, you've just created your first Luos distributed system. The objective of this part of our Get started was to use a service located in your first board, in another board to perform an action on it.
4. Use Pyluos to control your network
You can now use
pyluos-shell in your terminal, as we did in Part 2. You should see the following:
Searching for a gate available
Connected to "/dev/cu.usbmodem13102".
Sending detection signal.
Waiting for routing table...
Hit Ctrl-D to exit this interpreter.
Your luos device have been successfully mounted into a "device" object:
┃ ╭node 1 /!\ Not certified ┃
┃ │ Type Alias ID ┃
┃ ├> State led 2 ┃
┃ ├> Pipe Pipe 3 ┃
┃ ╰> Gate gate 1 ┃
╚══ 0>┃0 ╭node 2 /!\ Not certified ┃
┃ │ Type Alias ID ┃
┃ ╰> Unknown blinker 4 ┃
As we can see, the blinker application is now displayed on a separate board. You still can control and interact with services on both boards with pyluos, as we did in Part 2.
For example, with your network connected to the computer, follow the step 3 from Part 2 and try to execute these lines one by one in an IPython session:
- Set up the blinking timing to 250ms (you should see the LED blink faster):
- Pause the blinking of the LED:
- Turn on the LED:
- Turn off the LED:
- Restart the blinking of the LED:
5. Next steps
In the next part of the Get started tutorial, we'll use the default network used by the Luos engine called Robus. The customization of your physical interface will be addressed in a future tutorial. The default hardware interface used by Robus is defined on the Robus HAL folder corresponding to your device.
6. Test your skills
Congratulation, you have plugged, configured, and used your first Luos network!
The next step will show you how to visualize your network online through the Luos Network Display tool.
You can check out our tutorials to learn more about Luos and understand how to use the features of Luos engine. We also invite you to check out our documentation to learn more about the core concepts of Luos engine.
⭐ If you liked this tutorial, feel free to star our Luos engine repository⭐