Pages: [1]   Go Down
Author Topic: RN-42 and Arduino connection  (Read 1483 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
Need help. I have the following setup Arduino UNO R3, Bluetooth RN-42, Android tablet with "BlueTerm" application. I soldered everything and the tablet is connecting to the RN-42 just fine. I can also short the RX and TX on the RN-42 and see the character echo on the tablet.
On the connection to the Arduino - I'm able to send text from the Arduino to the tablet terminal.
The thing that is not working is the connection between the output of the RN-42 and the input to the Arduino.
When I load the program below, the led only turns on for 2 seconds, meaning that the Serial.available() is working only when I connect the TX from the RN-42 to the RX of the Arduino - and then it is not available for the next time the loop occurs - any ideas??

int ledPin=8;
void setup()
{
  Serial.begin(115200);
  pinMode(ledPin, OUTPUT);
}
 
void loop()
{

    if (Serial.available() >0)
   {
     char cmd = Serial.read();
     Serial.print(cmd);
     digitalWrite(ledPin, HIGH);
   
     if (cmd=='1')
     {
       digitalWrite(ledPin, HIGH);
       Serial.print("HIGH");
     }
     else if (cmd == '0')
    {
      digitalWrite(ledPin, LOW);
      Serial.print("LOW");
    }
  } else {digitalWrite(ledPin, LOW);}
 
delay(2000);
}
Logged

Kentucky, US
Offline Offline
Full Member
***
Karma: 1
Posts: 193
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry for asking the obvious, but are you continuing to send characters from the Android?  Serial.available() will return false once you've emptied the receive buffer.

FWIW, I've gotten the RN-42 to work in a similar situation with an Arduino-compatible board, so I'm confident you'll get this solved.

Jim
Logged

TC4 Open Source Digital Thermometer and Temperature Controller
http://code.google.com/p/tc4-shield

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

Thanks for the reply Jim.

Yes, of course - I'm trying to send the characters from the Android like a crazy man, but the Arduino doesn't respond to any input, even though I know for sure that the TX from the Arduino is active and is sending the characters that I type.

I'm so lost on this.

One thing that I did read is that somewhere I should define the port on the Arduino for the connection with the bluetooth? I'm using Linux (11.10) and the Arduino is defined on.../ACM0 but other than that I don't know where to define a specific port for the Arduino to talk to the bluetooth.

Thanks again for your help.
Logged

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

Sorry - I mean the TX from the RN-42.
Logged

Kentucky, US
Offline Offline
Full Member
***
Karma: 1
Posts: 193
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

One thing that I did read is that somewhere I should define the port on the Arduino for the connection with the bluetooth? I'm using Linux (11.10) and the Arduino is defined on.../ACM0 but other than that I don't know where to define a specific port for the Arduino to talk to the bluetooth.
I'm not following this.  The Linux box shouldn't be connected to the USB port on your Uno while you are using the RN 42.  So (unless I am missing something) the port setup on your Linux box would be irrelevant.

My suggestion would be to use a stripped-down sketch that does nothing more than flash the LED briefly every time a character is read from Serial.  You might also want to try to establish communication with the Uno/R42 through a BT connection to your Linux box to see if the problem maybe lies with the Android app.

Jim

Logged

TC4 Open Source Digital Thermometer and Temperature Controller
http://code.google.com/p/tc4-shield

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

Thanks Jim. I think this is was a progress for me - When I tested this, I always had the Arduino and the Linux connected since I used the USB as the only source of power. Didn't that the serial USB connection had to be disconnected in order for this sketch to work.

I tried the sketch again with a 9V connection (without the USB) and although it still doesn't work, I was able to see "LOW" on the Android app one time - which is a first since I was never able to have a print from within the "if cmd".

As for the Android app, I did try 2 separate apps in the process and also when I short the TX and RX on the RN42 - I get the echo on the terminal on the Android - I don't know if it means that the problem is somewhere else though.

Thanks for the first advice though I didn't realize the USB to Linux had to be disconnected. I wish I was a little bit closer to get this setup to work though...
Logged

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

Problem was resolved just by replacing the RN42 module with a new one
Logged

Pages: [1]   Go Up
Jump to: