- SIM868L.py: a pure-MicroPython driver for the SIM868 GPRS module with both HTTP(S) GET and POST support. Works out of the box on the RP2040-SIM868.
Example usage of HTTP is in the example_SIM868.py script, just set the APN and change the pins if needed, then run the "example_usage" function.
Example usage of GPS is in the gps_example.py script, run the "example_usage" function.
Example usage of SMS is in the sms_example.py script, run the "example_usage" function.
- Tutorial on getting started with the RP2040 and MicroPython from Install Thonny to Blink the onboard LED is the most relavant.
- Save/upload the SIM868.py file to the RP2040-SIM868.
- Save/upload one of the example file or create your own script.
This is a modified fork from Pythings SIM800L HAL Driver. There driver significantly speeded up development of RP2040-SIM868 HAL driver.
Modem(uart=None, MODEM_PWKEY_PIN=None, MODEM_RST_PIN=None, MODEM_POWER_ON_PIN=None, MODEM_TX_PIN=None, MODEM_RX_PIN=None)
Initialize a class of Modem.
- uart: Hardware uart number to use
- MODEM_PWKEY_PIN: Pin that the power key is attaced too. N/A for the RP2040-SIM868.
- MODEM_RST_PIN: Pin that the Reset on the SIM868 is attached too. N/A for the RP2040-SIM868.
- MODEM_POWER_ON_PIN: Pin that the Power on/off is attached too on the SIM868. PIN 3 on the RP2040-SIM868.
- MODEM_TX_PIN: Pin that the TX on the SIM868 is attached too. PIN 5 on the RP2040-SIM868.
- MODEM_TX_PIN: Pin that the RX on the SIM868 is attached too. PIN 4 on the RP2040-SIM868.
Modem.initialize()
Power on the modem and initialize the uart driver.
Modem.connect( apn, user='', pwd='')
Connect to the GPRS network.
Set the APN to internet
with no username or password. Otherwise please contact your service provider to get these settings.
- apn: Set SIM868 APN.
- user: SIM868 APN USERNAME.
- pwd: SIM868 APN PASSWORD.
Modem.disconnect()
Disconnect from the GPRS network.
Modem.http_request(url, mode='GET', data=None, content_type='application/json')
Send a HTTP request via the GPRS network.
Only support for GET and POST method at this time.
- url: URL to send the HTTP Request too.
- mode: HTTP method to use.
- data: Data to be sent on the network via HTTP.
- content_type: Set the HTTP content type header.
HTTP Response.
Modem.gps_on()
Turn on the GPS.
Modem.gps_off()
Turn off the GPS.
Modem.gps_read()
Request GPS data from the SIM868.
GPS data as a dictionary.
Modem.send_sms(number=None,msg='')
Send a SMS message. (untested)
The number must lead with you international code eg. +27xxxxxxxxx
- number: Number to send the SMS too.
- msg: SMS message.
Modem.get_info()
Get information about the modem
Modem information.
Modem.battery_status()
Modem.scan_networks()
Modem.get_current_network()
Modem.get_signal_strength()
Modem.get_ip_addr()
Modem.get_ip_addr()