arduino/bluetooth
This commit is contained in:
47
arduino/bluetooth_arduino.cpp
Normal file
47
arduino/bluetooth_arduino.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
// Basic Bluetooth sketch HC-06_01
|
||||
// // Connect the Hc-06 module and communicate using the serial monitor
|
||||
// //
|
||||
// // The HC-06 defaults to AT mode when first powered on.
|
||||
// // The default baud rate is 9600
|
||||
// // The Hc-06 requires all AT commands to be in uppercase. NL+CR should not be
|
||||
// added to the command string
|
||||
// //
|
||||
//
|
||||
//
|
||||
// #include <SoftwareSerial.h>
|
||||
// SoftwareSerial BTserial(2, 3); // RX | TX
|
||||
// // Connect the HC-06 TX to the Arduino RX on pin 2.
|
||||
// // Connect the HC-06 RX to the Arduino TX on pin 3 through a voltage
|
||||
// divider.
|
||||
// //
|
||||
//
|
||||
//
|
||||
// void setup()
|
||||
// {
|
||||
// Serial.begin(9600);
|
||||
// Serial.println("Enter AT commands:");
|
||||
//
|
||||
// // HC-06 default serial speed is 9600
|
||||
// BTserial.begin(9600);
|
||||
// }
|
||||
//
|
||||
// void loop()
|
||||
// {
|
||||
//
|
||||
// // Keep reading from HC-06 and send to Arduino
|
||||
// Serial Monitor
|
||||
// if (BTserial.available())
|
||||
// {
|
||||
// Serial.write(BTserial.read());
|
||||
// }
|
||||
//
|
||||
// // Keep reading from
|
||||
// Arduino Serial Monitor
|
||||
// and send to HC-06
|
||||
// if
|
||||
// (Serial.available())
|
||||
// {
|
||||
// BTserial.write(Serial.read());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
21
arduino/bluetooth_serial_test.py
Executable file
21
arduino/bluetooth_serial_test.py
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
#
|
||||
# - Pair bluetooth useing bluetoothctl.
|
||||
# agent on
|
||||
# pair 20:16:02:14:58:51
|
||||
# - Setup serial connection:
|
||||
# sudo rfcomm bind hci0 20:16:02:14:58:51 1
|
||||
#
|
||||
# - For module
|
||||
# sudo apt-get install python-serial
|
||||
#
|
||||
|
||||
import serial
|
||||
from time import sleep
|
||||
|
||||
bluetoothSerial = serial.Serial( "/dev/rfcomm0", baudrate=9600 )
|
||||
|
||||
bluetoothSerial.write( "Test from python." )
|
||||
print bluetoothSerial.readline()
|
||||
|
||||
Reference in New Issue
Block a user