Skip to content

Commit 4ed1978

Browse files
author
brentru
committed
fona send/read sms example
1 parent 47e6fa8 commit 4ed1978

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

examples/fona_sms.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import time
2+
import board
3+
import busio
4+
import digitalio
5+
from adafruit_fona.adafruit_fona import FONA
6+
7+
print("FONA SMS")
8+
9+
# Create a serial connection for the FONA connection
10+
uart = busio.UART(board.TX, board.RX)
11+
rst = digitalio.DigitalInOut(board.D4)
12+
13+
# Initialize FONA module (this may take a few seconds)
14+
fona = FONA(uart, rst, debug=False)
15+
16+
# Initialize Network
17+
while fona.network_status != 1:
18+
print("Connecting to network...")
19+
time.sleep(1)
20+
print("Connected to network!")
21+
print("RSSI: %ddB"%fona.rssi)
22+
23+
# Text a number
24+
if not fona.send_sms(140404, "HELP"):
25+
raise RuntimeError("FONA did not successfully send SMS")
26+
27+
# Ask the FONA how many SMS message it has
28+
num_sms = fona.num_sms
29+
print("%d SMS's on SIM Card"%num_sms)
30+
31+
# Read out all the SMS messages on the FONA's SIM
32+
for slot in range(1, num_sms):
33+
print(fona.read_sms(slot))

0 commit comments

Comments
 (0)