Micropython script on Raspberry Pi Pico for AWS MQTT communication over a SIM7020E

Job ID: 37688228

Budget: £20 – £250 GBP

#### Abstract ####

We need a Raspberry Pi Pico W to be able to send and receive JSON encoded data to AWS via MQTT over the NB-IoT cellular network.

#### Progress ####

We are well down the road on this with everything working using the built in WiFi on the Pico. We are using AWS Shadow to keep device config sync'd and then normal pub/sub to and from AWS topics with "AWS IoT rules" setup to store incoming MQTT data on each topic to Dynamo DB.

This is all working perfectly utilising a mqtt_as.py script (see attached file mqtt_as.txt) and crucially, works in a "non blocking" way so other code can run whilst the script is listening for incoming MQTT messages to subscribed topics.

Our next step is to replace using the onboard WiFi and instead to do the comms over the mobile network, and we are using the SIM7020E NB-IoT Module (https://thepihut.com/products/sim7020e-nb-iot-module-for-raspberry-pi-pico?variant=40797269655747) to achieve this.

Again we are down the road on this but have hit a brick wall with our lack of experience in the raw AT commands that the sim module uses to communicate. We can successfully get the module to connect to the data network (via a 1NCE IoT sim card) and say that it's "OK" and working, but when we follow the documentation for making MQTT requests (especially with needing to send the various AWS security certificates, with line endings, and them needing to be chunked over multiple commands due to max char limitations etc) we get errors or can't get it to work.

#### Requirements ####

Lets start by saying the project will only be deemed successful if we can include and use your script as a replacement for the mqtt_as.txt script that we currently use over WiFi. And when using your replacement script, it connects to the mobile network via the SIM7020E NB-IoT Module, and manages this connection (with retries etc like the current script does for WiFi), and it can connect to AWS (again, like the existing script does where we pass it the certificates file data) and then, in a non-blocking way like the script, can subscribe to topics and publish to topics over the MQTT connection with AWS.

I have attached a code_snips.txt file which show bits of code for how we call the various functions (including reading the AWS certificates on the Pico) in the existing mqtt_as.txt script so you can see the expected behaviour of your new replacement script.

I have also attached the the latest docs we received for the the SIM7020E Module (you can obviously find / check these on the web) which details the various AT commands etc.

Also, to aid with testing on both your, and our side, I have also included an isolated testing micropython script (sim_mqtt_aws.txt) which we wrote, and is as far as we have got, just to try and get the initial connection and basic MQTT command to work but to no avail. So you may want to get this working first, and we can test / confirm it works our end, before completing the full replacement script.

Whilst we say "it will only be deemed a success (and therefore release payment) once we can replace the mqtt_as.txt script with your script, and everything work as it is now - we fully understand that this may need testing our end and some back and forth - especially as we can't release our full code, or exact AWS credentials, certificates etc for security reasons. So, we are more than happy to work with you and test things our end throughout, but what we mean is that we will only finalise the project and release payment once the script is fully complete and working as a drop in replacement for the mqtt_as.txt.

We expect this to be a fairly trivial task for someone with existing cellular / AT command knowledge, and experience with AWS and MQTT - especially as IoT devices have boomed over the last few years and AWS is a very popular platform for this. In fact, we can't believe that we are the first to be asking this, but after searching the web high and low, we cannot find any examples / scripts of this setup MQTT over cell / sim connection to AWS for micropython... and also speaking to Waveshare (suppliers to the Pi Hut) and even SIMCom directly (the manufactures of the module), they don't seem to have any example libraries / scripts etc other that the somewhat lacking examples in their documentation.

A couple of closing points, we expect the script to be well formatted and thoroughly commented (in English obviously), and this project, its communications / messages, the documents and files attached, and the resulting script documentation you provide, are all to be deemed confidential, private and will become our intellectual property, and not to be re-used, sold or given to anyone else. And finally, we will not make any adjustments to any AWS config to do with security or SSL etc as like I say, we know everything is currently working fine with the existing AWS setup, users, certificates etc over the built in WiFi on the Pico.

Happy to answer any questions (or provide any missing information you may need) BEFORE we select a successful candidate for this project, as once we accept someone, we expect this to only take a day or two to complete for someone with the right skills / experience.

Look forward to working with you on this,
Many thanks for your time,
Ben