I have been experimenting with the Swarm M138 Transceiver Kit with an ESP32 dev kit, and have had no problems communicating with the modem via the Hardware Serial ports using the Sparkfun Arduino Library.
I noticed in the SparkFun_Swarm_Satellite_Arduino_Library.cpp file there seems to be some sort of support for communication over Software Serial. I have tried using the espsoftwareserial Arduino library (which works well with other UART devices) to initialise a software serial connection, then initialising the M138:
#include <SoftwareSerial.h>
#include <SparkFun_Swarm_Satellite_Arduino_Library.h>
SoftwareSerial swarmSerial;
SWARM_M138 mySwarm;
#define TXD2 14
#define RXD2 13
void setup() {
Serial.begin(115200);
while (!Serial)
; // Wait for the user to open the Serial console
Serial.println(F("Swarm Satellite example"));
swarmSerial.begin(115200, SWSERIAL_8N1, RXD2, TXD2);
bool modemBegun = mySwarm.begin(swarmSerial); // Begin communication with the modem
while (!modemBegun) // If the begin failed, keep trying to begin communication with the modem
{
Serial.println(F("Could not communicate with the modem. It may still be booting..."));
delay(2000);
modemBegun = mySwarm.begin(swarmSerial);
}
I also tried to enable the software serial mode by calling: ``` #define SWARM_M138_SOFTWARE_SERIAL_ENABLED 1
However, I cannot get any method to work, and unfortunately I'm out of ideas. Is there a way to achieve this with an ESP32? Any information would be great.
Thanks!
We’ve noticed issues on some ESP32 boards where the RXD and TXD pin numbering definitions cause problems. Can you please try a simple loop-back test? Disconnect the modem. Use a jumper wire to link 14 to 13. Open the serial monitor. Whatever you type and send should be echoed straight back?
Thanks for the quick response. So I was unable to get the loop-back test to work , however I was able to communicate between two ESP32 boards using software serial and the same pins (and names) as above, so I’m not sure what the issue might be.
I think you’re right, the SoftwareSerial loop back works up until 57600 Baud, but like you said it fails at 115200. The espsoftwareserial documentation claims support up to 115200, but maybe that’s more of a maximum. Is it possible to set the M138 to communicate at a lower baud rate?
All good, no I absolutely don’t need software serial, I’ve been using hardware serial with the M138 up until now and it works flawlessly, it was more just curiosity.