1

Good evening, I'm trying to establish serial communication between an Arduino UNO/Nano (ATMega328P) and a SP1ML-868 RF radio module (http://www.st.com/en/wireless-connectivity/sp1ml.html). I can talk to the radio with an FTDI breakout board, connected directly to my PC, but I can't do it with the Arduino.

As the radio is 3.3V and the Arduino is 5V, I tried to use the logic level converter from Sparkfun in the RX/TX lines, but that didn't work as well.

Any idea as to what I might be doing wrong? Thanks!

EDIT
I was able to talk to the radio by uploading a blank sketch to my Arduino and using only the RX/TX pins and the FTDI chip on the board. When I configure the Serial port (i.e. Serial.begin), this no longer works, which leads me to believe the problem is in the ATmega USART configuration. For some weird reason, this only works when the Arduino RX is connected to the module RX, and TX with TX.

As requested, below is the simple serial echo code I'm using, and an image with the wiring. This assumes the normal RX->TX and vice-versa connection. The module is powered through wires underneath its breakout board (3.3v).


void setup(){
  Serial.begin(115200);
}

void loop(){ while(Serial.available() > 0){ Serial.print((char)Serial.read()); } }

enter image description here

  • Please edit your question to include a complete minimal sketch that demonstrates the problem. Please edit your question to explain how you have the module wired to the Arduino board. – per1234 Aug 13 '17 at 0:16
  • @per1234 There, does that help? – RenanGM Aug 13 '17 at 2:22
0

For some weird reason, this only works when the Arduino RX is connected to the module RX, and TX with TX.

This works because in that configuration you are actually using your Arduino as a USB-serial adapter. When you make the RX-RX, TX-TX connection you cannot communicate between the ATmega328P on your Uno but you are also making a RX-TX, TX-RX connection with the ATmega16U2 chip on your Uno that is used as the USB-serial adapter on the board.

I feel that it's problematic to try to use Serial (pins 0 and 1) for communication both with the computer and the module. Instead I would recommend using the SoftwareSerial library for communication between the Uno and the module.

SoftwareSerial doesn't work reliably at 115200 so you should first use the current working wiring to configure the module to communicate at a lower baud rate. 9600 is quite safe but if communications speed is a bottleneck for your application you can probably use a higher baud rate.

Next, wire the module to any unused pins on your Uno other than 0 and 1.

Finally, upload the following code to the Uno:

#include <SoftwareSerial.h>

SoftwareSerial SP1MLserial(10, 11); // RX, TX

void setup() {
  Serial.begin(115200);  // set this to the baud rate of the Serial Monitor
  SP1MLserial.begin(9600);  // set this to the baud rate of the module
}

void loop() {
  if (SP1MLserial.available()) {
    Serial.write(SP1MLserial.read());
  }
  if (Serial.available()) {
    SP1MLserial.write(Serial.read());
  }
}

This is the equivalent of the simple echo code you posted above and can be used to verify that everything is working before moving on to more complex code. I have arbitrarily chosen pin 10 for the Uno software serial RX pin 11 for the TX pin but you can modify the code to any pins that are convenient for you. You should make the connections with the module as RX-TX, TX-RX.

  • Thanks for the answer! However, I tried your suggestions and it still does not work. I send a command to the module (i.e. "+++\r", to enter command mode) and get nothing in return. If it helps, this module's serial comm is done with an STM32L1 ARM MCU, which connects to the SPIRIT1 radio via SPI protocol. Maybe there is a mismatch between the SoftwareSerial protocol and the one used in the ARM? – RenanGM Aug 13 '17 at 14:23
0

Not an answer to my question per-se, but I was able to solve my problem.
As mentioned on my comment on the last answer, the SP1ML module's serial communication is handled through an ARM microcontroller. So I got my hands on an Arduino Due, which has an ARM Cortex M3 MCU, and uploaded a serial echo code similar to the one on my question, only now using Serial3 to talk to the module:


void setup(){
  Serial.begin(9600);    // Connected to PC
  Serial3.begin(115200); // Connected to SP1ML, Rx-Tx connection
}
void loop(){ if (Serial.available() > 0){ Serial3.write(Serial.read()); // Echo to SP1ML } if (Serial3.available() > 0){ Serial.write(Serial3.read()); // Echo to serial monitor } }

I tried the exact same code on an Arduino Mega (same pins, ATmega2560 MCU) and it didn't work.
Obviously the MCUs are very different, but I have no idea one works and the other doesn't. A wild guess would be that the word sizes are different. In the Atmega, the word size is 16-bits, and in the ARM, the word size is 32-bits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.