Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Info
iconfalse
Excerpt

We detail how you can create a SmartMesh IP network manager out of a Raspberry PI and use ngrok to access its web interface from anywhere.






Table of Contents

Background

Your SmartMesh IP network is an essential piece of a low power, reliable, IoT solution. Once you’ve gotten to the point where you have proven all the great attributes of your SmartMesh IP network, you may want to integrate your project into a complete end-to-end IoT solution. A great deal of that end to end solution exists outside of your SmartMesh IP network and outside the parts you can buy from Linear Technology. There are infinitely many choices you can make there, and the vast array of choices might make it hard to figure out where to start. 

In this blog post, I’ll show you two different ways I’ve used to access my SmartMesh IP network over the Internet, from anywhere. These quick and easy methods to provide around-the-world connectivity to your SmartMesh IP network are not intended to be free turnkey solutions to what your product might look like. They are intended to be examples you can use to execute a demonstration, access a pilot network remotely, or do a proof-of-concept for your project.  

Option 1.  Using Weaved to access a Raspberry Pi that is connected to a SmartMesh IP network

My setup:

  1.  A new Raspberry Pi 2, running Raspbian
  2.  A SmartMesh IP starter kit (1 manager + 5 motes)

Step 1:  Plug in the Raspberry Pi and plug it into Ethernet

I have my Raspberry Pi plugged into the LAN in my office. I connected the HDMI output to a monitor so I can see the IP address it picked up from the DHCP server. It is possible to configure your Raspberry Pi to email you its IP address as soon as it boots up. That’s a really handy technique that I will possibly write up in another blog post. 

Step 2:  SSH into your Pi

I use PuTTY to start an SSH session to my Pi. The absolute first thing I do is change the password for the pi user from raspberry to something else.  It’s probably a good idea to assign a new hostname as well so you can tell multiple Pi’s apart. 

Step 3:  Get a free account on Weaved.com

Go to www.weaved.com, sign up for a free account.  Keep the browser open, because we’ll use that in a couple minutes.

Step 4:  Download and install Weaved to your pi.

In that SSH session window, type the command:

...

That’s it!  You now have the setup to allow you to connect to the linux shell of your Pi from anywhere in the world, anytime you like. 

Step 5:  Actually connecting from anywhere

Now, from any web browser anywhere, you can sign in to weaved and see your registered devices on a list.  You can request a connection which will open up a port for 30 minutes.  The site will give you a URL and port number that you can use from your SSH client to connect to your Pi. I use both the weaved.com website and the weaved iphone app to do this. With a free account, you can only stay connected for 30 minutes, but that is enough time to check on the network stats of your SmartMesh IP network or run some tests. It’s quite useful!

Option 2:  Using ngrok to port forward content from your Raspberry Pi to anywhere

One of the free example applications that Linear provides is DustLink. DustLink is a Python-based application that can connect to the SmartMesh IP manager and display information about that network as a webpage. Typically, you run DustLink on a computer that is connected to the SmartMesh IP manager, and you view the webpage on that same computer, pointing your browser to http://localhost:8080.  ngrok is another piece of free software that opens up sockets between computers. Now you can plug your manager into Raspberry Pi, and run DustLink on Raspberry Pi, and view that DustLink webpage from any browser anywhere in the world. 

My setup is exactly the same. I have a manager plugged into a USB port of my Raspberry Pi.

Step 1.  Plug in Pi into Ethernet and note its IP address

Step 2.  Download ngrok.zip from ngrok.com

Go to www.ngrok.com. This is an open source project and you pay what you want. There is no sign up, and no fees. Download the appropriate zip file to your PC. I used ngrok_2.0.19_linux_arm.zip.

Step 3.  Move ngrok.zip to your Pi.

I used WinSCP to move the zip file to my Pi.  The only installation is unzipping it with the command:

Code Block
unzip ngrok_2.0.19_linux_arm.zip

Step 4.  Get DustLink Running

If you already have DustLink installed on your pi, start it up. If not, follow the instructions on the earlier blog post getting DustLink running on your Pi. 

Step 5.  Generate an ngrok url

Dustlink is running on http://localhost:8080. To forward that to the outside world, use the command:

...