Can I write from one softwareserial port to another on same arduino?

Hi I’m trying to debug communication from an arduino nano to a sim800c gsm chip, which isn’t working, so I’ve tried connecting the softwareserial TX pin (in my case, pin 8) to the softwareserial RX pin (9), just to see if the arduino is actually transmitting and receiving data. This doesn’t work, should it?

sim800c_serial.ino (1.3 KB)

Voellmer:
Hi I’m trying to debug communication from an arduino nano to a sim800c gsm chip, which isn’t working, so I’ve tried connecting the softwareserial TX pin (in my case, pin 8) to the softwareserial RX pin (9), just to see if the arduino is actually transmitting and receiving data. This doesn’t work, should it?

Why not use a LED in series with a 220 Ohm resistor? If the LED is correctly connected, it will light, and then blink with data transmission.

Paul

With software serial you can't read in what is being sent out at the same time.

In this part of your code:

  if (Serial.available()) {
    int b = Serial.read();
    Serial.write(b);
    // Serial.print("now");
    serialSIM800.print(b);
  }

There is a difference between write() and print()

@CrossRoads even on different pins? Isn't the RX pin buffered? How does the RX pin know what is transmitting, or when it was transmitted? Thanks!
@blh64 yeah I'm trying all different combinations. Thanks! I'll go RTFM now...:slight_smile:

Voellmer:
@CrossRoads even on different pins? Isn't the RX pin buffered? How does the RX pin know what is transmitting, or when it was transmitted? Thanks!
@blh64 yeah I'm trying all different combinations. Thanks! I'll go RTFM now...:slight_smile:

Even on different pins. Software serial is half duplex. One instance of software serial at a time can transmit or send. If you try to do two at once, both normally end up with gibberish.

Unlike real hardware serial, there is no RX buffer, and each transition has to occur while interrupts are enabled.

Software serial sucks. I avoid using it whenever possible, choosing parts with enough serial ports for my purposes (at most, I'd use one software serial instance) - (with 2: 328PB, tiny841/1634, '1284p; with 4: '2560)

For debugging, one thing I often do is, for each line (tx or rx) I want to monitor, I connect one additional serial adapter. Tie all grounds together, and put an RX line of each additional serial adapter onto the serial lines you want to monitor. Open multiple terminal windows (I strongly recommend hterm on windows for this kind of thing - you can even use the modem control pins to see the status of pins from behind the keyboard; when I have been intensively developing serial applications, this was a godsend). Serial adapters are like a buck-and-change each on ebay (if going CH340G, get the black ones with the voltage switch, or the green ones with the voltage switch and microusb port. Dont have specific recommendations for CP2102 based ones) - though they don't break out the modem control pins (I sell one that does, for a considerably higher price since I assembled them myself with tweezers)