Page 1 of 1

Send Command from Bluetooth Serial Controller Android App

Posted: Fri Aug 21, 2015 10:22 am
by yllumi
I have successfuly connect my HC-05 bluetooth module to pyboard via UART(6). I also have tried to connect and send serial data from computer.

Now I currently trying to receive data from Bluetooth Serial Controller Android app to pyboard. The app can connect to bluetooth module and I try to send character '1' to pyboard, but there is no response. This is my program:

Code: Select all

from pyb import UART

uart = UART(6, 9600)

print(uart.read())
if uart.read():
  pyb.LED(3).on()
else:
  pyb.LED(3).off()
Is my code wrong or I've done wrong way?

Re: Send Command from Bluetooth Serial Controller Android App

Posted: Fri Aug 21, 2015 4:26 pm
by dhylands
When you open the UART, there are 2 timeouts you can specify. One is simply called timeout and the second is called timeout_char
http://docs.micropython.org/en/latest/l ... #uart.init
The default timeout is 1000 which is 1000 msec or 1 second. What that means is that if you call uart.read() and no data shows up for 1 second then it will return an empty string.

So you really need to put your read in a loop.