Problems with BLE

Hello :slight_smile:

I'm having some problems trying to send and recieve data with Bluetooth Low Energy connection using UART with micropython. We have try a lot of tutorial but nothing seems to work for us. It seems that the problems is on app inventor cause when we try it on "Serial Bluetooth Terminal" app, the code on mycropython wroks perfectly but the same code doesn't send any data with app inventor.

We could really use your help :slight_smile:

What do you see if you directly assign the stringValues into a Label in the stringsReceived event?

Thanks for responding.

If you mean to put it like the image above, the program doesn't show anything. We just try it and the program makes the bluetooth connection but seconds later the app closes. This is our trying code for the bluetooth connection on Thonny.

from ble_uart_peripheral import BLEUART
from machine import Pin, I2C, PWM
import bluetooth
from BLE import BLEUART
import time
import utime
from ble_simple_peripheral import BLESimplePeripheral

#Variable global
led = Pin(2,Pin.OUT)

#Crear objeto BLE
ble = bluetooth.BLE()

#Abrir sesión UART
name = "Glucometro1"
print(name, "Conectado")
#sp = BLESimplePeripheral(ble, name)
uart = BLEUART(ble, name)

#Definir ISR para una entrada UART en la conexión BLE
def on_rx():
num = [4,8,15,16,23,42]
num2 = [1,2,3,4,5,6]
i = 0
i2 = 0

uart_in =

if uart_in == 'ON':
    uart_in =
    uart.write(str(num[i]) + "\n")
    i = (i+1) % len(num)
    uart.write('ESP 32 say:' + str(uart_in) + '\n')
if uart_in == 'OFF':
    uart_in =
    uart.write(str(num2[i2]) + "\n")
    i2 = (i2+1) % len(num2)
    uart.write('ESP 32 say:' + str(uart_in) + '\n')


Thanks again.