Pages: [1]   Go Down
Author Topic: Bluetooth Tx / Rx problem  (Read 866 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi! I am the tipical newbie with problems... thanks in advance
I'm trying to run a bluetooth device with a test sketch. The intention is that by sending an ascii character through another Bluetooth device (in this case the character "i"), turns on an LED on pin 13. The problem is:
If I use the standard hardware serial (Rx on pin 0 and Tx on pin 1), does NOT work. But if I use the software serial library <SoftwareSerial.h>(Rx on pin 2 and Tx on pin 3), it works.
In the first case I use this sketch: (does NOT work)

// Schema: Arduino - TTL Bluetooh: GND to GND, 3V3 to 3.3, Rx(pin0) to Tx, Tx(pin1) to Rx. With external power supply

void setup(){
  Serial.begin(9600); //Bluetooth
  pinMode(13, OUTPUT);
}

void loop() {
  byte data;
  char* menssage;

  if (Serial.available()) {
    data=Serial.read();
    switch(data){

      case 105: // i
        digitalWrite(13, HIGH);
        menssage="LED on";
        break;
      case 107: // k
        digitalWrite(13, LOW);
        menssage="LED off";
        break;

      default:
        Serial.print(data);
        Serial.print(": ");
        menssage="Error";
        delay(200);
    }
  }
}


In the second case I use this other sketch: (It works)

// Schema: Arduino - TTL Bluetooh: GND to GND, 3V3 to 3.3, Rx(pin2) to Tx, Tx(pin3) to Rx. USB connected to PC, NOT external power supply

#include <SoftwareSerial.h>
SoftwareSerial SerialExtra (2, 3);

void setup(){ 
  Serial.begin(9600); // Debug
  SerialExtra.begin(9600); // Bluetooth

  pinMode(13, OUTPUT);
}

void loop() {
  byte data;
  char* menssage;
 
  if (SerialExtra.available()) {
    data=SerialExtra.read();
    switch(data){

       case 105: // i
        digitalWrite(13, HIGH);
        menssage="LED on";
        break;
      case 107: // k
        digitalWrite(13, LOW);
        menssage="LED off";
        break;

      default:
        Serial.print(data);
        Serial.print(": ");
        menssage="Error";
        delay(200);
    }
  }
}


My Arduino is the standard "Uno" model and the TTL bluetooth is like this:
http://www.ebay.es/itm/Serial-USB-Bluetooth-RF-TTL-Transceiver-Module-RS232-3-3V-DC-8mA-for-Arduino-/290647062190

I have tried several configurations and searched the web... I've even reflash the 8u2, but the "Hardware serial " doesn't seem to work
Where can be the error? Does this device can not work with the standard serial pins 0&1?

By the way, happy new year!!
Logged

Katowice POLAND
Offline Offline
Full Member
***
Karma: 2
Posts: 127
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

try different baudrates (my module is on 19200) and remember to cross rx and tx (so arduino rx goest to bt tx )
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you very much, zachwiej
I tried 9600, 19200, 57600 and 115200 always crossing Tx &Rx (and sometimes not crossing), without success. Anyway, my device works well with 9600 with <SoftwareSerial.h>. But I want to use the standard way to connect it, on pins 0&1. I don't give up!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've also tried to change the external power supply to 12V and a ton of things more... It seems that pins 0&1 not send or receive data, but the usb connection is working properly when I use. And also works the softwareserial.h
Is there any software instruction to (force) turn off the usb connection and only turn on the hardware serial on 0&1?
Thank you!
Logged

Pages: [1]   Go Up
Jump to: