-->

In lab 2, we are going to learn wireless communication with Bluetooth of the Artemis board. We will discuss the framework, the latency, and the data rate of the BLE modules. The first task is to setup USB passthrough so the adaptor should work with the Ubuntu VM. The BLE has existed on my computer (Windows 10), so the only setting we have to do is go to the VM devices → USB → Intel Bluetooth to enable the bluetooth on the VM. It can be verified by using the command “hciconfig” or “lsusb”, which is shown in Figure 1.

Set up 1

Figure 1. Bluetooth connection verification.

Next, we need to install the bleak library on python3 by running the command “python3 -m pip install bleak”. The bleak library is a GATT client software, capable of connecting to BLE devices acting as GATT servers. Figure 2 shows the installation process of the bleak.
Set up 1

Figure 2. The installation process of bleak.

Then, we upload the provided Arduino sketch to the Artemis board. However, it popped out an error that shows “wsf_types.h file is not found” because the version of the Apollo library in Arduino is too new (1.2.0), so we need to download the old version 1.1.2 to compile to program. Once the program is uploaded successfully, the blue LED blinks rapidly which shows in Video 1 and the serial monitor also shows the message in Figure 3.

Video 1: LED Blink with upload verification.

Set up 1

Figure 3. Serial monitor of Bluetooth message.

Later, we run the main.py on VM to discover the BLE on the Artemis board and it will show the message in Figure 4 when the robot is found.
Set up 1

Figure 4. The message when the robot is found.

We can now write several programs to understand the robot command framework. The basic structure is 99 bytes which include the first byte as the command type and the second byte is the length of the message. The rest of the bytes are the data information. The first experiment is to ping the robot by running the code “await theRobot.ping()”, which shows in Figure 5.
Set up 1

Figure 5. The robot ping code.

When we run the program, we could see the result in Figure 6.
Set up 1

Figure 6. The result of the robot ping.

Set up 1

Figure 7. Histogram of the robot ping.

It can see the major time of the robot ping is between 138~154 ms and the average latency is 154.7 ms for 64 packets. From the main.py program and the serial monitor (l_Rcvd), we can see that there are 99 bytes per ping transferred and the transfer rate will be 10240 bits/seconds. It is slower than the serial connection which is 115200 bits per second for the program. Next, we modified the program to request a float number. The code shows in Figure 8. We comment “await theRobot.ping()” and uncomment “await theRobot.sendCommand(Commands.REQ_FLOAT)” in the main.py to get the result in Figure 9.
Set up 1

Figure 8. The float code.

Set up 1

Figure 9. The result of requesting a float value.

We could see the value that displayed to the screen is slightly different from the float that we tried to send. It means that the data will a little distortion by using Bluetooth, so the float comparison will not be accurate. Last, we have already known what the round-latency is, so we want to understand the wireless data transfer rate is by modified the Ardunio code that shows in Figure 10. We want to send two different bytes values in order to compare the speed rate. The small value is 14 bytes and the large value is 46 bytes. Therefore, the first data set has one 32 bit value and one 64 bit value. The other data set has one 32 bit value and five 64 bit value. Also, we changed the code in main.py in order to match the unpack buffer that shows in Figure 11.
Set up 1

Figure 10. Data rate code.

Set up 1

Figure 11. Modification in SimpleHandler in main.py.

We could see the part of the result in Figure 12. Then, we plotted the histogram using excel to compare the rate difference of two different bytes.
Set up 1

Figure 12. The result of the testing rate.

Set up 1

Figure 13. Histogram of the 14 bytes transfer.

Set up 1

Figure 14. Histogram of the 46 bytes transfer.

The average time of 14 bytes is 11.338 ms and the average time of 46 bytes is 11.49ms. Therefore, we can determine that the larger bytes will require a longer time to transfer the data. Besides, the 14 bytes should have 164 packets to be sent, but the system only received 90 packets instead, which means 32.9% packets were dropped. On the other hand, the 46 bytes should have 339 packets but only 85 packets are received, so there are 75 packets were dropped.