This class provides a driver for the Cellular modem in the XBee.
import network import time cellular = network.Cellular() while not cellular.isconnected(): time.sleep_ms(50) print(cellular.ifconfig()) # now use socket as usual ...
You can use the constructor to create an XBee Cellular object.
You can use these method options in the XBee Cellular configuration.
Cellular power and airplane mode
This method determines whether the XBee Cellular Modem is powered on or in airplane mode.
- Returns True if the XBee Cellular Modem is powered on.
- Returns False if the XBee Cellular Modem is in airplane mode.
- False: XBee Cellular Modem enters airplane mode.
- True: XBee Cellular Modem leaves airplane mode.
Note No changes to the XBee Cellular Modem are made if the parameter matches the current mode.
Verify cellular network connection
This method determines whether the XBee Cellular Modem is connected to a network.
- True: The XBee Cellular Modem is connected to a cellular network and has a valid IP address.
- False: Neither condition required to return True is met.
Cellular connection configuration
The cellular.ifconfig() method reports on settings that describes the cellular network connection. The values are only present once known.
- iccid: The SIM card's ICCID (Integrated Circuit Card Identifier).
- imei: The XBee Cellular Modem's IMEI (International Mobile Equipment Identity).
- operator: The network operator on which the module is registered.
- phone: The SIM card's phone number, starting with the plus sign (+) and the country code.
For additional information about network configuration, please refer to the MicroPython network configuration documentation.
Send an SMS message
This method sends a message to a phone using SMS (Short Message Service).
- phone: The phone number of the device to which the message should be sent. This variable can be a string or an integer.
- message: The contents of the message. The message should be a string or a bytearray of 7-bit ASCII characters.
Possible return values:
- None: The cellular network acknowledges receipt of the message. The method throws a "ValueError" for invalid parameters.
Throws an "OSError" exception:
- ENOTCONN: The cellular mode hasn't connected.
- ETIMEDOUT: If the network doesn't acknowledge the message in a reasonable amount of time.
- EIO: If there was some other error in sending the messages.
Receive an SMS message
This method returns information about a sent SMS message. Possible return values include None or a dictionary key.
- None: A message isn't waiting.
- timestamp: The time the SMS message was received. The timestamp displays as a number of seconds since 1/1/2000. For more information, see the related MicroPython documentation about the utime module: http://docs.micropython.org/en/latest/pyboard/library/utime.html
- sender: The phone number of the sender.
- message: The contents of the SMS that was received.