RAK8212: Create a Digital Twin in AWS IoT

Posted on
  • Please check my recent blog post for a step-by-step explanation how the RAK8212 can be used for prototyping IoT use cases - using the "Digital Twin" representation in AWS IoT Core

    https://wolfgangklenk.wordpress.com/2019­/04/06/espruino-on-rak8212-create-a-digi­tal-twin-in-aws-iot/

    Unfortunately, this article is too big to fit into this forum conversation, so you can start reading here, but have to go to my wordpress blog article to read the full story.

    You need a fast, simple and inexpensive way to prototype your IoT use cases?

    This article describes how you can achieve this using

    • The RAK8212 device with its built-in Quectel BG96 communication module
    • Espruino: A JavaScript interpreter for microcontrollers
    • Narrowband IoT (NB-IoT): A Low Power Wide Area Network (LPWAN) radio technology standard
    • AWS IoT Core and Device Shadow Service ("Digital Twin")


    In this example, the RAK8212 device is used as a sensor that periodically sends temperature values to its digital twin in AWS IoT Core. For communication with AWS it uses the MQTT protocol over Narrowband IoT (NB-Iot). The state of a LED on the RAK8212 can be controlled by setting it on the digital twin in AWS IoT.

    ##Setting up the "thing" in AWS Iot Core
    Get yourself an account on AWS, navigate to “AWS IoT” and “Create a single thing”. Describing all the steps would go too far in this article, and AWS has good online documentation. So please follow the steps given in the AWS documentation.

    In the end, you should have an IoT object (=thing), identified by a name, and a certificate for this object (e.g. 133c075337.cert.pem), a public key (e.g. 133c075337.public.key) and a private key (e.g. 133c075337.private.key). You need to download these three files and activate the certificate.

    In the navigation menu of the AWS console, go to “Manage -> Things” and you will see all your things. Select the thing of your choice and, in the navigation menu of the thing, go to “interact”. Note the server address displayed as “Update your Thing Shadow using this Rest API Endpoint”. We will use this as the address of the MQTT server later.

    Example Address: a136ivuau4uklv-ats.iot.eu-central-1.amaz­onaws.com

    Also notice the MQTT topics below. They all contain the name of your thing:

    Example MQTT Topic: $aws/things/klenk-iot-device/shadow/upda­te

    This shows that the name of my thing is “klenk-iot-device”.

    ##Setting up the example code for RAK8212
    The example code is hosted at github:

    https://github.com/wklenk/rak8212-esprui­no-nb-iot/blob/master/data-logger-bg96-m­qtt.js

    Find the JavaScript object that holds the configuration for the NB-IoT radio network connection, e.g.

    // NB1 connectivity settings for Vodafone Germany
    
var connection_options = {
  
      band: "B20",
  
      apn: "vgesace.nb.iot",
  
      operator: "26202",
    
  debug: false // Print communication with BG96 module to console.
    
};
    

    Adapt this to fit to your NB-IoT network of choice.

    Find the JavaScript object that holds the configuration for the MQTT connection to AWS IoT:

    var mqtt_options = {

      // AWS IoT

      server: 'a136ivuau4uklv-ats.iot.eu-central-1.ama­zonaws.com',
    
  port: 8883,
    
  client_id: "klenk-iot-device"
    
};
    

    Adapt the MQTT server (same as address of API endpoint noted down above) and client_id (name of the thing).

    Please go on reading at https://wolfgangklenk.wordpress.com/2019­/04/06/espruino-on-rak8212-create-a-digi­tal-twin-in-aws-iot/

  • Nice - thanks for posting!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

RAK8212: Create a Digital Twin in AWS IoT

Posted by Avatar for wklenk @wklenk

Actions