Using the GPy from Pycom.io to POST data to a REST API (in this case a Django REST Framework
- Using a Hologram.io SIM
- Currently using post_json_data project
- reports uptime and GPS every hour using GPy and Pytack v2.
- 29-Mar-2022: added option to add Adafruit's bme680 shield to GPy and Pytrack v2, using a breadboard an the SPI interface. Many thanks to robert-hh/BME680-Micropython
- Upgrade Pytrack 2 firmware as described at this link
- Upgrade GPy as described at this link, for USB
sudo usermod -a -G dialout $USER
and reboot- Download and install Atom and install Pymakr plugin
- attach Gpy to Pytrack v2. Connect Pytrack v2 with USB and REPL should be available in Atom
- Example:
>>> import sqnsupgrade as ssqn >>> ssqn.info() <<< Welcome to the SQN3330 firmware updater [1.2.6] >>> >>> GPy with firmware version 1.20.2.r2 Your modem is in application mode. Here is the current version: UE5.4.0.2 LR5.4.1.0-50523 IMEI: xxxxx
- Currently no firmware upgrade is needed as described here
- If a firmware upgrade is required, then probably do
sudo apt install python3-serial
and follow link's instructions
- Pycom documentation
- The pyboard.py tool
- Useful debugging: see Readme_debugging.md
See sample_private_vars.py
for an example. Used for private (secret) variables. Create
a file, `lib/private_vars.py' and use as follows:
import private_vars
server = private_vars.HOST
Sometimes Atom and the Pymakr plugin do not always work, e.g. failed to upload. Resolve these type of issues after downloading [pyboard.py](./pyboard.py simple_files/get_https/main.py) and using the virtual environment (see Pipfile). Some examples are below.
#Cleaning up
./pyboard.py --no-soft-reset -f rm :main.py
rm :main.py
./pyboard.py --no-soft-reset -f ls :
ls :
29 boot.py
0 cert/
0 lib/
34 main.py
0 sys/
#Default main.py
./pyboard.py -f cat :main.py
cat :main.py
# main.py -- put your code here!
#Run this script in memory
./pyboard.py simple_files/hello_world/main.py
Hello!
Hello!
#Run this project in memory after loading libraries
./pyboard.py -f cp projects/hello_world/lib/helper_functions.py :lib/
cp projects/hello_world/lib/helper_functions.py :lib/helper_functions.py
./pyboard.py -f cat :lib/helper_functions.py
cat :lib/helper_functions.py
import private_vars
def hello_world():
return '{}'.format(private_vars.msg)
./pyboard.py projects/hello_world/main.py
Starting "Hello World Project"
msg: Goodnight Moon!
msg: Goodnight Moon!
msg: Goodnight Moon!
#Another example of testing a script before uploading it
./pyboard.py simple_files/get_https/main.py
In addition to the pyboard.py
tool (above), one can enter the REPL with a serial connection
For example:
screen /dev/ttyACM0 115200
#or,
screen /dev/ttyACM0 115200 -hupc
#Or, starting with pyboard
./pyboard.py --no-exclusive simple_files/hello_world/main.py
#then, Ctrl-C, exiting, and then to follow the output
screen /dev/ttyACM0 115200 -hupc
#and to drop to a python prompt: Ctrl-C Ctrl-B
>>>
>>> help()
#Note: Ctrl-F will dump everything and restart the program, the Ctrl-C
#https://fvdm.com/code/howto-write-screen-output-to-a-log-file
screen -dmS test -L /dev/ttyACM0 115200
screen -S test -X colon "logfile flush 0^M"
tail -Fn 0 screenlog.0
#or reattach to screen
screen -r test