Raspberry Pi, App Inventor keeps showing strange special characters

Hello, I would like to ask App Inventor experts for help.

I am using the HC-06 module to communicate with App Inventor and Raspberry Pi via Bluetooth.

You can send messages from Raspberry Pi to App Inventor without any problems.

When sending messages from App Inventor to Raspberry Pi, App Inventor keeps showing strange special characters.

I'll post a photo below.

Does any teacher know why this happens?

Please... I'm holding on for a few days.

Looks like you need to ensure that all data is UTF-8 encoded...

Upload both the .ino and .aia files here for a more specific analysis.

How do I make sure all the data is encoded in utf-8??

Grid.aia (7.8 KB)

I couldn't find how to extract the .ino file, so I only upload the .aia file. I want to know what the problem is.. please.. thank you.

You don't extract an .ino file.

You do a File -> Save As in the text editor you use to code the sketch.

If I save it under a different name in App Inventor's block window, it just saves it to my project under a different name. I can't figure out how to do it.

Instead, we will capture the block composition.


Who programmed the Raspberry Pi?

The code asked Chat-gpt to write a Python code that sends a message to the app inventer and receives it in Raspberry Pi.. I just wanted to make sure that the transmission works properly because the errors keep coming out..

Just in case, I will also upload the code I asked gpt...

----python cod------

import serial
import RPi.GPIO as GPIO
import time

GPIO 핀 번호 설정

LED_PIN = 14

시리얼 통신 객체 생성

bluetooth_port = '/dev/ttyS0' # HC-05 모듈이 연결된 시리얼 포트 경로
bluetooth = serial.Serial(bluetooth_port, 9600, timeout=1)

GPIO 초기화


print("Waiting for Bluetooth messages...")
while True:
if bluetooth.in_waiting > 0:
# Bluetooth로부터 데이터 수신
received_data = bluetooth.readline()
# UTF-8로 디코딩 시도
received_data = received_data.decode('utf-8').strip()
print("Received message:", received_data)

            # 수신된 메시지에 따라 LED 제어
            if 'on' in received_data:
                print("Turning LED ON...")
                GPIO.output(LED_PIN, GPIO.HIGH)  # LED 켜기

            elif 'off' in received_data:
                print("Turning LED OFF...")
                GPIO.output(LED_PIN, GPIO.LOW)  # LED 끄기
        except UnicodeDecodeError:
            print("UnicodeDecodeError: Cannot decode the received data")

except KeyboardInterrupt:
print("Keyboard Interrupt. Exiting...")

# GPIO 리소스 해제
# Bluetooth 시리얼 포트 닫기

The above code connects App Inventor and Raspberry Pi with a Bluetooth module called hc-06 and attempts to communicate in series.

When you run the code and send a message from AppInventor to Raspberry Pi, you get the following error: (This is the contents of the terminal window.)

pi@raspberrypi:~/test $ sudo python seled.py
Waiting for Bluetooth messages...
Received message:
Received message:
Traceback (most recent call last):
File "/home/pi/test/seled.py", line 14, in
received_data = bluetooth.readline().decode().strip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe0 in position 1: invalid continuation byte

Well, I'm stumped.
Too many wild cards for me here.
A language I can't read, ChatGPT generated code in python, unknown wiring, possibly mismatched baud rates, code translation without purpose ...

I'm sorry for the embarrassment and I'm glad you thought about the problem with me.

thank you