We have a mobile broadband modem at home with a 4G sim card which works perfectly. We have a stable connection of 25 megabit down speed which is good enough for the family. But once in a while the modem looses it’s connection to the Internet. When it does, we need to walk up the stairs, unplug it, and the replug it.
But not any more! With my new home automation setup I have solved this so that the modem reboots itself, one minute after it looses it’s connection. Read on to see how I did it.
Tell-what, Rasp-what, Open-what?
OK, gramp, this section is for you. Those of of you who already knows what I’m talking about can skip ahead to the next section.
Raspberry Pi is a small computer that is really cheap yet quite powerful. Among other things it can run a couple of versions of an operating system called Linux. Linux is just like Windows, but you need to be a geek to understand how to use it. In return, you may configure the system all the way through. Besides, Linux is free. As my good friend David put it: Linux is for those who have no money but an infinite amount of time.
Raspberry Pi can be bought for around 40€, and you can use it as a media center, game station or surf station. Basically anything a slow computer can do, the Raspberry will do better.
Tellstick is a product that is manufactured by the Swedish company Telldus. It is a small transponder that transfers data over the 433 MHz band. That is the frequency that most of the remote controlled wall sockets uses. You can buy a remote control for almost anything today. The most common is a wall socket that you may control from your sofa. There are also door bells, termometers, weather stations and so on that operates on the 433 MHz band. With Tellstick you can send and receive information to and from those frequencies. With other words, you can turn your lamp on or off with your computer.
I bought a Tellstick Duo which connects to the Raspberry Pi through the USB Port.
OpenNetHome is an open source software through witch you can control your Tellstick. You tell the program which units you have installed in your home and the program gives you buttons to control them throuch a web interface, a web page.
I think Telldus has their own software to do this. What’s nice with OpenNetHome is that it has a Rest-API so that you can order it to do things over the internet. You send an online request to turn the lamp on or off, without using that web page I mentioned. More specifically – you may use your own program to do this.
End of explanation.
Tellstick Duo, Raspberry Pi
The first thing I did was to install the Linux operating system Ubuntu Mate on my Raspberry Pi. I used the installation description by Ubuntu Mate.
When that was done, I hade to activate SSH on my Raspberry Pi before the next step. Follow this description.
After that I could install OpenNetHome by the description on their homepage. I also followed the description of how to add the Tellstick and the remote wall socket connected to my router. When all this was done I had the following layout on my personal OpenNetHome page.
When the hardware was all set up it, I started with the software. I installed the development environment Mono on my Raspberry Pi. With Mono you can write C# code on Linux. C# is my backyard, that’s why I chose this solution. Other environments are also available to do the same thing.
I actually intended to use dotnet core first, but I couldn’t set it up during the short time I invested in it. Mono was easy to install. You entered the command prompt on the Raspberry Pi and wrote:
sudo apt-get install mono-runtime
sudo apt-get install monodevelop
Then I could start Mono through the Ubuntu meny, under Programming.
In Mono I created a new project and wrote a small program that does what I want it to do. Then I opened up the Ubuntu Mate Control Center, and under Autostart I added my program so it will run automatically every time I start up my Raspberry Pi. Note that the Mono executable file needs to be started through Mono.
And there we are! Now I have a watchdog that keeps my network running after just 1 minute down time!
Here is my code, feel free to use it as much as you want. I’ve disguised it as a .js-file so that WordPress will allow you to see it.