Tuesday, January 01, 2019

20$ Pocket router as Domoticz Home Automation Gateway


TLDR; I built a openwrt based custom firmware(autom8box), that packs router_functionality+domoticz_server+mqtt_broker which is all-in-one home-automation-gateway-solution running on a cheap $20 router that can be purchased off-the-shelf. 

Wifi based home automation products are cheaper compared to zigbee or z-wave products, but the downside is, wifi devices need internet connection to perform their function. Letting your home devices controlled by a bunch of cloud servers on the internet may not be the best idea.

Internet connectivity for home devices should be optional - user should be incharge of deciding whether he/she wants to expose the home-devices to internet(may be for remote monitoring/controlling purpose), but in today's world, there are so called "alexa"/"google-home" compliant wifi devices who insist on internet else they wont work.

Thanks to the opensource community(tasmota/espurna/etc) for helping us to jailbreak those wifi devices like sonoff/blitzwolf/teckin/etc.. but jailbreaking solves part of the problem, still the need for a home-automation gateway is a challenge and requires some advanced knowledge of setting-up wifi_access_point + mqtt_broker + automation_gateway_server(ex: domoticz/openHab).

To address this gateway problem in a simplest and cheapest way, here is my attempt to convert an existing Off-the-shelf cheap wifi-router into a full-automation-gateway to support following functionalities.

  • wifi-access-point
  • dhcp and dns server
  • mqtt broker(mosquitto)
  • domoticz
GL-MT300Nv2 is a ~$20 device which supports opensource firmware like openwrt. All I did was to build my own variant of openwrt firmware that includes all necessary components like domoticz and mqtt-broker.


Downside of using this device as an automation-gateway is the limited-wifi-range and limited set of domoticz plugins(because of 16MB flash limit). But its a good start if you want to start playing with home-automation on low-budget.

Ok, lets get started, follow these steps to overwrite OEM firmware with autom8box on GL-MT300N-v2 hardware.

1) Download the autom8box binary from here.
2) Power ON your GL-MT300N-V2 box and wait for device's ssid to show up on you PC.
3) with OEM firmware, this device's ssid is shown as "GL-MT300N-V2-xxx"














4) Go ahead and "Connect", when a password window shows up, enter "goodlife" (this info is also printed on the backside sticker of GL-MT300N-v2)















5) If everything goes well, you will see the following message on your windows PC.










6) Open a browser, and enter following address in the URL field:
http://192.168.8.1/cgi-bin/luci/admin/system/flashops



7) As shown above, leave the password box empty and click on "Login" button. Next window will take you to firmware update section as shown below.





8) As shown above, uncheck "Keep settings box" and choose the file(autom8box-mt300nv2.bin) which was downloaded from a link given in step-1.
































9) Click on "Flash Image" button and wait for next window to show up and click on the "Proceed" button.























10) Next window you will see as follows, wait for about 2minutes.















11) After 2minutes, check on your Pc's wifi-list, new ssid "autom8box"  will show up


















12) when connected, password request will show up, again "goodlife" is the password.















13) If everything goes well, then your PC will get the ip address in the range of 192.168.8.x

14) open the following URL in the  browser - there you go! your new shiny domoticz UI
http://192.168.8.1:8080





















 From here onwards i assume you know how to add and configure the devices on domoticz. But as part of initial setup, here are some important steps i recommend to secure your home-devices-network.

Q: What are the ssh login details?
A: user: root and pw: goodlife

Q: How to change the root password?
A: using ssh, login to the box and run the following command
         "passwd root" when asked, enter the new password

Q: How do i change the ssid key?
A: using ssh, login to the box and run the following command
         "uci set wireless.default_radio0.key=my-new-ssid-key-here;uci commit wireless;wifi"

Q: How do i change the ssid?
A: using ssh, login to the box and run the following command
         "uci set wireless.default_radio0.ssid=my-new-ssid-here;uci commit wireless;wifi"

Q: I dont trust your binary, can i build the image from sources? is it opensource?
A: As of today, my openwrt build scripts are not organized well, but you can try to build the image yourself and let me know if you face any problem. Sources and buildscripts are all opensource on github, here you will find the build instructions.


Important Note:
As of now, autom8box doesnt support automatic saving of domoticz database, for the moment, after adding all your domoticz devices, you need to ssh login and run manual "reboot" command, during reboot domoticz databased is saved from ram to persistant partition - if you do hard-power-cut your previously configured devices on domoticz may get lost - i plan to fix this in future.


18 comments:

Unknown said...

Hey ho,

I have some of the "Sister Series" GL-MT300A
Flying around somewere here.

Its basically the same price & thing but the SoC is a different one MTK 7620A @580Mhz but more importantly the Storage is woping DDRII 128MB/ FLASH 16MB.

Would you mind compiling a second Firmware for this Box?

Angelo Filippi said...

great work! i will try soon as possible.

Unknown said...

How can I do this on other routers?

WorldWideSkylab said...

Can I use this box instead? it's like a better version of the one you choose IMO

https://smile.amazon.com/gp/product/B01FJ4S9JK/ref=ox_sc_saved_title_2?smid=A364119SDJA4QG&psc=1

Unknown said...

Can I try this one with open hab?? or i need more muscle in the hub to run open hab on this??

Unknown said...

Any chance of reverting back to original firmware?

Ener-jblog said...

I found your blog very informative and useful. Thanks for sharing.
Smart Home Security

Ram Chauhan said...

Impressive!! and we are also one of the Cheapest Wireless Mobile Network Signal Booster In India.
Best Mobile Network Signal Repeater

Logan L Watson said...

This content is simply exciting and creative. I have been deciding on a institutional move and this has helped me with one aspect. best home builder in st louis

Unknown said...

Hello,

I'm really happy to have found this page.
I've managed to install the firmware on this pocket router.
Domoticz is going well...
I've manged to install some more package (nano, curl, jq...)
But I still can't load script from 'Action On' or 'Action Off' with a dummy device.

I've search on the net but I don't find the way to make it possible.
Should it be possible to get some help about this point ?

Thanx a lot.

Cyril

allin121 said...

this is the information i am searching over the internet as i am also in same type of business.
192.168.1.1

Nick Act said...

Hey great work.. I loved this post..Thanks for sharing this information. home automation solutions

Ener-jblog said...

Great post. Thanks for sharing.
Hot Water Tap

Unknown said...

this would be even nicer if it supported cc2531 usb dongle ..

Allbet Casino Malaysia said...

Thanks for sharing me awesome info of handmade gifts, very impressed know more about Allbet Malaysia

From Finland said...

Hello

Can I use this with Heishamon and Domoticz for Raspberry?

Richard said...

I just wanted to drop by and say how much I appreciate your positivity and creativity in each post!"Think of a minecraft servers ip as our own digital world where you can create anything you imagine and share it with others.

Anonymous said...

Esta publicación fue estimulante y agradable de leer. ¡Gracias por su arduo trabajo! ¿Busca una forma divertida y adictiva de mejorar su velocidad de clic? ¡La CPS Test te mantendrá entretenido mientras te desafías a ti mismo!