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.


5 comments:

T1g3rch3n 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??