Pages: [1]   Go Down
Author Topic: reading 3.3v serial output  (Read 527 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

not sure what i'm doing wrong here. an oscilloscope would help but i don't have one. here's what i'm trying to do:

wrt54g wireless router output text on it's LVTTL serial to arduino on rx port
- the wrt54g can output text no problem to a PC at either 115200bps or 9600 (using setserial to change)
- when i output to a pc, i use a max3232c to convert the 3.3v output to rs232 levels

when connecting to the arduino, since i just need to receive data on the arduino i wanted something simpler than a powered IC, i setup a 2N3904 transitior like this:

wrt54g 3.3v tx -> BASE
arduino 5v -> COLLECTOR
arduino rx -> EMITTER

(resistors on the base and collector)

really simple program:

------------------------------
int incomingByte = 0;   // for incoming serial data

void setup() {
   Serial.begin(9600);
}

void loop() {

  incomingByte = Serial.read();
  if (incomingByte > -1 ) {
    Serial.print(incomingByte);
  }
}
-----------------------

if a computer is connected to the arduino via serial I expect this to happen:

"hello" -> wrt54g serial tx -> 2N3904 -> arduino tx -> serial to PC receiving "hello"

what i get is nothing. incomingByte is always equal to -1

any ideas?
Logged

0
Offline Offline
Faraday Member
**
Karma: 16
Posts: 2855
ruggedcircuits.com
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Move the resistor from the collector to the emitter, and have it go to ground. The Arduino input pin is at the connection of the emitter and this resistor (I'd go with 4.7k or so).

Or you can just try a direct connection. 3.3V is sorta maybe high enough for the Arduino to read as high.

And don't forget to connect the grounds together!

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons
Logged

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

thank you!

common ground between the arduino and the wrt54g's serial port was all i needed for a dirty 3.3v tx signal to be read from the arduino's rx.

i didn't do this before because both the wrt54g and the arduino are in the same 12v power supply although on different rails.

now instead of a constant stream of -1 i see other values when things are echod to the wrt54g's serial port... and it's even simpler than with the 2N3904.

thank you again!
Logged

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

i worked on this all day (>6 hours) which for someone more experienced would have been a couple minutes but i learned lots and feel very good about my achievement.

i can now do what i need, send stuff to the serial port and have the arduino understand it.

i'm just using a direct connection to the TX1 pin to the arduino RX pin, grounding the arduino to the wrt54g's serial ground.

i was originally changing the baud from 115200 on the wrt54g to 9600 but the arduino i found can do 115200! lots of credit to the link below, i took parts of his code to make something much simpler than what he was doing. here it is:

Arduino code, credit http://kennethfinnegan.blogspot.com/2010/09/hacking-wrt54gl-serial-port.html - my code is based on this


char k;
int j;

void setup() {
   Serial.begin(115200);
}

void loop() {
  if (Serial.available() > -1) {
    for (j=0; j < 16 && Serial.available(); j++) {
      k = Serial.read();
      Serial.print(k);
    }
  }
}

this will output whatever you see on the console during boot time, as well as stuff you echo with  echo "b" > /dev/tts/0 from the wrt54g for example.

now for a beer smiley
Logged

Pages: [1]   Go Up
Jump to: