I use a Raspberry Pi 3 Model B and I have a Bluetooth HC-08 module.
I would like to be able to send and receive data. I use the port /dev/ttyS0 and I changed the file /boot/config.txt for "enable_uart=1"
I connected the RX pin of the module to pin 8 of the RPI and the TX pin to pin 10. ( TX -> RX / RX -> TX)
To test, I use a mobile application, LightBlue. I can read the data I send from the application but I can't write.
I also changed parameters in raspi-config, Interface Options / Serial -> No -> Yes
Here's my test code :
import time import serial print "Starting program" ser = serial.Serial('/dev/ttyS0', baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS ) time.sleep(1) try: ser.write('Hello World\r\n') ser.write('Serial Communication Using Raspberry Pi\r\n') ser.write('By: Embedded Laboratory\r\n') print 'Data Echo Mode Enabled' while True: if ser.inWaiting() > 0: data = ser.read() print data except KeyboardInterrupt: print "Exiting Program" except: print "Error Occurs, Exiting Program" finally: ser.close() pass
I don't know why I can read but not write data ... Do I miss something ?
Some help would be appreciated, thanks