Reference
SIM7000
SIMCom SIM7000 LTE-M/NB-IoT/GSM modem — SMS (send, receipts, incoming commands), USSD and HTTP POST over GPRS, with retries and recovery.
- Connects over
- UART (serial)
- Made by
- SIMCom
- Datasheet
- simcom.com
Use it
hardware {
device sim7000: SIM7000
}
every 1s {
let value: bool = sim7000.ready()
log("sim7000", "ready={value}")
}
The SIM7000 talks over a UART. On its own the declaration gets a free serial port; to choose the pins, declare uart modem(tx: 17, rx: 16, baud: 9600) and write device sim7000: SIM7000 on modem.
Methods
-
sim7000.ready() -> bool
true if the modem answers AT
-
sim7000.registered() -> bool
true when registered (home or roaming)
-
sim7000.signal() -> int
Signal quality 0-31 (99 = unknown)
-
sim7000.send_sms(number: string, text: string) -> bool
Send an SMS with a delivery receipt requested; retries (2 s, 5 s) only if refused before sending, never when it may have gone out
-
sim7000.check_receipt() -> int
Delivery receipt for the last SMS: 1 delivered, 0 not yet, -1 failed
-
sim7000.http_post(url: string, form: string) -> int
HTTP POST a form body over GPRS with up to 3 attempts on failure or 5xx; returns the HTTP status or -1
-
sim7000.set_pwrkey(pin: int, active_high: bool)
Tell the driver which GPIO drives PWRKEY (K) and its polarity; enables power_cycle() and full recovery
-
sim7000.reset() -> bool
Soft restart (AT+CFUN=1,1), wait for it and re-apply settings
-
sim7000.power_cycle() -> bool
Hard restart via PWRKEY: switch off (if on), then on, then re-apply settings
-
sim7000.recover() -> bool
Soft reset if the modem answers, otherwise power-cycle
-
sim7000.maintain() -> int
Call periodically: returns network status and recovers the modem if it is silent or off-network for 3 minutes
-
sim7000.network_status() -> int
0 not searching, 1 home, 2 searching, 3 denied, 4 unknown, 5 roaming, -1 no answer
-
sim7000.signal_dbm() -> int
Signal strength in dBm (-113..-51), 0 if unknown
-
sim7000.operator_name() -> string
Network operator name (empty if unknown)
-
sim7000.voltage() -> int
Supply voltage at the modem in mV
-
sim7000.network_time() -> int
Network time as Unix seconds (UTC), 0 until the network sends it
-
sim7000.ussd(code: string) -> string
Send a USSD code (e.g. a balance check) and return the network's reply text; closes any menu it opens
-
sim7000.allow_number(number: string)
Whitelist a number in code (fixed: can't be removed by SMS); up to 6 numbers in total, matched on the last 9 digits
-
sim7000.next_sms() -> bool
Read the oldest stored SMS (then deleted from the SIM); false if none
-
sim7000.sms_from() -> string
Sender of the last SMS read by next_sms()
-
sim7000.sms_text() -> string
Text of the last SMS read by next_sms()
-
sim7000.sms_allowed() -> bool
true if the last SMS came from a whitelisted number
-
sim7000.sms_command() -> string
First word of the last SMS in upper case, only for whitelisted senders (else empty)
-
sim7000.sms_command_is(cmd: string) -> bool
true if the last SMS is a whitelisted command equal to cmd (case-insensitive)
-
sim7000.sms_arg_int() -> int
First number after the command word of the last SMS (e.g. SETID 7 → 7); -1 if none or sender not whitelisted
-
sim7000.sms_arg() -> string
Second word of the last whitelisted SMS (e.g. the number in SETNUM 0771234567)
-
sim7000.sms_arg_is(word: string) -> bool
true if the second word of the last whitelisted SMS equals word (case-insensitive), e.g. DOOR OFF
-
sim7000.load_alert_number(fallback: string)
Load the alert recipient saved in flash (or use fallback) and allow it to send commands
-
sim7000.alert_number() -> string
Current alert recipient
-
sim7000.set_alert_number_from_sms() -> bool
Save the number given in the last whitelisted SMS (SETNUM <number>) as the alert recipient
-
sim7000.load_whitelist()
Load numbers added by SMS (ALLOW) from flash; call once in setup
-
sim7000.whitelist_add_from_sms() -> int
ALLOW <number> from a whitelisted SMS: 1 added, 0 already allowed, -1 bad number, -2 list full
-
sim7000.whitelist_remove_from_sms() -> int
REMOVE <number>: 1 removed, 0 not on the list, -1 bad number, -2 fixed (admin or alert number)
-
sim7000.whitelist_text() -> string
The whitelist as SMS text, e.g. 'Allowed: 0776162283 (fixed), 0775438588'
Wiring
| Pin | Connect to |
|---|---|
V | Board supply (feeds the on-board regulator); needs a 2 A source |
G | Common ground with the MCU |
T | Modem TX → MCU RX (GPIO16 on ESP32) |
R | Modem RX ← MCU TX (GPIO17 on ESP32) |
K | PWRKEY (optional): pulse low ~1 s to switch the modem on/off |
Specifications
- Voltage
- 3.0-4.3V module supply (boards with a buck regulator take 5V+)
- Current
- up to ~2 A bursts when transmitting on GSM
- Baud
- 9600 or 115200 depending on the board (check with AT; some are fixed with AT+IPR)
- Networks
- LTE Cat-M1, NB-IoT, GSM/GPRS 900/1800
Tips
- If the network has no LTE-M/NB-IoT, the modem can wait minutes in automatic mode; this driver forces GSM-only (AT+CNMP=13).
- Laptop USB power is not enough when it transmits; use a 2 A supply.
- A straight ~8 cm wire on the LTE antenna pad's centre pin works for testing; use a proper antenna in an enclosure.
Alternatives worth knowing:
- SIM800L: 2G-only, cheaper; some boards ship with IMEIs networks reject.