This week, the main focus was getting the bluetooth finally up and running. Getting the Bluetooth functionality of ViBRA up and running was a crucial step in enabling wireless communication between the Python code and the Arduino. Initially, we faced some challenges in establishing a stable Bluetooth connection, but with a systematic troubleshooting approach, we were able to overcome these hurdles.
Step 1: Wiring the Bluetooth Module: Once we had the Bluetooth module, we connected it to the Arduino using the appropriate pins. Typically, the Bluetooth module requires two pins: one for receiving data (RX) and another for transmitting data (TX). We double-checked the connections to ensure they were accurate and secure.
Step 2: Pairing the Bluetooth Module: We paired the Bluetooth module with the computer using the computer's Bluetooth settings. It was essential to ensure that the Bluetooth module was discoverable and that it appeared as a available device on the computer.
Step 3: Verifying Serial Communication: We first tested the Bluetooth module's serial communication capability independently of the Python code. To do this, we used a basic Arduino sketch that allowed us to send and receive data from the Arduino via the serial monitor. This step was crucial to verify that the Bluetooth module was functioning correctly and was capable of transmitting and receiving data.
Step 4: Python Serial Configuration: In the Python code, we needed to configure the correct COM port and baud rate to establish a serial connection with the Bluetooth module. We carefully set the serial_port variable to the appropriate COM port number, which we had previously identified during the pairing process. Additionally, we set the baud_rate variable to match the baud rate set in the Arduino sketch.
Step 5: Troubleshooting Communication Errors: During initial tests, we encountered occasional data transmission errors between the Python code and the Arduino. To troubleshoot this, created a very minimal python and Arduino code that would show if the data is sent and received from the Arduino.
Step 6: Testing and Iteration: Throughout the process, rigorous testing and iterative refinement were essential. We continuously ran tests, identified any issues, and made necessary adjustments to the code and hardware until we achieved stable and reliable Bluetooth communication.
By following these troubleshooting steps and conducting thorough testing, we successfully established a functional Bluetooth connection between the Python code and the Arduino, allowing seamless wireless communication for the ViBRA project.
Below is a snippet of the code that was used to verify that there was a stable connection to the Bluetooth module. The python code is on left with the COM port belonging to that of the Bluetooth module and the Arduino code is on the right. Note that the baud rate in both programs are 9600 for ease of communication.
![](https://static.wixstatic.com/media/cfd036_780dcd683f47460db215bbe9f697d4ec~mv2.png/v1/fill/w_980,h_345,al_c,q_85,usm_0.66_1.00_0.01,enc_avif,quality_auto/cfd036_780dcd683f47460db215bbe9f697d4ec~mv2.png)
Comments