Bluetooth-Grundlagen

Erstmal die Blauzahnunterstützung installieren:

apt-get install bluetooth => Monsterpacket

 

hcitool

hciconfig => zeigt Interfaces

hcitool hci0 up => Interface wird aktiviert

hcitool scan => Paarungswillige Geräte anzeigen

root@kali:~# hcitool scan
Scanning ...
00:12:11:28:05:63 linvor
bluez-simple-agent hci0 00:12:11:28:05:63 => Pairing, Key 1234 wird abgefragt

Um die Schnittstelle /dev/rfcomm0 nutzen zu können muss man /etc/bluetooth/rfcomm.conf editieren:

rfcomm0 {
 # Automatically bind the device at startup
 bind yes;
 # Bluetooth address of the device
device 00:12:11:28:05:63;
 # RFCOMM channel for the connection
channel 1;
 # Description of the connection
comment "Example Bluetooth device"; }

 

 

rfcomm => Status der Verbindungen

root@kali:~# rfcomm l
rfcomm0: 00:19:7E:F7:AC:4A -> 00:12:11:28:05:63 channel 1 connected [reuse-dlc tty-attached]

 

Kompletter 1-wire-Arduinocode auf dem Nano:

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

void setup(void)
{
  // start serial port
  Serial.begin(9600);
   // Start up the library
  sensors.begin();
}

void loop(void)
{ 
  sensors.requestTemperatures(); // Send the command to get temperatures
  Serial.print("Temperature is: ");
  Serial.print(sensors.getTempCByIndex(0));  
  Serial.println(" degrees Celsius ");
  delay(1000);
}