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!")
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.
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())
Code: Select all
b'AT+CCID\r\r\n+CCID: "<SIMID> (removed for privacy reasons)"\r\n\r\nOK\r\n'
Thanks!
Best,
Rufus