Hi,
I have a new project. I want to use an Arduino to read serial data that is being sent by an IR serial port at 9600 baud (by an electricity meter).
So I set up a test to see if I can send serial data from one Arduino to another using an IR LED and an IR phototransistor. See attached schematics.
After some tinkering I got this sort of working. However, I can only make it work at 2400 baud. When I try at 9600 baud I receive different characters from the ones I sent. Some bits seem to get lost / added / changed.
So I was wondering what the speed limiting factor is here. Do I need a phototransistor with a faster response? Is it the LED? Or something else?
The sketches are very simple:
//sending Arduino:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(13, 3, true); // RX, TX, inverse_logic
void setup() {
Serial.begin(9600);
Serial.println("starting...");
mySerial.begin(2400);
}
void loop()
{
if (Serial.available())
{
mySerial.write(Serial.read());
}
}
//receiving Arduino:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 3, true); // RX, TX
void setup()
{
pinMode(4, INPUT);
Serial.begin(9600);
Serial.println("starting...");
mySerial.begin(2400);
}
void loop()
{
if (mySerial.available())
{
Serial.write(mySerial.read());
}
}
Arduino_IR_serial_test - Schematic.pdf (30.7 KB)