Arduino Pro Micro won't do softwareserial ?

Hello,

Apologies if this is the wrong section for this, but it seems to be an arduino hardware issue, so this seemed most appropriate.

I have one of these knockoff tiny units with an AtMega32u4:

And I’m trying to use it as a softwareserial device to talk to a Sim808 and issue simple AT commands. I’m using this very basic sketch which works on a regular arduino uno:

//#include "SIM900.h"
#include <SoftwareSerial.h>
//#include <GSM.h>

//GSM_SMS sms;

SoftwareSerial mySerial(5, 6); // RX, TX

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

Serial.println("Goodnight moon!");

  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
  mySerial.println("AT");
//  mySerial.println("AT+CGNSTST=1");


}

void loop() {
  // put your main code here, to run repeatedly:

if (mySerial.available()) {
    Serial.write(mySerial.read());
  }
  if (Serial.available()) {
    mySerial.write(Serial.read());
  }

}

I’ve tried various pin combos starting with 2,3 then 3,4 etc and none of them seem to be able to send data.

If I put this same code onto an Uno, I can send AT commands and see the return values with no problem.

What am I missing here? Is it possible I just have a bad unit?

Many thanks,
Rich

See docs: Arduino - SoftwareSerial

Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

Why use software serial? Are you already using the hardware serial port (Serial1) for something else? Hardware serial is better - its full duplex (can send and receive simultaneously - software serial can’t), doesn’t use your PCINTs, and doesn’t block while sending.

Hardware may be an option, but I'm using the USB connection back for terminal I/O so I can type the AT commands and see the result on a terminal screen.

Also, I will eventually want to be able to talk to multiple devices with this, so there's that.

Softwareserial works fine for this with exactly the same code on an uno. Any idea why it's different on this "Pro micro" device?

Thanks, Rich

From https://www.arduino.cc/en/Reference/softwareSerial:

Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).

This also applies to the Pro Micro. So this means you can't use pin 5 for RX, that's the cause of your problem.

Unlike other Arduino boards, pins 0 and 1 on the Pro Micro is Serial1, not Serial. That means you can use hardware serial on those pins without interfering with your use of Serial to communicate with the computer or upload sketches.