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

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

 

En realidad vamos a usar los comandos especificados por el fabricante, asi que técnicamente no es hacking, pero suficiente cerca 🙂

Requisitos

  1. Arduino MCU
  2. Modulo Serial HM10 BLE
  3. TSRB430 Relay Board

Arduino Code

#include <SoftwareSerial.h>
int bluetoothTx = 10; // TX-O pin of bluetooth
int bluetoothRx = 11; // RX-I pin of bluetooth
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
void setup(){
Serial.begin(9600); // Begin the serial monitor at 9600bps
delay(200); // Short delay, wait for the Mate to send back CMD
bluetooth.begin(9600); // Start bluetooth serial at 9600
Serial.print("send...");
// bluetooth.print("AT");
//bluetooth.print("e"); //open relay 1
//delay(2000);
//bluetooth.print("o"); //close relay 1
}
void loop(){
if(bluetooth.available()){
Serial.print((char)bluetooth.read());
}
if(Serial.available()){
bluetooth.print((char)Serial.read());
}
}
void activateTSRB430() {
Serial.print("commanding...");
bluetooth.print("110");
delay(3000);
bluetooth.print("100");
delay(2000);
}

Con este codigo conectamos un Arduino MCU con un modulo serial bluetooth y enviamos comandos una relay board TSRB430 HM-10 BLE.

Ahora hagamos lo mismo pero desde una RPi!

Requisitos

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

Raspberry Pi2 Code

</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 is open: " + str(ser.isOpen())
print "Now Writing"
ser.write("e")
#ser.write("AT+CONNL")
print "Did write, now read"
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 que podemos hacer con esta conexión.

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