Lab 1: The Artemis board and Bluetooth

Lab Overview

The purpose of this lab was to familiarize myself with using Jupyter Lab as a way of having a virtual environment with Python, progamming the course's microcontroller Sparkfun's RedBoard Artemis Nano, and using Bluetooth to send commands and data back and form between the Artemis board and my laptop.

Material List

Lab 1A

For this section of the lab, I had to setup the connection between my laptop and the Arttemis board. After connecting the two with the USB cable I went into the arduino IDE selcted the correct board and port to be able to use the Arduino IDE to program the Artemis board. Following this I conducted 4 programs to verify different aspects of the board. These programs are as follows:

Blink

This example was a very simple blink program. This program would set the on board LED to be on for 1 second then turn it off for 1 second then repeat.

Serial Monitor

This example was done to verify that there is a steady serial connection between the Artemis Board and my laptop. As you can see in the picture below I would type out different sentences and phrases and they would show up in the serial montior.

Serial Example

AnalogRead/Temperature Readings

This example was used to verify ADC usability and if the onboard temperature sensor is working. As you will see in the video the ambient temperature stayed around 3800 but when I applied heat through touching the sensor with my finger the ADC value would increase to 4500-4600 verifying that it works.

Microphone Output and PDM

This example was used to verify if the onboard microphone was working. As you will see in the video when I created sounds by either clapping or whislting the highest detected frequency would increase or decrease depending on the noise being produced.

Lab 1A Conclusion

After running each of these programs this portion of the lab leaves me in a good position to expand on the connection between my laptop and the Artemis board. The next portion of the lab will have a heavy focus on sending data from my laptop to the Artemis board and vice versa.

Lab 1B

Configurations

I burned the Arduino ble file onto the Artemis board causing the mac address needed to connect to it to be printed into the serial monitor.

Mac address Example

From there I needed to update the mac address in the connections file on jupyter lab and you can see in the picture below that I changed the address so that the address on both files match.

connections file

After that I had to generate a UUID that would be unqiue to my board. If I did not do this, there is a high likely chance I would connect to a classmate's Artemis board.

UUID matching

Finally this lead to checking if the board was capable of connecting to my laptop through jupyter lab. If done successfully there would be a statment printed that the board is now connected. If not then there will be a statment printed that it is still attempting to connect.

Board connects

ECHO Command

The purpose of this command is to be able to send infomation to the Artemis board/robot and allow that same information to be sent back to my laptop. In addtion to being able to do this a prefix was added to further clarify the purpose of the command.

You can find the code below in addition to what is return when running that command.

Echo code Echo cmnd

SEND_THREE_FLOATS Command

The purpose of this command is to be able to send data like floats to the board through strings and be able to extract 3 floats out of the string being sent to the board. Being able to send floats over bluetooth can be helpful in debugging to ensure that the connection between the board and my laptop is stable. As shown below that show the code used to implement the logic for this command.

Send three floats code Send three floats cmnd Send three floats in Arduino cmnd

GET_TIME_MILLIS Command

The purpose of this command is to take advantage of the built-in timer on the Artemis board. Being able to recieve the current time in milliseconds is an odvious advantage when it comed to debugging espcially if it seems that a bug is time related. My implementation of this command and what is returned is seen below.

Get time in milliseconds code Get time in milliseconds cmd

Notification Handler

The purpose of this section of the lab is to be able to create a function that handles when data is being sent from the Artemis board to the laptop. When messages are being sent from the board to the laptop this handler will extract the needed data and display the data in a slightly different way. The implemenation of the handler and how to initate the notifications are shown below:

notification handler code

GET_LOOP_OF_TIME command

The purpose of this command is to be able to time stamps repeatedly to my laptop. I can see how this will help when debugging fast amounts of data. When using this command it seems that a message is being sent roughly every 60 milliseconds. The implemenatation and result can be seen below:

loop of time code loop of time python

SEND_TIME_DATA Command

The purpose of this command is to be able to send data by populating an array in the arduino sketch the send each indiviual element in the array over bluetooth. This seems to be a way of seeing how fast and how much data can be sent over bluetooth. The implemenation and result can be see below:

sent data code sent data python

GET_TEMP_READINGS

The purpose of this command is to be able to gather temperature readings concurrently with its respective time stamp. This seems like a baseline framework for future debugging when sending commands over bluetooth and seeing at what time stamp it might fail. The implemenation and result can be see below:

Temp readings code Temp readings python

Lab 1B Conclusion

After completing this portion of the lab I was able to see the pros and cons of sening the data directly vs sending the data from an array. When sending the data directly I was able to send 1 message every 60 milliseocnds vs the much faster rate of sending the data from an array. The data was gathered at such a faster rate that the time stamps were repeated multiple times showing evidence that the time was being collected at a much faster rate. If we do not include the repeated time stanmps then it seems that the time stamps were being gathered roughly once 1 milliseond. If we wanted to compare the size of the replies then when sending the data directly I was sending 21 bytes of data vs when using an array I was sending 23 and 40 byte replies when sending just the time stamps and when sending the time stamps and temperature readings respectfully. If I was in a situation where the tasks are not very demanding then using the sending directly method could be used but in more complex work where quick data collection is needed sending from an array is clearly the better choice. Being able to send more data quickly is a huge advantage with a major downside being that I will be more likely to use all of the RAM that is avaiable with is 384 kBs.

Disclaimer: When creating the code for parts 5-7 I looked through Nila Narayan's website to clarify misconceptions about expectations for the code and what files certain code blocks needed to be in.