Hello,
I have been attempting to get serial communication working on various ESPs for a bit now. I have spent many hours looking through various types of documentation, and I am hoping someone can simply fill me in on something I am fundamentally missing here.
So, my intent is to simply communicate with the Modem using an ESP8266 or a ESP32. My latest attempt is using an ESP32, this one to be particular.
https://www.amazon.ca/DIYmalls-Transcei … NrPXRydWU=
For my wiring, I have GND → GND, 5V → VIN, PIN 16 (RX) → TX0, PIN 17 (TX) → RXI. Yes I have broken the PCB jumpers, and yes I have checked via measuring continuity across them.
I have spent some time testing the output serial port (pins 16/17) of my board (by communicating with another of the same board) and have successfully sent data via serial by setting up my serial port this way "
HardwareSerial Sender(1); // Define a Serial port instance called 'Sender' using serial port 1
#define Sender_Txd_pin 17
#define Sender_Rxd_pin 16
void setup() {
//Serial.begin(Baud Rate, Data Protocol, Txd pin, Rxd pin);
Serial.begin(115200); // Define and start serial monitor
Sender.begin(115200, SERIAL_8N1, Sender_Txd_pin, Sender_Rxd_pin); // Define and start Sender serial port
The above setup does appear to send data that I can receive on the other board, running a similar code, but rather opening a port (on the same pins) and listening for data coming in.
I am attempting to run any of the programs in the Swam example code (and I have added the Swarm library), espcially Example1 or Example14 and I cannot get the connection to be established. I keep getting the “Could not communicate with the modem. It may still be booting…”
I am noticing the difference between how the serial port is declared in the example
#define swarmSerial Serial1
vs mine
HardwareSerial Receiver(1);
And to get mine to work, I have been also using the "
#define Sender_Txd_pin 17
#define Sender_Rxd_pin 16
The question then becomes, how would I add in the
swarmSerial.begin(115200, SERIAL_8N1, Sender_Txd_pin, Sender_Rxd_pin);
``` equivalent??
Would it be the above code, and then add in "
bool modemBegun = mySwarm.begin(swarmSerial); // Begin communication with the modem
after it?
Either way, I have tried it in many configurations of this code. I have tried different serial port pin declarations, different port declarations, and many attempts at getting this to work.
Any glaring issues here, or things you would recommend I attempt? I have also tried the following to "hardcode" serial communication to the modem, to see if I could get any response. I have not yet. I'm assuming it's because I am missing fundamental things happening in the background inside the library this example code is using (My SWARM).
Here is the "hardcode" attempt.
// Sending/Receiving example
HardwareSerial Sender(1); // Define a Serial port instance called ‘Sender’ using serial port 1
#define Sender_Txd_pin 17
#define Sender_Rxd_pin 16
const char payload=“$CS*10”;
void setup() {
//Serial.begin(Baud Rate, Data Protocol, Txd pin, Rxd pin);
Serial.begin(115200); // Define and start serial monitor
Sender.begin(115200, SERIAL_8N1, Sender_Txd_pin, Sender_Rxd_pin); // Define and start Sender serial port
}
void loop() {
//float sensor_temperature = 22.141; // Set an example value
Sender.println(payload); // Send it to Sender serial port
Serial.println(“sent”);
delay(200);
if (Sender.available()) { // Wait for the Receiver to get the characters
String received = Sender.readString(); // Display the Receivers characters
Serial.println(received); // Display the result on the serial monitor
}
else {
Serial.println(“not connected yet”);
};
delay(2000);
}
Please note, in the code above, it always prints "not connected yet" which to me means the serial port does not see active data, although it should see some from a response from the command issued just before it. I have played around with a few timings of delays (both before and after the send data command) and I have the same issue.
... One last data point, I have confirmed the modem is still working by connecting the USB and running the Python GUI, and once I connect the jumpers again, I am able to run it like normal.
This appears to be an issue in my serial configuration or code initialization that doesn't work.
Let me know what you think. Thanks!