Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
139 lines (126 sloc) 6.5 KB

Prerequisites

  • A Pycom Development Board
  • A Pycom Expansion Board or Shield
  • Wifi Access to the Internet
  • An account at Ubirch Web UI

Prepare Local Environment

  1. Download and install Atom Editor (download)
  2. Start Atom Editor
  3. Click on Install a Package in the menu on the right
    • Enter pymakr in the search field
    • Install pymakr package
  4. Connect Pycom Device via USB
    • watch pymakr console window in Atom to see if it worked (should show up automatically on the bottom of the Atom window)
  5. CLOSE Atom Editor or DISCONNECT the Pycom Device

Flash Pycom Devices

  1. Download Pycom Upgrader (download)
  2. Download UBIRCH Pycom Firmware (download)
    • select the correct firmware for your Pycom device (WiPy, Lopy4, GPy, ...)
  3. Run Pycom Upgrader and Flash Firmware
    • On the third screen named COMMUNICATIONselect the right serial port / COM port and check the flash from local file checkbox
    • select file downloaded in step 2 and continue the process
    • wait until flash process finished successfully

Configure Pycom Device

  1. Re-start Atom Editor or re-connect device

  2. Download example firmware code

    • Click menu View >> Toggle Command Palette
    • Enter git clone and press return
    • Paste https://github.com/ubirch/example-micropython to the Clone from field and clone it
    • A new project with the project tree at the right of Atom should open automatically
  3. Press the UPLOAD button just above the pymakr console window in Atom

  4. Wait for all files to upload. The code will start running on your device and you will see a ** UUID : XXXX output

  5. copy the UUID

Register Device in Ubirch Web UI

  1. Go to https://console.demo.ubirch.com and register your device:

    • Once logged in, go to Things (in the menu on the left) and click on ADD NEW DEVICE
    • paste the the UUID copied in the last step of the previous chapter to the hwDeviceId field
    • click create
  2. Next, click on your device and copy the apiConfig

  3. Create a file config.json in the src directory of the project tree and paste the apiConfig into it.

  4. Add configuration for WIFI connection and the expansion board you are using.

    It should then look like this:

    {
      "networks": {
        "<WIFI SSID>": "<WIFI PASSWORD>"
      },
      "type": "<BOARD TYPE>",
      "password": "<password for ubirch auth and data service>",
      "keyService": "<URL of key registration service>",
      "niomon": "<URL of authentication service>",
      "data": "<URL of data service>"
    }
    • Replace <WIFI SSID> with the name of your wifi network
    • Replace <WIFI PASSWORD> with the password to your wifi network
    • Replace <BOARD TYPE> with the expansion board type you are using (pysense or pytrack)
  5. Press the UPLOAD button again and you're good to go.

On initial start, the Pycom will generate an ed25519 key pair for the device and register the public key at the Ubirch key service. After that, it will frequently measure the following data...

  • pysense:
            {
                "AccPitch": "<accelerator Pitch in [deg]>",
                "AccRoll": "<accelerator Roll in [deg]>",
                "AccX": "<acceleration on x-axis in [G]>",
                "AccY": "<acceleration on y-axis in [G]>",
                "AccZ": "<acceleration on z-axis in [G]>",
                "H": "<relative humidity in [%RH]>",
                "L_blue": "<ambient light levels (violet-blue wavelength) in [lux]>",
                "L_red": "<ambient light levels (red wavelength) in [lux]>",
                "P": "<atmospheric pressure in [Pa]>",
                "T": "<external temperature in [°C]>",
                "V": "<supply voltage in [V]>",
            }
  • pytrack:
            {
                "AccPitch": "<accelerator Pitch in [deg]>",
                "AccRoll": "<accelerator Roll in [deg]>",
                "AccX": "<acceleration on x-axis in [G]>",
                "AccY": "<acceleration on y-axis in [G]>",
                "AccZ": "<acceleration on z-axis in [G]>",
                "GPS_lat": "<longitude in [deg]>",
                "GPS_long": "<latitude in [deg]>",
                "V": "<supply voltage in [V]>",
            }

...and send it to the Ubirch data service. Further, it packs the sha512 hash of the data into a chained UPP (Ubirch Protocol Package) which is the certificate of the data's authenticity, and sends it to the Ubirch public blockchain based authentication and timestamping service.

Visualize the data

  1. Go to https://grafana.dev.ubirch.com/?orgId=1
  2. Login with your Ubirch Web UI account
  3. Create a new dashboard and go to Add Query
  4. Select Elasticsearch in the drop-down menu
  5. Configure your query and make sure your device is still running
  6. Enjoy the data coming in from your device

(Optional - for experts) Check Blockchain Anchoring [DRAFT]

  1. While the Pycom is connected and running, and Atom is open, check the pymakr console in Atom and wait for a hash of a measurement certificate to appear, e.g.:

    ** sending measurement certificate ...
    hash: nU3Q1JbJ/q/U0nxbremiIbHtKwaHSD9N9qPHeSr0sXTh3ZaVLyTioZZ3wfiQL0gFONIpGQGKgcr0RyLj4gGO1w==
    

    Copy the hash.

  2. Send a POST request to the UBIRCH verification service, e.g. by using curl (or any other tool to send POST requests):

    curl -s -X POST -H "accept: application/json" -H "Content-Type: text/plain" -d "$HASH" "$URL"
    
  3. The response will list all blockchain anchors containing this measurement certificate. The txid (Blockchain Transaction ID) of each anchors entry can be used to lookup the entry in the according blockchain explorer (consider the blockchain and network_type attribute to find the right explorer)

You can’t perform that action at this time.