beetle - mpu6050 - hc06
beetle
https://www.dfrobot.com/wiki/index.php/Beetle_SKU:DFR0282
HC-06
chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/http://cfile9.uf.tistory.com/attach/214E8642531A7BB635FA55
mpu6050 -beetle
BT setting 관련.
beetle은 leonardo를 사용해서 UART가 두개가 있다.
결국 UART0는 USB 디버깅으로 사용하고 UART1은 외부로 회선이 나온것으로 생각하면 된다.
아래 코드는 테스트용 코드이다.
Serial1이 BT인 HC-06 이다.
void setup()
{
Serial.begin(9600); //uart
Serial1.begin(9600); // Begin the serial monitor at 9600bps
Serial1.println("AT+NAMEbeetle");
}
void loop()
{
char test = 0;
if(Serial1.available())
{
test = Serial1.read();
Serial1.print(test);
Serial.print(test);
}
if(Serial.available())
{
test = Serial.read();
Serial1.print(test);
}
}
코드의 내용은 간단하다.
USB로 들어온 데이터가 있을 경우 BT로 내보내고…
BT로 들어온 데이터는 USB랑 BT로 내보내는 코드이다.
테스트를 위해서 안드로이드 어플은 Bluetooth Terminal을 사용하였다.
회로의 경우
Beetle의 TX를 HC-06 의 RX 에
Beetle의 RX를 HC-06의 TX 에
Beetle의 SCL을 MPU-6050 의 SCL에
Beetle의 SDA를 MPU-6050의 SDA 에
연결하였다.
\