Swarm-Technologies / Getting-Started

62 stars 20 forks source link

I can't connect modem 138 eval kit with esp32 #28

Open wstack-dev opened 1 year ago

wstack-dev commented 1 year ago

Hi, I'm plugging an ESP32 into an evaluation kit.

[env:nodemcu-32s] platform = espressif32 board = nodemcu-32s framework = arduino lib_deps = sparkfun/SparkFun Swarm Satellite Arduino Library@^1.1.10 monitor_speed = 115200

I have connected to the JTAG headers Captura de pantalla de 2023-02-20 00-28-40

1-I have downloaded the swarm library for arduino. But I can't connect to the hardwareSerial or SoftwareSerial. I have tried in various ways to make it work without success.

2- When executing a simple HardwareSerial code defining the baud and the pins (RX, TX). I can connect to the modem without problems and read the information returned by the eval kit. But even so, I do not receive a response from the commands sent by the serial2 port, since if I send a $FV*10 I do not get the expected response. I only see a $RT RSSI=XXX message every 5 seconds in the serial2.read()

`/*!

include //Click here to get the library: http://librarymanager/All#SparkFun_Swarm_Satellite

SWARM_M138 mySwarm;

define swarmSerial Serial2 // Use Serial1 to communicate with the modem. Change this if required.

void printGeospatial(const Swarm_M138_GeospatialData_t *info) { Serial.print(F("New geospatial information received: Lat: ")); Serial.print(info->lat, 4); Serial.print(F(" Lon: ")); Serial.print(info->lon, 4); Serial.print(F(" Alt: ")); Serial.print(info->alt, 2); Serial.print(F(" Course: ")); Serial.print(info->course, 2); Serial.print(F(" Speed: ")); Serial.println(info->speed, 2); }

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

void setup() { // Swarm Satellite Transceiver MicroMod Function Board PWR_EN

ifdef swarmPowerEnablePin

pinMode(swarmPowerEnablePin, OUTPUT); // Enable modem power digitalWrite(swarmPowerEnablePin, HIGH);

endif

delay(1000);

Serial.begin(115200); while (!Serial) ; // Wait for the user to open the Serial console Serial.println(F("Swarm Satellite example")); Serial.println();

//mySwarm.enableDebugging(); // Uncomment this line to enable debug messages on Serial

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); }

// Just to prove it works, call getGeospatialInfo to request the most recent geospatial information Swarm_M138_GeospatialData_t *info = new Swarm_M138_GeospatialData_t; // Allocate memory for the information

Swarm_M138_Error_e err = mySwarm.getGeospatialInfo(info);

while (err != SWARM_M138_SUCCESS) { Serial.print(F("Swarm communication error: ")); Serial.print((int)err); Serial.print(F(" : ")); Serial.println(mySwarm.modemErrorString(err)); // Convert the error into printable text Serial.println(F("The modem may not have acquired a valid GPS fix...")); delay(2000); err = mySwarm.getGeospatialInfo(info); }

Serial.print(F("getGeospatialInfo returned: ")); Serial.print(info->lat, 4); Serial.print(F(",")); Serial.print(info->lon, 4); Serial.print(F(",")); Serial.print(info->alt); Serial.print(F(",")); Serial.print(info->course); Serial.print(F(",")); Serial.println(info->speed); delete info; // Free the memory

// Set up the callback for the geospatial information message. Call printGeospatial when a new $GN message arrives mySwarm.setGeospatialInfoCallback(&printGeospatial);

// Set the $GN message rate: send the message every 2 seconds err = mySwarm.setGeospatialInfoRate(2);

if (err == SWARM_M138_SUCCESS) { Serial.println(F("setGeospatialInfoRate was successful")); } else { Serial.print(F("Swarm communication error: ")); Serial.print((int)err); Serial.print(F(" : ")); Serial.print(mySwarm.modemErrorString(err)); // Convert the error into printable text if (err == SWARM_M138_ERROR_ERR) // If we received a command error (ERR), print it { Serial.print(F(" : ")); Serial.print(mySwarm.commandError); Serial.print(F(" : ")); Serial.println(mySwarm.commandErrorString((const char *)mySwarm.commandError)); } else Serial.println(); }

// Just to prove it works, call getGeospatialInfoRate to check the message rate uint32_t rate;

mySwarm.getGeospatialInfoRate(&rate);

Serial.print(F("Message rate is ")); Serial.println(rate); }

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

void loop() { mySwarm.checkUnsolicitedMsg(); }`

Response Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting... Could not communicate with the modem. It may still be booting...

Simple serial hardware code

`#include

define RXD2 16

define TXD2 17

void setup() {

Serial.begin(115200);

Serial2.begin(115200, SERIAL_8N1, RXD2, TXD2);

}

void loop() { while (Serial2.available()) { Serial.print(char(Serial2.read())); } }`

Response $RT RSSI=-110*1d $RT RSSI=-110*1d $RT RSSI=-110*1d $RT RSSI=-110*1d $RT RSSI=-110*1d $RT RSSI=-110*1d $RT RSSI=-110*1d $RT RSSI=-110*1d

I send a $RT ?19 by Serial2.Println to stop the command from being sent by the modem. But the modem still sends me the response of $RT 513 (do you understand me??)

I followed the example of DHT20 sensor. But it didn't work for me.

wstack-dev commented 1 year ago

https://github.com/sparkfun/SparkFun_Swarm_Satellite_Arduino_Library/issues/35

I put my problem on sparkfun's github for the swarm library