Has anyone connected a raspberry pi to the BiBoard using the Tx,Rx, Ground, and 5v GPIO pins? I was able to run ardserial.py using the usb-c port connected to the Rpi, but didn't have any luck with GPIO.
For the second serial port, should it be sending a response after receiving a command? I've made a simple test in the main script of SerialCommunication.py in the serialMaster directory of opencat:
if __name__ == '__main__':
Communication.Print_Used_Com()
port = port_list_number
if not port:
print("No serial ports found.")
else:
myCom = Communication(port[0], 115200, 1)
print("Ret = ", Ret)
myCom.Open_Engine()
try:
while True:
key = input("Enter a command (or 'exit' to quit): ")
if key == 'exit':
print("Exiting...")
break
# Send the user input to the serial device
myCom.Send_data((key + '\n').encode('utf-8'))
print(f"Sent: {key}")
# Wait for a response from the serial device
response = ""
while True:
try:
line = myCom.Read_Line().decode('ISO-8859-1').strip()
if line:
response += line
# Check for known response endings
if response.endswith("k"):
break
else:
break
except UnicodeDecodeError as e:
print(f"Decode error: {e}")
break
# Extract the actual response before the "k"
actual_response = response[:-1].strip() if response.endswith("k") else response
if actual_response:
print(f"Received: {actual_response}")
else:
print("No response received")
except KeyboardInterrupt:
print("\nProgram interrupted by user.")
finally:
myCom.Close_Engine()
But this only sends a response back when I connect my raspberry pi to the BiBoard through USB instead of the tx2 and rx2 pins.
I'm trying to get confirmation that a command is executed on the BiBoard, so I don't need to blindly blast the board with a bunch of commands in my autonomous control loop.
To use the second UART port, you need to send a Serial command "XS", similar to the way that you activate other modules. By "X?", you can check the module's status.
To receive the response, the program will call printToAllPorts().
If you connect both ports, the autoConnect script may get confused and connect the USB port using the first-come-first-serve principle. You may manually define the port as UART2 instead of using autoConnect().
Serial port 2 is activated, and I am able to send commands to the robot through the Tx2 and Rx2 pins, but I don't get a confirmation response back. If I connect the BiBoard to the raspberry pi with usb, then it is connected to port ttyACM0, and I get feedback after sending and executing commands:Connected to myCom: /dev/ttyACM0
Ret = True
Enter a command (or 'exit' to quit): krest
Sent: krest
Received: rest
Enter a command (or 'exit' to quit): kbalance
Sent: kbalance
Received: balance
Enter a command (or 'exit' to quit): krest
Sent: krest
Received: rest
If I then disconnect the usb cable and connect with the tx2 and rx2 pins, I am connected to port ttyAMA0, but receive empty responses back. I am able to send commands, and the robot executes them:Connected to myCom: /dev/ttyAMA0
I currently have the Bittle X model with a Bi Board V0_2. I am currently having trouble connecting my Bittle to my computer. I have a Surface pro-9. While this computer doesn't have a built-in USB port, I have been utilizing a USB adapter to perform firmware updates via the petoi desktop app. However, this also hasn't worked. I'm writing to ask if there's any way for me to successfully upload the proper firmware to my bittle without the use of a built-in USB.
I've gotten the serial monitor to work on both USB and UART2 with the XS command. I'm having trouble getting the IMU data to send to my raspberry pi through the "v" command though. When I enter "v" through the raspberry pi, the IMU data is printed on the arduino IDE serial monitor, but not on the PI. Do you have any insight on this?
Not within imu.h without throwing missing definition errors, but adding io.h to the include statements causes multiple declaration errors. It was simpler to just add the Serial2 print statement.
Following up on this post, I'm still trying to get the Tx and Rx pins on the ESP32 to work for serial communication with a raspberry pi. I've noticed that the OpenCatEsp32.ino file has this in the setup loop:voidsetup() {
}Where the line that is commented out has a comment that this is for the second serial port, while the first Serial.begin statement is commented to be for the USB serial. I tried removing the comment, however the board is unresponsive when I do this.
Additionally, I've been able to test the serial communication with this .ino file:void setup() {
Serial.begin(115200); // Initialize Serial for debugging
Serial2.begin(4800, SERIAL_8N1, 16, 17); // Initialize Serial2 with a lower baud rate
Serial.println("Serial2 test started");
}
void loop() {
if (Serial2.available()) {
String incoming = Serial2.readStringUntil('\n');
Serial.print("Received from Pi: ");
Serial.println(incoming);
// Send a response back to the Raspberry Pi
Serial2.print("Hello from ESP32\n");
}
delay(1000);
}and this python script running the on the Raspberry Pi:import serial
import time
# Configure the serial port
ser = serial.Serial(
port='/dev/serial0', # Use the correct serial port for your setup
baudrate=4800, # Lower baud rate
timeout=1
)
def main():
time.sleep(2) # Give some time for the connection to establish
print("Starting Serial communication with ESP32")
while True:
# Send a message to the ESP32
ser.write(b'Hello from Raspberry Pi\n')
print("Sent: Hello from Raspberry Pi")
# Wait for a response from the ESP32
response = ser.readline().decode('utf-8').strip()
if response:
print(f"Received: {response}")
else:
print("No response received")
time.sleep(1) # Delay before the next message
if __name__ == "__main__":
main()This test worked as expected to communicate using the Tx and Rx pins on the Pi and Esp32. I'm just having trouble tracking down where in the OpenCatESP32 code I need to adjust things to get commands working with this port.
For the second serial port, should it be sending a response after receiving a command? I've made a simple test in the main script of SerialCommunication.py in the serialMaster directory of opencat:
if __name__ == '__main__':
Communication.Print_Used_Com()
port = port_list_number
if not port:
print("No serial ports found.")
else:
myCom = Communication(port[0], 115200, 1)
print("Ret = ", Ret)
myCom.Open_Engine()
try:
while True:
key = input("Enter a command (or 'exit' to quit): ")
if key == 'exit':
print("Exiting...")
break
# Send the user input to the serial device
myCom.Send_data((key + '\n').encode('utf-8'))
print(f"Sent: {key}")
# Wait for a response from the serial device
response = ""
while True:
try:
line = myCom.Read_Line().decode('ISO-8859-1').strip()
if line:
response += line
# Check for known response endings
if response.endswith("k"):
break
else:
break
except UnicodeDecodeError as e:
print(f"Decode error: {e}")
break
# Extract the actual response before the "k"
actual_response = response[:-1].strip() if response.endswith("k") else response
if actual_response:
print(f"Received: {actual_response}")
else:
print("No response received")
except KeyboardInterrupt:
print("\nProgram interrupted by user.")
finally:
myCom.Close_Engine()
But this only sends a response back when I connect my raspberry pi to the BiBoard through USB instead of the tx2 and rx2 pins.
I'm trying to get confirmation that a command is executed on the BiBoard, so I don't need to blindly blast the board with a bunch of commands in my autonomous control loop.
Hi,
I currently have the Bittle X model with a Bi Board V0_2. I am currently having trouble connecting my Bittle to my computer. I have a Surface pro-9. While this computer doesn't have a built-in USB port, I have been utilizing a USB adapter to perform firmware updates via the petoi desktop app. However, this also hasn't worked. I'm writing to ask if there's any way for me to successfully upload the proper firmware to my bittle without the use of a built-in USB.
I've gotten the serial monitor to work on both USB and UART2 with the XS command. I'm having trouble getting the IMU data to send to my raspberry pi through the "v" command though. When I enter "v" through the raspberry pi, the IMU data is printed on the arduino IDE serial monitor, but not on the PI. Do you have any insight on this?
Following up on this post, I'm still trying to get the Tx and Rx pins on the ESP32 to work for serial communication with a raspberry pi. I've noticed that the OpenCatEsp32.ino file has this in the setup loop: void setup() {
// put your setup code here, to run once:
Serial.begin(115200); // USB serial
Serial.setTimeout(SERIAL_TIMEOUT);
// Serial1.begin(115200); //second serial port
while (Serial.available() && Serial.read())
; // empty buffer
initRobot();
} Where the line that is commented out has a comment that this is for the second serial port, while the first Serial.begin statement is commented to be for the USB serial. I tried removing the comment, however the board is unresponsive when I do this.
Additionally, I've been able to test the serial communication with this .ino file: void setup() {
Serial.begin(115200); // Initialize Serial for debugging
Serial2.begin(4800, SERIAL_8N1, 16, 17); // Initialize Serial2 with a lower baud rate
Serial.println("Serial2 test started");
}
void loop() {
if (Serial2.available()) {
String incoming = Serial2.readStringUntil('\n');
Serial.print("Received from Pi: ");
Serial.println(incoming);
// Send a response back to the Raspberry Pi
Serial2.print("Hello from ESP32\n");
}
delay(1000);
} and this python script running the on the Raspberry Pi: import serial
import time
# Configure the serial port
ser = serial.Serial(
port='/dev/serial0', # Use the correct serial port for your setup
baudrate=4800, # Lower baud rate
timeout=1
)
def main():
time.sleep(2) # Give some time for the connection to establish
print("Starting Serial communication with ESP32")
while True:
# Send a message to the ESP32
ser.write(b'Hello from Raspberry Pi\n')
print("Sent: Hello from Raspberry Pi")
# Wait for a response from the ESP32
response = ser.readline().decode('utf-8').strip()
if response:
print(f"Received: {response}")
else:
print("No response received")
time.sleep(1) # Delay before the next message
if __name__ == "__main__":
main() This test worked as expected to communicate using the Tx and Rx pins on the Pi and Esp32. I'm just having trouble tracking down where in the OpenCatESP32 code I need to adjust things to get commands working with this port.
Hi,
Have you dialed the switch from Voice to UART2?