Hello, please read my post carefully as I've already done a LOT of troubleshooting on this.
So I have a sensor that streams comma delimited ASCII data constantly. It streams at 4800 baud rate on RS-232 protocol. I have gotten this sensor to send data to my PC through a RS232-USB cable. I know that this sensor works correctly.
When I connect this sensor to a MAX232 breakout board (this board specifically) and then connect that to my Arduino uno, I absolutely cannot get it to output any readable data of any kind. I know that the sensor works and streams, I know that the MAX232 board works (I've used it in other projects), and I know that my arduino serial ports/code works (tested with other devices). But none of it works when put together. Here is my code:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 5, 1); // RX, TX
String content = "";
char character;
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Native USB only
}
Serial.println("hello");
// set the data rate for the SoftwareSerial port
mySerial.begin(4800);
//mySerial.println("Hello, world?");
}
void loop() // run over and over
{
//Serial.println(mySerial.available());
while (mySerial.available()>0) {
Serial.print(mySerial.read());
}
Serial.println();
delay(50);
}
It's a super basic serial streaming code, I'm using softwareSerial library to try and read the serial input from the sensor to my PC. What happens is that I will usually get no answer from the sensor even though I know that data is streaming on it, I checked with my oscilloscope and saw the data coming in on the MAX232 serial pin, the arduino just isn't doing anything for some reason?? Or if I fiddle with any small settings, or turn my sensor off then on again, sometimes I can start to get a bit of data in on the port, but it ends up being a stream of numbers that can't be converted properly to ASCII format or anything?? Again, remember, I've connected this sensor directly to my PC and had no problem streaming in the readable ASCII data.
I've found that when I set the softwareSerial to inverse_logic, I tend to get something more often than if I do not set it to inverse_logic. Would anyone have an explanation for this?
I have tried with Serial.write() and Serial.print() and neither function gives any readable results, if any results at all.
Also, PLEASE do not come at me with any stuff about "Have you checked that you have the right baud rate?" YES I HAVE THE CORRECT BAUD RATE!! THIS SENSOR WORKS AT 4800 BAUD, IT IS IN THE DATASHEET, IT WORKS WHEN CONNECTED TO MY PC!
This is seriously driving me insane, I can't figure out what is wrong, other people can't figure out what is wrong, why won't this sensor simply stream to the arduino? Is it a timing issue? Am I missing something with converting the incoming data? Why does the data not show up at all when I don't set the inverse_logic to 1? When it does show up, it is either a stream of integer/decimal numbers, or hex numbers (if I set the serial output to hex), that can't be converted to readable ASCII. Any explanation for this?
