New Tutorial! Build an IoT device with Super SIM and the Raspberry Pi Pico

tsmith
tsmith mod
edited August 31 in Super SIM

Just posted: a new guide to plugging a Raspberry Pi Pico-based IoT device — a Waveshare Pico SIM7080G Cat-M/NB-IoT cellular add-on board and Super SIM provide the connectivity — into the Internet.

It includes:

  • A full application built in MicroPython.
  • An MCP9808 temperature sensor as a data source.
  • An HT16K33-based four-digit, seven-segment LED for visual output.
  • Over-the-air device control and reporting via Super SIM SMS Commands.

Check it out over in the Twiio docs.

Comments

  • Update FYI, all, I’ve done a little refactoring on the code, and clarified a couple of points about what portions of additional code need to be added.

  • Here’s a little extra: some replacement code for the temperature reading function, process_command_tmp(). In addition to sending off an SMS with the data, the code below also displays the current celsius temperature reading on the LED (including the unit symbol):

    def process_command_tmp():
        print("Sending a temperature reading")
        celsius_temp = "{:.2f}".format(sensor.read_temp())
        if send_at("AT+CMGS=\"000\"", ">"):
            # '>' is the prompt sent by the modem to signal that
            # it's waiting to receive the message text.
            # 'chr(26)' is the code for ctrl-z, which the modem
            # uses as an end-of-message marker
            r = send_at_get_resp(celsius_temp + chr(26))
        # Display the temperature on the LED
        digit = 0
        previous_char = ""
        for temp_char in celsius_temp:
            if temp_char == "." and 0 < digit < 3:
                # Set the decimal point -- but only if we're not
                # at the last digit to be shown
                display.set_character(previous_char, digit - 1, True)
            else:
                # Set the current digit (a minus sign or a number)
                display.set_character(temp_char, digit)
                previous_char = temp_char
                digit += 1
            if digit == 3: break
        # Add a final 'c' and update the display
        display.set_character("c", 3).update()
    

    If you prefer a capital C for Celsius, change the last line to:

    display.set_glyph(0x39, 3).update()
    

    The comments in the main code will show where the 0x39 comes from.