IoT: Intro a Raspberry Pi 2 – Bt Serial Uart HM10-HM12 Relay Board for AI

Raspberry Pi 2 Bluetooth Serial Uart HM10 HM12 Relay Board AI by Santiapps Marcio Valenzuela
Raspberry Pi 2 Bluetooth Serial Uart HM10 HM12 Relay Board AI

Para trabajar con RPi es necesario instalar todo primero y hacer las conexiones.  Para nuestros proyectos de RPi con BLE Serial por ejemplo, seguimos las siguientes instrucciones y conexiones:

Conexion de BLE Serial al RPi

Rx-Tx-3.3V-GND

Configuracion de Linux en RPi:

Linux

sudo shutdown -h now

sudo ssh service start

sudo inserv

Configuracion del Rasbian Jessie

enable_uart=1 in /etc/inittab

remove console in /boot/cmdline.txt

set IMME to 1 on hmsoft

 

 

Raspberry Pi 2 Bluetooth Serial Uart HM10 HM12 Relay Board AI by Santiapps Marcio Valenzuela
Raspberry Pi 2 Bluetooth Serial Uart HM10 HM12 Relay Board AI

 

Codigo Python para script simple:

#!/usr/bin/env python
import serial
ser = serial.Serial(
port='/dev/serial0',
baudrate=9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
print "Serial esta abierto: " + str(ser.isOpen())
print "Escribiendo..."
ser.write("AT")
print "Escrito! Ahora leamos"
x = ser.readline()
print "got '" + x + "'"
ser.close()
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s