Networking of data via Acoustic Modem(NanoModem)

Good Morning,

I was hoping to get any help or advice on this topic. I am trying to connect an Arduino Uno Microcontroller to an acoustic modem and use this to communicate with another ardunio/modem connection.

I have connected my Arduino with the usb and used a softserial to create a rs232 interface with the acoustic modem. Because the modem and arduino both have Rs232 female heads, I have used a null modem cable to make this connection.

My first test setup needs to be Arduinoà to nanomodem0 to nanomodem1 to PC (terminal). I am going to test by using a unicast command e.g. $U0015hello (send to address 001, 5 bytes, “hello”) and you should see %U5hello appear on the terminal. If that works then I can replace “hello” with your sensor data of any length up to 7 bytes.

The nanomodem already has inbuilt commands to query its status like $?.

How do I write a code for this?

#include <SoftwareSerial.h>

SoftwareSerial port1(8, 7);
#define BAUD 9600
void setup() {

Serial.begin(9600);
while (!Serial) {
;
}

port1.begin(9600); }

void loop(){
String input;
//If any input is detected in arduino
if(Serial.available() > 0){
//read the whole string until ‘\n’ delimiter is read
input = Serial.readStringUntil(’\n’);
if (input.equals("$U0015input")){

}

else if {
Serial.println(“Error”);
}
}
}

The nanomodem has the details I have attached.

I appreciate any help I can get with this.

Nanomodem v2.1 user guide.pdf (685 KB)

Because the modem and arduino both have Rs232 female heads, I have used a null modem cable to make this connection.

According to the attached documentation the NanoModem uses RS232 level, so you must not connect it directly to the Arduino, you may damage any of the devices. A MAX232 or similar chip may do the level translation.

What do you want this communication to be used for? If you use SoftwareSerial your Arduino will not do much except that communication because of the horrible design of the library.

Thank you for your reply. So with the nullmodem I have got the arduino and the nanomodem working and it can communicate with the other nanomodem connected via RS232 to the PC.

The goal is to be able to send sensor data from the arduino through the nanomodem to the second nanomodem if that makes sense.

At the moment if I have it connected. From a terminal program putty, they can communicate with each other but I need a code in which arduino runs and it communicates data.

So with the nullmodem I have got the arduino and the nanomodem working and it can communicate with the other nanomodem connected via RS232 to the PC.

In this case post a complete wiring diagram of your setup.

At the moment if I have it connected. From a terminal program putty, they can communicate with each other but I need a code in which arduino runs and it communicates data.

If the communication already works you seem to have an Arduino sketch that works with the modem. Please explain what you need additionally and post the code you're currently using.

#include <SoftwareSerial.h>

// need a serial port to communicate with nanomodem
SoftwareSerial gtSerial(8, 7); // Arduino RX (GT TX), Arduino TX (GT RX)

void setup() {
Serial.begin(9600); // serial connection to processing app.
gtSerial.begin(9600); // for communicating with the nanomodem
}

byte rx_byte = 0; // stores received byte

void loop() {
if (Serial.available()) {
// get byte from processing app. and send to nano
rx_byte = Serial.read();
gtSerial.write(rx_byte);
}
if (gtSerial.available()) {
// get a byte from the FPS and send it to the processing app.
rx_byte = gtSerial.read();
Serial.write(rx_byte);
}
}

That is the code im using on Arduino so when I send a nanomodem command that querys its status $? it should give me the battery volatage, it just gives me a error as attached

That is the code im using on Arduino so when I send a nanomodem command that querys its status $? it should give me the battery volatage, it just gives me a error as attached

That doesn’t look like an error but simply white noise on the data line.

And the code you posted (you forgot the code tags, please fix!) is simply a forwarding device. So in my opinion this does not work. And according to the documentation you need to fix that level problem TTL <-> RS232. You might even already have damaged your Arduino (it really doesn’t like negative voltages which are common on RS232).