Warning: this post refers to this specific code commit: https://github.com/pythings/Drivers/tre ... 90745504a9, since the driver is evolving if you just browse the repo at the latest version things won't match (but are similar).
When you flash MicroPython, you get a) a MicroPython interpreter and b) a filesystem (unless in some special cases where there is not enough flash memory, i.e. on the ESP01 with 512 Kb since 1 MB is required for the filesystem to work).
Let's take for granted that you have a+b. At this point you can connect with a serial console and use tools like ampy (
https://github.com/scientifichackers/ampy) which make it easy to list, put and get files. MicroPython creates by default an empty-ish file named boot.py which gets executed at every boot.
Example serial console interaction:
Example ampy output after a fresh MicroPython Install on esp32:
Code: Select all
$ ampy -p /dev/cu.SLAB_USBtoUART ls
/boot.py
You can then change the pins on which the SIM800L is connected at line 412 and the APN at line 428 of SIM800L.py (with respect to commit 865216c on the repo I linked) and put the driver on the board. Note that you need to manually change the pins and the the APN in the driver code only to make the "example_usage" function to work, when you use the driver in the "proper" way, which is to instantiate a Modem class from your scripts, the pins and the APN are parametrised (as you can see from the "example_usage" function at line 403 itself)
Code: Select all
$ ampy -p /dev/cu.SLAB_USBtoUART put SIM800L.py
$ ampy -p /dev/cu.SLAB_USBtoUART ls
/SIM800L.py
/boot.py
and now, two options:
1) Connect via a serial console to your board (I assume you are familiar with this, if not it is the first thing you need to get used to after flashing the firmware) and try/test the module/driver from there. Example:
Code: Select all
>>> import SIM800L
>>> SIM800L.example_usage()
Starting up...
Modem IP address: "191.219.151.34"
Now running demo http GET...
Response status code: 200
Response content: <html><head><title>Current IP Check</title></head><body>Current IP Address:
191.219.151.34</body></html>
Now running demo https POST...
Response status code: 200
Response content: {"args":{},"data":{"myparameter":42},"files":{},"form":{},"headers":{"x-forwarded-proto":
"https","host":"postman-echo.com","content-length":"19","accept":"*/*","content-type":"application/json",
"user-agent":"SIMCOM_MODULE","x-forwarded-port":"443"},"json":{"myparameter":42},"url":"https://postman
-echo.com/post"}
>>>
2) Edit the boot.py, or create your own scripts to be imported from boot.py, and use this driver from there, so that when the board powers on your application logic gets automatically executed. The most simple thing you can do is to copy-paste the "example_usage" function code in the boot.py script (and add a "from SIM800L import Modem" at the top), then from there should be simple to evolve the code according to your needs
There is more than this of course, for example you can bake (or "freeze") python modules as this one in the MicroPython firmware at firmare built-time to have them both ready and to use way less memory (not flash, memory), but if you are a newcomer you really don't want to start with this as the build chain is quite complex to setup.
Warning: this post refers to this specific code commit: https://github.com/pythings/Drivers/tre ... 90745504a9, since the driver is evolving if you just browse the repo at the latest version things won't match (but are similar).