lukeserial
Posts: 6
Joined: Mon Dec 04, 2017 12:25 am

Can't get FONA 3G to respond to serial on Pi 3

Mon Dec 04, 2017 12:35 am

Hello,

I am new to the Pi from the Arduino world.
I have a FONA 3G module that i previously had hooked up to an Arduino and is worked fine.

Now the FONA is hooked up to the Pi 3 just as instructed in the following tutorial. https://www.digikey.com/en/maker/projec ... c5c1dc2ff0

I followed the advice on this forum to add

Code: Select all

enable_uart=1
in /boot/config.txt

I cannot get any response from the serial monitor after sending a AT command. I am really confused now. I flashed a new image and started from the top but still no luck.

The FONA 3G works fine with the Arduino but I cannot get it to connect with TX RX on the Pi.

Thank you for your help.

lukeserial
Posts: 6
Joined: Mon Dec 04, 2017 12:25 am

Re: Can't get FONA 3G to respond to serial on Pi 3

Mon Dec 04, 2017 1:04 pm

I thought that there might be a problem with the Stretch distribution so I re-imaged my SD card to the last distribution of Jessie.

I followed the instructions on this link: https://raspberrypi.stackexchange.com/q ... pberry-pi3 to enable serial communication.

I installed Screen with

Code: Select all

sudo apt-get install screen
Then I try to access the FONA 3G with the following:

Code: Select all

sudo screen /dev/serial0 115200
The Screen goes to all black with a cursor at the top. I use the caps lock key and type AT then enter

Nothing happens. No matter how many times I do it. According to Adafruit and the tutorial from DigiKey, this should produce a response of OK from the FONA 3G. This works fine with the same FONA 3G when connected to the serial RX TX on my Arduino but not on the Raspberry Pi 3.

lukeserial
Posts: 6
Joined: Mon Dec 04, 2017 12:25 am

Re: Can't get FONA 3G to respond to serial on Pi 3

Mon Dec 04, 2017 8:10 pm

Continuing to troublshoot my inablity to use the serial uart on my Raspberry Pi 3, I tried this test with an Arduino wired to the RX and TX pins.

https://www.jaredwolff.com/blog/raspber ... rial-uart/

The Arduino will send back over serial anything typed. Except in my case, nothing comes back. I checked the connections as recommended.

I also read through the PI 3 uart sticky thread above. viewtopic.php?f=28&t=141195 I followed the suggestions but nothing seems to work on this PI 3. I plan to re-flash a new image once again and start from the beginning again.

Now I am really confused because before it might have been the FONA module but now I can't even get the PI to recieve serial information from an Arduino.

Thank you in advance for any help.

lukeserial
Posts: 6
Joined: Mon Dec 04, 2017 12:25 am

Re: Can't get FONA 3G to respond to serial on Pi 3

Tue Dec 05, 2017 4:53 pm

Now I have some serial response from the Arduino on the Pi via USB using the following code. It does not echo a character it just prints hex numbers to serial in sequence. Via the USB from Arduino to Pi it works fine when I type "sudo screen /dev/ttyAMA0 115200"
It prints out the numbers and does not stop.

If I hook up the Arduino to the RX and TX pins, then it starts to print numbes but suddenly stops. It also skips numbers and adds random spaces. I am typing "sudo screen /dev/serial0 115200" in the Pi terminal.

Below is a image of the Arduino / Pi wiring.

Code: Select all

# define SERIAL_BAUD 115200

char dataString[50] = {0};
int a = 0; 

void setup() {
Serial.begin(SERIAL_BAUD);              //Starting serial communication
pinMode(LED_BUILTIN, OUTPUT);
}
  
void loop() {
  a++;                          // a value increase every loop
  sprintf(dataString,"%02X",a); // convert a value to hexa 
  Serial.println(dataString);   // send the data
  delay(1000);                  // give the loop some break
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW


[attachment=0]schematic-rpi-arduino.png[/attachment]
}
Attachments
schematic-rpi-arduino.png
schematic-rpi-arduino.png (5.51 KiB) Viewed 87 times

lukeserial
Posts: 6
Joined: Mon Dec 04, 2017 12:25 am

Re: Can't get FONA 3G to respond to serial on Pi 3

Wed Dec 06, 2017 2:21 pm

I conducted further testing. The "screen" serial monitor still has strange behavior but "minicom" behaves better when I type

sudo -b 115200 -o -D /dev/serial0

That gets all of the characters from the Arduino.

sudo screen /dev/serial0 115200 randomly crashes and has errors.

I connected pin 8 to pin 10 on the Raspberry Pi. Then I opened the serial. When typing I get the same characters back. This is good since I wondered if maybe the problem was not being able to send information to the FONA.

Now I know the Tx GPIO of the Pi seems to work.

I know the Rx GPIO of the Pi works since when I hook up an Arduino to it, the characters from the Arduino print.

I know the FONA 3G Tx and Rx pins work because I can use them with the Arduino.

I still cannot get the FONA and the Pi to communicate.

Any suggestions of what to test next is appreciated.

lukeserial
Posts: 6
Joined: Mon Dec 04, 2017 12:25 am

Re: Can't get FONA 3G to respond to serial on Pi 3

Thu Dec 07, 2017 12:58 am

I realized that I had not fully tested whether the Pi could send serial commands.

To test this I used the following Arduino code.

Code: Select all

const int ledPin =13;
int n;

void setup() {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  n = 7;
}

void loop(){
  if(Serial.available()){
    n = Serial.read() - '0';
  }
  digitalWrite(ledPin, HIGH);
  delay(n*100);
  digitalWrite(ledPin,LOW);
  delay(n*100);
}
Then on the Pi I used the following Python code.

Code: Select all

import serial
arduinoSerialData = serial.Serial('dev/serial0', 9600)
arduinoSerialData.write(b'5')
Changing the write number in the Python code changes the blink rate of the Arduino led.

The Arduino is unpowered to avoid damage to the Pi. It is hooked up as follows.
Pi 3.3v --> Arduino 5v
Pi GND --> Arduino GND
Pi TX --> Arduino RX
Pi RX --> Arduino TX

This test worked fine and I can send commands from the Pi to the Arduino to change the blink rate.

What works
USB serial to / from Pi and Arduino
GPIO Rx / Tx serial to / from Pi and Arduino
FONA send and receive SMS with Arduino

What does not work
FONA respond to serial with PI

I ordered a serial to USB cable to test with the FONA as a last try. I do not know what I am missing.

Suggestions?

Return to “Troubleshooting”

Who is online

Users browsing this forum: dazz100 and 50 guests