sparkfun / SparkFun_Swarm_Satellite_Arduino_Library

An Arduino library to enable communications with the Swarm M138 satellite modem
Other
28 stars 10 forks source link

Serial Ports, RAM Requirements and Pin Voltages #18

Closed K4KDR closed 2 years ago

K4KDR commented 2 years ago

Good day!

My SPX-19236 arrives in a few days - can't wait!

To prepare, I have explored both the Pi (python GUI) and Arduino options to interface to this device.

Initially, I'll certainly use a Pi to allow me to interact with the modem via your excellent GUI. I fully understand using one of the Pi's USB ports to both communicate with -and- power the SPX-19236.

I've also been exploring the Arduino examples to prepare myself to eventually setup the SPX-19236 in a stand-alone configuration to periodically uplink the value of an analog sensor via the Swarm constellation.

However, I am confused by the 'serial' connection to the SPX-19236 such as referenced in this line of code:

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

... the only 'Serial' that I have any experience with on a variety of Arduino products is the serial connection via USB to upload code and later view output via a Serial Monitor.

What is, or how do you use 'Serial1' for communication with the SPX-19236?

The example code seems to use the conventional 'Serial Monitor' (that I am used to) to echo messages to the user, but I'm not clear on how the SPX-19236 connects to the Arduino.

Thanks very much!

-Scott, K4KDR

PaulZC commented 2 years ago

Hi Scott (@K4KDR ),

Newer "Arduino" boards usually have more than one hardware serial port. The console (USB) serial port is usually called "Serial" (although it can sometimes be called "SerialUSB"). The second hardware serial port is usually called "Serial1". The examples were written with "Serial1" in mind, but it is easy to change. Simply replace "Serial1" with the name of the port.

Some older boards have only one hardware serial port. On those boards, you may be able to use SoftwareSerial instead - see below. But those boards usually also had very limited RAM and this library needs more than 2kBytes of RAM - to store the incoming and outgoing Swarm messages. If you have a "Uno"-type board (ATmega328P) or one of our original RedBoards (also ATmega328P), you will need to upgrade.

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

#include <SoftwareSerial.h>
SoftwareSerial swarmSerial(2,3); // RX pin, TX pin

Also, some of those older boards were 5V boards - the signals on the I/O and Serial UART pins were 5V. The Swarm Breakout needs 3.3V serial. If you have a 5V board, you will need a level-shifter to convert your 5V signals to 3.3V.

https://www.sparkfun.com/products/12009 https://www.sparkfun.com/products/19626

The good news is that most newer boards are: 3.3V; have plenty of RAM and program memory; and usually have multiple hardware serial ports. There are many to choose from.

Best wishes, Paul

K4KDR commented 2 years ago

>>> If you have a "Uno"-type board (ATmega328P) or one of our original RedBoards (also ATmega328P), you will need to upgrade.

That's extremely helpful - thanks very much for the reply!

I have ordered a couple of the newer ('Due') boards which have way more memory, 4x serial UARTs, & 3.3v I/O.

In the meantime, I was going to use the RPi first anyway, so I'll look forward to putting this unit on-the-air as soon as it arrives.

Thanks again!

-Scott