I have attached a maxr3232 board to my Uno, hooked it up as follows:
Uno RX pin (0) - max3232 TX
Uno TX pin (1) - max3232 RX
Gnd/3.3v
After some initial issues getting it to detect the board, .available() now returns true but the arduino doesn't seem to read any serial data from the max3232.
I'm using the following script to test:
#include <SoftwareSerial.h>
#define rxPin 0 // 10
#define txPin 1 // 11
int baudrate = 9600;
String command = ""; // Stores response of bluetooth device
SoftwareSerial softSerial(rxPin, txPin); // RX, TX
void setup()
{
softSerial.begin(baudrate);
Serial.begin(baudrate);
Serial.println("HW Serial Ready!");
}
void loop() // run over and over
{
if (softSerial.available()) {
Serial.println("Soft Serial available");
}
else {
Serial.println("Soft Serial not available");
}
int data = softSerial.read();
Serial.println(data);
Serial.println(char(data));
delay(1000);
}
The arduino+maxrs232 are hooked up to a laptop running the arduino ise with the above script and the serial monitor.
I'm using a pc with usb/rs232 cable to send data to the arduino but nothing seems to be coming through.
Specification:
Product Name RS232 Serial to TTL Converter Module
Chip MAX3232
Working Voltage 3.3V/5V
Total Size 45 x 32 x 14mm/1.8" x 1.3" x 0.55"(LWH)
Package Content
1 x RS232 Serial to TTL Converter Module
Description:
Built-in MAX3232 or equivalent Transfer chip.
Fully compatible with existing legacy COM port software.
Easy to use, Compact design.
Output signals: VDD TXD RXD CTS RTS GND.
Power TX RX LED.
Please modify your post (Upper right of the post) , select the code part and press the # button (above the smileys)
That will insert code tags and makes the code better readable.
@Paul: sorry about that. Would like to continue the conversation in this thread.
As a test and learning thing I' m trying to send data from my pc to the Arduino over rs232.
When I know that works (and more importantly 'how') I want to read data from other devices with a comm port.
@robtillaart: post updated with code tag. Will try your update tonight when I get home.
Respondo en español porque mi ingles apesta. El problema que tienes es conficto de hardware.
Esta usando los pines 0 y 1 para SoftwareSerial, y al mismo tiempo usas la comunicacion por hardware.
Cambia la coneccion de los pines 0 y 1 a 2 y 3, ademas tu sketch debe ser:
Greetings.
I answer in Spanish because my English sucks. The problem you have is hardware confict.
This using pins 0 and 1 for SoftwareSerial, while using the communication hardware.
Change the connection pins 0 and 1 to 2 and 3, plus your sketch should be:
#include <SoftwareSerial.h>
#define rxPin 2 // 10
#define txPin 3 // 11
int baudrate = 9600;
String command = ""; // Stores response of bluetooth device
unsigned long nr = 0;
SoftwareSerial softSerial(rxPin, txPin); // RX, TX
void setup()
{
softSerial.begin(baudrate);
Serial.begin(baudrate);
Serial.println("HW Serial Ready!");
}
void loop() // run over and over
{
if (softSerial.available())
{
Serial.println("Soft Serial available");
char data = softSerial.read();
Serial.print(nr); // which byte
nr++;
Serial.print("\t");
Serial.print(data); // integer format
Serial.print("\t");
Serial.println(char(data)); // ascii format
}
}
Switched RX=0 and TX=1 to RX=10 and TX=11.
0 and 1 seem to be used by the onboard serial. If I use those pins the RX light on the MAX3232 lights up at the same time as the RX light on the Arduino Uno (which is still connected to the laptop via USB to watch the serial monitor).
After the change to RX/10 and TX/11 or (8/9) nothing seems to happen, softSerial.available() never seems to become true.
I have connected a USB/RS232 cable to the Arduino Uno/MAX3232 and the other end into a PC (com 5).
When I send some text using a command line serial send util to com5 it says "written" on the pc side but the RX light on the MAX3232 never lights up.
Ok, made some progress with RX on pin 2 and and TX on 3. Running TeraTerm on the computer connected via the RS232 cable, I can see text send from the Arduino (still connected to the laptop via usb) coming in.
Now the only thing I need to get working is the other way around. Send text from the computer to the Arduino using Software serial.