Issues with the FONA Library

Adafruit cellular platform - SMS and IoT over celluar

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
strau0106
 
Posts: 3
Joined: Thu Dec 08, 2022 8:33 am

Issues with the FONA Library

Post by strau0106 »

Heyho!
I bought a SIM5320E module (aka. the FONA3G) from adafruit and wanted to start using it. However, when trying to test the fona with the sketch from here: https://learn.adafruit.com/cellular-dat ... -with-fona
The exact sketch I am running:

Code: Select all

# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT

# pylint: disable=unused-import
import time
import board
import busio
import digitalio
import adafruit_requests as requests
from adafruit_fona.adafruit_fona import FONA
from adafruit_fona.fona_3g import FONA3G
import adafruit_fona.adafruit_fona_network as network
import adafruit_fona.adafruit_fona_socket as cellular_socket

print("FONA Webclient Test")

TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
JSON_URL = "http://api.coindesk.com/v1/bpi/currentprice/USD.json"

# Get GPRS details and more from a secrets.py file
try:
    from secrets import secrets
except ImportError:
    print("GPRS secrets are kept in secrets.py, please add them there!")
    raise

# Create a serial connection for the FONA connection
uart = busio.UART(board.TX, board.RX)
rst = digitalio.DigitalInOut(board.D2)


fona = FONA3G(uart, rst)

# Initialize cellular data network
network = network.CELLULAR(
    fona, (secrets["apn"], secrets["apn_username"], secrets["apn_password"])
)

while not network.is_attached:
    print("Attaching to network...")
    time.sleep(0.5)
print("Attached!")

while not network.is_connected:
    print("Connecting to network...")
    network.connect()
    time.sleep(0.5)
print("Network Connected!")

print("My IP address is:", fona.local_ip)
print("IP lookup adafruit.com: %s" % fona.get_host_by_name("adafruit.com"))

# Initialize a requests object with a socket and cellular interface
requests.set_socket(cellular_socket, fona)

# fona._debug = True
print("Fetching text from", TEXT_URL)
r = requests.get(TEXT_URL)
print("-" * 40)
print(r.text)
print("-" * 40)
r.close()

print()
print("Fetching json from", JSON_URL)
r = requests.get(JSON_URL)
print("-" * 40)
print(r.json())
print("-" * 40)
r.close()

print("Done!")
I was unable to get it started. I kept getting this error:

Code: Select all

main.py output:
FONA Webclient Test
Traceback (most recent call last):
  File "main.py", line 32, in <module>
  File "adafruit_fona/fona_3g.py", line 61, in __init__
  File "adafruit_fona/adafruit_fona.py", line 100, in __init__
RuntimeError: Unable to find FONA. Please check connections.
So I tried to directly send AT commands with the following sketch:

Code: Select all

import board
import busio
uart_passthrough = busio.UART(board.TX, board.RX, baudrate=115200, timeout=0.1)

uart_passthrough.write(b'AT+CSQ\r')

while True:
    if uart_passthrough.in_waiting:
        print(uart_passthrough.read())
 
Which reports back to me:

Code: Select all

b'AT+CCID\r\r\n+CCID: "<SIMID> (removed for privacy reasons)"\r\n\r\nOK\r\n'
Which leaves me puzzeld because it is infact not a problem with the wiring, but with the library?

Thanks!

Best,
Rufus

User avatar
strau0106
 
Posts: 3
Joined: Thu Dec 08, 2022 8:33 am

Re: Issues with the FONA Library

Post by strau0106 »

I had additional time to test a bit and. I set the debug param in the FONA3G initializer to true and after a bit of output, sadly I don't have it anymore and I'm not able to test right now, it crashed with a Unicode Error instead of the FONA not found error. Changing the FONA3G to just FONA then returns that FONA 808 v1 is not implemented in this library.

I hope this helps further determine the issue. I will post exact outputs and inputs as soon as I have access to the hardware again.

User avatar
strau0106
 
Posts: 3
Joined: Thu Dec 08, 2022 8:33 am

Re: Issues with the FONA Library

Post by strau0106 »

I now have found the issue. The FONA library overrides the baudrate of the FONA connection to 4800 baud. Removing that line and thus having 115200 baud the module works nicely... I will create an issue on the github repo.

Locked
Please be positive and constructive with your questions and comments.

Return to “FONA”