Sunday, October 09, 2022

Re-purpose your $30 Pocket-Router as an AWS-IoT-Edge-Device

 


This blog is about upgrading default firmware of GL.iNet-MT300N-V2 pocket router with a custom built  Openwrt-Linux Image which includes a AWS-IoT-Device-SDK and aws-iot-pubsub-demo application.

With this demo image, you can turn your low cost Gl.iNet-MT300N-V2 pocket router into an AWS-IoT-Edge device which can feed local sensor data to the AWS-Cloud and it opens up many interesting use cases for developing various IoT applications.

As an average user, here are 3 easy steps which can turn your low cost pocket router into an AWS-IoT -Edge-Device,
  1. Overwrite OEM firmware with custom gl-mt300nv2-awsiot-demo.bin
  2. Using webUI, upload AWS-Cloud generated Device-certificate/Private-Key and set the Endpoint.
  3. Reboot the device and watch Hello-World messages being published to your Aws-IoT-Core.

Step-1: Prepare the Setup as shown in this picture below and Power-ON(wait for LED to stop blinking)



Step-2: On your Browser PC, open URL: http://192.168.8.1/cgi-bin/luci/admin/system/flashops (or you may be guided through a different onboarding process of GL.iNet's webUI)

Step-3: Find the sw upgrade menu on the webUI and upgrade the OEM sw with gl-mt300nv2-awsiot-demo.bin (make sure to disable "keep-settings" menu - we want to start with default settings)

Step-4: Wait for about 2minutes(till LED's on pocket router stops blinking)

Step-5: On you PC, Remove the network cable and re-plug so that your PC gets new IP starting with 192.168.20.x

Step-6: On your Browser PC, change the ULR to http://192.168.20.1 and you shall see the following:



Step-7:  In this step - we will be uploading device-certificate and private-key files (note: My web programming skills are really poor, you will notice, file upload actions do not have an action completion message - just ignore this till it is fixed and implemented in a clean way)



Step-8: Click on AWS-IoT==>Service Settings menu, you shall see the following page - enter your endpoint and click "Save & Apply"(before clicking Save & Apply, ensure that your security policies on console.aws.amazon.com are setup correctly as shown in step-10 below)




Step-9: Check Log : If everything goes well, you shall see a "connection success" message in the Service Log as shown below)

Step-10: open console.aws.amazon.com and ensure that following security policies are set correctly as shown here in this picture


Step-11: As shown in the picture below, On console.aws.amazon.com, subscribe to a topic(test/topic) to see Hello world!  Messages published from your pocket router when Save & Apply button was clicked in step-8 above, as per default settings, aws-iot-pubsub-demo program would just publish 10 messages with an interval of 5seconds and then messages would stop publishing. To see the messages regularly for a longer period, increase the Publish Count to a higher value in Service Settings page of the pocket router.



Step-12: To see the subscribe action on the pocket router, you can publish a json message to test/topic_led from your console.aws.amzaon.com and see the router LED turning ON or OFF as per published json value : {"powerstate" : "on"} or {"powerstate" : "off"}


Other use cases of aws-iot-pubsub-demo agent: This pocket router can be extended to act as a gateway between AWS-IoT-Core and local wifi or USB connected devices to this pocket router, Following are some of the use-cases:



If you have other ideas, do let me know in comments sections on how you would like to extend its functionality.

For those who wants to Fix/Modify/Extend this router's functionality, here are the sources and build instructions available on my github repository

1 comment:

lovelanguagetest said...

program included in this image, mirrors a gpio-input to an output and the phase difference between these two love language quiz signals gives an idea on how fast scheduler is able to give the required context to your application and the jitter(when measured with persist mode of the scope) on the output signal indicates the best and worst case scenario of the scheduler latency. Following picture shows best and worst case latency of the scheduler when subjected to different load on the hw(e.g network-