IoT Arduino-Raspberry Pi Hackeando una TSRB430 BLE Relay Board P2

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

 

Continuamos haciendo la TSRB430 BLE pero ahora desde una Raspberry Pi 🙂

Primero instalar ssh y automatizar con:

sudo /etc/init.d/ssh start

y luego con:

boot_enable_ssh.rc renombrar a boot.rc

luego instalar vncserver con:

sudo apt-get install tightvncserver

luego correr vmc server:

vncserver :1 -geometry 1280×800 -depth 16 -pixelformat rgb565

Acceder al ble uart del rpi para detectar tsrb430:

PL2032 – AT+ADDR?

74DAEAB314A5

AT+CONNL

pasando el codigo a un py script:

PRIMERO SCRIPT PARA CONNL

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(“o”)

ser.write(“AT+CONNL”)

print “Escrito!  Ahora leamos…”

AHORA LA CORREMOS…

pi@raspberrypi:~/Documents/python $ python togglerelay.py

Serial esta abierto: True

Escribiendo…

Escrito!  Ahora leamos…

got ‘OK+CONNLOK+CONN’

pi@raspberrypi:~/Documents/python $

Requisitos

  1. RPi2
  2. Modulo Serial HM10 BLE
  3. TSRB430 Relay Board

Raspberry Pi2 Codigo

</pre>
#!/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("e")
#ser.write("AT+CONNL")
print "Escrito!  Ahora leamos..."
x = ser.readline()
print "got '" + x + "'"
ser.close()

Aqui enviamos el codigo e al relay board y podemos ver que el relay se cierra.

 

En el proximo tutorial veremos como leer los estados de los relay.

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