For many applications, sending serial data from a microcontroller to a computer is easily achieved using one of these serial to USB adapters:
For a recent project the microcontroller in question was mounted on a rotating arm so using a normal wired usb to serial adapter was out of the question. Here is a short video of the rotating arm:
A HC-06 serial bluetooth adapter came to the rescue. It had been sitting in a parts bin for several years and this was its moment. Here is a pic of the breadboard circuit with a teensy, the HC-06 and a BNO55 IMU chip:
The HC-06 only has 4 pins. RX, TX, GND and VCC so just connect the power pins and connect the RX and TX on the module to the RX and TX of your micro-controllers serial port.
The HC-06 is particularly handy if the computer it connects to is running linux. In this case, the laptop had built in bluetooth and was running fedora. The first step is to go into the settings, enable bluetooth and find the mac address of the HC-06:
The HC-06 shows up as “Linvor”. Clicking on it brings up this window:
Copy and paste the MAC address into a notepad to save for later use.
This is where using Linux makes things nice and easy. You can bind the MAC address to a serial port using this command :
sudo rfcomm bind hci0 00:12:03:28:45:12
Replace the MAC address with your one.
This will create a serial port , most likely called /dev/rfcomm0 (unless you have another rfcomm device already created in which case it might be rfcomm1, 2 etc.)
To connect to the port, you can use whatever program you normally use to connect to a serial port. It could be a python script or something like Minicom or picocom etc.
To connect using Picocom the command would be:
picocom -b 9600 /dev/rfcomm0
Once you run this command the light on the HC-06 will go from blinking (which means not connected) to solid red (which means it is connected) and you have a bluetooth serial link.
This is a really handy method for quickly sending data from any microcontroller back to a computer wirelessly. The fact that the bluetooth link shows up like a normal serial port and without too much faffing around is what makes this great.