Showing posts with label home automation. Show all posts
Showing posts with label home automation. Show all posts

Friday, July 03, 2020

Vendor-Neutral Zigbee Gateway with Raspberry Pi

A one-script installer that turns a Raspberry Pi + CC2531 USB adapter into a vendor-neutral Zigbee home automation gateway running Domoticz — supporting 800+ Zigbee devices from any manufacturer.

Pimoticz hardware setup — Raspberry Pi with CC2531 USB adapter

Raspberry Pi with CC2531 USB Zigbee adapter — the complete Pimoticz hardware.

The problem

Cheap Zigbee home automation devices are everywhere, but they're locked to the manufacturer's gateway — limiting you to a small set of supported devices. With commercial off-the-shelf (COTS) hardware, you can build your own vendor-neutral gateway, but it requires setting up multiple components:

  1. Raspberry Pi
  2. CC2531 USB Zigbee adapter (with Koenkk firmware, ~$12 on Amazon)
  3. Raspberry Pi OS (32-bit)
  4. Node.js (v12 or higher)
  5. zigbee2mqtt
  6. Mosquitto MQTT broker
  7. Domoticz
  8. zigbee2mqtt plugin for Domoticz

For beginners, getting all these components working together is a challenging task. Pimoticz simplifies this with an automated installer script — in about 5 minutes you should be ready to pair your first Zigbee device.

Items needed

  • Raspberry Pi
  • Micro SD card
  • 5V power adapter
  • CC2531 USB Zigbee adapter

Important: To avoid the CC2531 programming setup, buy a pre-programmed USB adapter with Koenkk firmware (CC2531_DEFAULT_20190608.zip or higher).

Raspberry Pi OS setup

CC2531 USB adapter, keyboard, mouse, monitor, and internet connection are only needed during the initial setup.

Step 1 — Prepare the SD card using Raspberry Pi Imager and install Raspberry Pi OS 32-bit.

Step 2 — Insert the SD card, connect keyboard/mouse/monitor and internet to your Raspberry Pi, then power on.

Step 3 — On first boot, the setup wizard will guide you through:

  • Language and keyboard layout (important for correct local time — Domoticz needs it)
  • Set a new password for the pi user
  • Black border check (not important — Raspi will run headless after setup)
  • Wi-Fi setup (skip if using Ethernet)
  • Software update (optional — can skip to save time)
  • Reboot to apply settings
Pimoticz architecture diagram

Pimoticz software stack — zigbee2mqtt, Mosquitto, and Domoticz working together.

Pimoticz installation

Open a terminal on the Raspberry Pi (locally or via SSH) and run:

git clone https://github.com/hackboxguy/pimoticz.git
cd /home/pi/pimoticz
sudo ./setup.sh -h my-pimoticz    # -h hostname is optional
# wait ~5 minutes for setup to complete
sudo reboot
Pimoticz setup script running

Setup script in progress — installing all dependencies automatically.

After reboot, open a browser and navigate to http://127.0.0.1:8080 or http://my-pimoticz:8080 — Domoticz will show the detected CC2531 Zigbee coordinator.

Domoticz dashboard showing CC2531 coordinator

Domoticz running on Pimoticz — CC2531 Zigbee coordinator detected and ready to pair devices.

Your Pimoticz gateway is ready. You can now pair Zigbee devices from any manufacturer — Xiaomi, IKEA, Philips Hue, Sonoff, and 800+ more.

SOURCE CODE

github.com/hackboxguy/pimoticz — installer script and documentation

Tuesday, January 01, 2019

$20 Pocket Router as Domoticz Smart Home Gateway

A custom OpenWrt firmware (autom8box) that packs router + Domoticz server + MQTT broker into an all-in-one home automation gateway running on a ~$20 off-the-shelf GL-MT300N-V2 pocket router.

Domoticz home automation gateway setup diagram

System overview: GL-MT300N-V2 running autom8box firmware as Wi-Fi AP, MQTT broker, and Domoticz server.

The problem

Wi-Fi based home automation products are cheaper than Zigbee or Z-Wave, but they typically require internet connectivity. Letting cloud servers control your home devices is not ideal — internet should be optional, not mandatory.

Thanks to the open-source community (Tasmota, ESPurna, etc.) for helping jailbreak devices like Sonoff, Blitzwolf, and Teckin. But jailbreaking solves only part of the problem — you still need a home automation gateway: Wi-Fi access point + MQTT broker + automation server (Domoticz, OpenHAB, etc.).

What autom8box provides

  • Wi-Fi access point — dedicated network for your IoT devices
  • DHCP and DNS server — automatic network configuration
  • MQTT broker (Mosquitto) — message bus for IoT devices
  • Domoticz — home automation dashboard and rules engine
GL-MT300N-V2 pocket router

GL-MT300N-V2 (~$20) — compact pocket router running the autom8box firmware.

Limitations: Limited Wi-Fi range and a reduced set of Domoticz plugins due to the 16 MB flash limit. But it's a good starting point for low-budget home automation.

Flashing steps

Step 1Download autom8box-mt300nv2.bin.

Step 2 — Power on the GL-MT300N-V2 and wait for its SSID to appear (shown as GL-MT300N-V2-xxx).

GL-MT300N-V2 SSID visible in Wi-Fi list

OEM SSID appearing in the Wi-Fi list.

Step 3 — Connect to the SSID. When prompted for a password, enter goodlife (printed on the device's back sticker).

Wi-Fi password prompt

Enter the default Wi-Fi password.

Step 4 — Once connected, you should see the confirmation message:

Wi-Fi connected confirmation

Successfully connected to the router.

Step 5 — Open a browser and navigate to:
http://192.168.8.1/cgi-bin/luci/admin/system/flashops

LuCI login page

LuCI login — leave the password box empty and click "Login".

Step 6 — In the firmware update section, uncheck "Keep settings", choose autom8box-mt300nv2.bin, then click "Flash Image".

Firmware upload page

Firmware upload — uncheck "Keep settings" and select the autom8box binary.

File selected for flashing

File selected — ready to flash.

Step 7 — Click "Proceed" to confirm:

Flash confirmation dialog

Confirm flashing — click "Proceed".

Step 8 — Wait about 2 minutes for the flash to complete:

Flashing in progress

Firmware flashing in progress — wait for the device to reboot.

Step 9 — After reboot, a new SSID autom8box will appear. Connect with password goodlife.

autom8box SSID in Wi-Fi list

The new autom8box SSID is now visible.

Step 10 — Open http://192.168.8.1:8080 in your browser — Domoticz is ready:

Domoticz dashboard running on autom8box

Domoticz home automation dashboard — running entirely on the pocket router.

Post-setup security

SSH credentials: user root, password goodlife

Change root password:

passwd root

Change Wi-Fi password:

uci set wireless.default_radio0.key=my-new-password
uci commit wireless
wifi

Change SSID:

uci set wireless.default_radio0.ssid=my-new-ssid
uci commit wireless
wifi

Important: autom8box does not auto-save the Domoticz database. After configuring your devices, SSH in and run reboot — during reboot the database is saved from RAM to the persistent partition. A hard power cut without rebooting may lose your configuration.

SOURCE CODE

github.com/hackboxguy/lede-a5v11 — build instructions and sources

autom8box-mt300nv2.bin — pre-built firmware image

Sunday, December 30, 2018

Build a $2 IoT/MQTT Node with a Bare ESP-12F

How to use a bare ESP-12F module as a standalone IoT/MQTT node — powered directly from a USB charger with just a handful of passive components, no base board required. Total cost: under $2.

Completed ESP-12F standalone MQTT node

Finished board — ESP-12F module with USB connector, ready to plug into any 5V charger.

Items needed

Prices based on AliExpress at the time of writing:

  • 1x ESP-12F module (pre-programmed with Tasmota firmware)
  • 1x 10k SMD resistor
  • 1x 10k through-hole resistor
  • 2x 4001 SMD diode
  • 1x USB male connector (PCB mount, SMD)

Schematic

ESP-12F standalone board schematic

Wiring diagram — USB 5V stepped down through two diodes to ~3.6V for the ESP-12F.

Board preparation

Step 1 — Ensure the ESP-12F module is programmed with Tasmota firmware. See the ESP-12F programming post for details.

Step 2 — Mount a 10k SMD resistor between the GND and IO15 pads of the ESP-12F module.

10k SMD resistor between GND and IO15

10k SMD resistor soldered between GND and IO15 pads.

Step 3 — Mount a 10k through-hole resistor between the VCC and EN pads of the ESP-12F module.

10k through-hole resistor between VCC and EN

10k through-hole resistor connecting VCC to EN (chip enable).

Another view of the VCC-EN resistor

Another angle showing the VCC–EN pull-up resistor.

Step 4 — Stick a piece of insulation tape on the right side of the ESP-12F module so the USB connector doesn't short any pads.

Insulation tape applied to ESP-12F

Insulation tape prevents shorts between the USB connector and ESP pads.

Step 5 — Place the USB connector as shown below. The SMD pins of the USB connector should sit over the insulation tape.

USB connector placed on ESP-12F

USB connector positioned over the insulation tape.

Step 6 — On the back side, fix the USB connector to the ESP-12F using hot glue. Don't apply hot glue on the SMD pin side yet — that comes later.

Hot glue fixing USB connector on back side

Hot glue secures the USB connector on the back side.

Step 7 — Solder two SMD diodes in series between the + line of the USB connector and the VCC pad of the ESP-12F module.

Two SMD diodes in series for voltage drop

Two 4001 diodes in series drop 5V USB to ~3.6V for the ESP-12F.

Step 8 — Connect the line of the USB connector to the GND pad of the ESP-12F module.

GND wire from USB to ESP-12F

USB ground connected to the ESP-12F GND pad.

Step 9 — Apply hot glue on both sides of the USB connector and ESP-12F for stability.

Hot glue applied for stability

Hot glue on both sides for mechanical strength.

Completed board from another angle

Completed board — ready for testing.

Testing

Step 10 — Power the board with a 5V USB charger and look for an open Wi-Fi SSID named sonoff-NNNN.

Step 11 — Connect to the SSID and follow the standard Tasmota generic module configuration.

Your $2 IoT/MQTT node is ready. Plug it into any USB charger, configure Tasmota to connect to your MQTT broker, and start automating.

Sunday, December 31, 2017

Remote Home Access with a 5-Euro Pocket Router

How to turn a ~5€ A5-V11 pocket router into an XMPP chat-bot that lets you remotely access and control your home network from a smartphone — no port forwarding or dynamic DNS required.

Why the A5-V11?

In the quest for the cheapest off-the-shelf Linux hardware, the A5-V11 pocket router stands out — it consumes just ~0.3W, making it ideal for always-on IoT applications.

CPU360 MHz MIPS (Ralink RT5350)
RAM32 MB SDRAM
Flash4 MB
Ethernet100 Mbit
Wi-FiIEEE 802.11b/g/n
USB1 port for peripherals
LEDsRed and blue status indicators
A5-V11 pocket router overview

The A5-V11 pocket router — a ~5€ Linux device consuming just 0.3W.

How it works

The custom a5v11-xmpp firmware strips down most router/Wi-Fi functionality to fit an XMPP chat client daemon (based on lib-gloox) that acts as a chat-bot. XMPP makes it easy to access your home network without tweaking your home router settings — no port forwarding or NAT configuration needed.

Keep this device connected to your home internet and "chat" with it from anywhere using the Xabber app on your smartphone.

Setup instructions

Step 1 — Create two XMPP/Jabber accounts (master and slave) on your favorite Jabber server as explained here. Add both accounts as friends so the XMPP server can pass messages between them.

Step 2 — Connect a CAT-5/6 cable between your PC and the A5-V11 router, then power it on.

Step 3 — Flash the stock firmware with the a5v11-xmpp image. Follow the step-by-step guide in this blog post (also see the OpenWrt wiki for general instructions).

Step 4 — Connect the A5-V11 router to your home router's network (internet).

Step 5 — Log in via SSH to host my-a5v11 (user: root, default password: brb0x).

Step 6 — Configure the XMPP login details:

echo "user: test-slave-account@xabber.de" >/etc/xmproxy/xmpp-login.txt
echo "pw: chatbotpw" >>/etc/xmproxy/xmpp-login.txt
reboot

Important: Replace the test account details with your own credentials. Also use passwd to change the default root password.

Step 7 — Install Xabber on your smartphone and log in with the master account.

Step 8 — You should see the A5-V11 router appear online in Xabber. Send help to get a list of available commands.

Use cases

1. Get your public IP — Send publicip and the chat-bot responds with your home router's public IP. No dynamic DNS needed.

2. I2C peripheral control — Connect an i2c-tiny-usb adapter to the USB port for controlling sensors, GPIO expanders, and other I2C devices:

shellcmd i2cdetect -r -y 0       # scan for I2C devices
shellcmdresp                      # read the scan result
shellcmd i2cset -f -y 1 0x3c 0x00 0xff b   # set PCF8574 pins high
A5-V11 with i2c-tiny-usb adapter connected

A5-V11 with i2c-tiny-usb adapter for peripheral control.

3. Sonoff relay control — Control Sonoff Wi-Fi relays running Tasmota firmware on your local network:

sonoff 192.168.1.10 on       # switch ON
sonoff 192.168.1.10 off      # switch OFF
sonoff 192.168.1.10 toggle   # toggle
sonoff 192.168.1.10          # read current state

4. Remote SSH commands — Trigger commands on other Linux machines via sshpass:

shellcmd sshpass -praspberry ssh -y pi@raspi-ip sudo reboot
shellcmd sshpass -praspberry ssh -y pi@raspi-ip sudo poweroff
shellcmd sshpass -praspberry ssh -y pi@raspi-ip omxplayer /tmp/video.mp4

5. Wake-on-LAN — Power on a PC that supports WoL:

shellcmd etherwake 00:00:DE:AD:BE:EF

SOURCE CODE

github.com/hackboxguy/lede-a5v11 — build instructions and sources

a5v11-xmpp.uimg — pre-built firmware image

Monday, January 04, 2016

Control Home Devices via XMPP Chat with Raspberry Pi

Control your home devices from anywhere using a Raspberry Pi running the RBox Linux distribution. The RBox chat-bot connects to a public XMPP/Jabber server, so you can toggle GPIO pins from your phone's chat app — no port forwarding, no dynamic DNS, no paid cloud services.

How it works

Setup diagram — Raspberry Pi at home communicating with smartphone via XMPP

Setup diagram — Raspberry Pi at home and your phone both connect to a public Jabber server. Chat messages carry GPIO commands.

Both the Raspberry Pi (running RBox) and your Android phone (running Xabber or any XMPP client) log in to a public Jabber server with their own credentials. Once the two accounts have authorized each other, they can exchange chat messages through the server.

Advantages

  • No router configuration or port forwarding needed — all incoming firewall ports can stay blocked
  • No dependency on paid cloud services — hundreds of free Jabber servers are available
  • Works from any location as long as your phone has internet access (Wi-Fi or mobile data)

Controlling GPIO

To toggle a GPIO pin, send a chat message from your XMPP client:

Gpio 2 1    # set GPIO2 high
Gpio 2 0    # set GPIO2 low

For full setup instructions (SD card preparation, XMPP account creation, first boot), see the RBox installation guide.

SOURCE CODE

github.com/hackboxguy/brbox — RBox sources and build instructions

Saturday, December 10, 2011

$35 Linux Box for Robotics and Home Automation

A survey of low-cost Linux boards for home automation, robotics, and DIY hardware — and why a ~$35 TP-Link MR3220 Wi-Fi router running OpenWrt turned out to be the sweet spot in 2011.

TP-Link MR3220 router with OpenWrt

TP-Link MR3220 — a cheap Wi-Fi router capable of running OpenWrt Linux.

The hardware landscape

Over the past few years I studied several low-cost open-source hardware platforms for home automation:

Board Price
Beagleboard$150
Beagleboard xM$150
Beaglebone$89
Sheevaplug$85
Seagate Dockstar$50
Buffalo Linkstation Live~$150
Linksys WRT-54GL$50
Asus RT-N16$90
TP-Link MR3220$35
Raspberry Pi$35

Only a few of these are truly open in terms of hardware and software. The rest are commercial products with an option to run open-source Linux.

Requirements

  • Decent processor, RAM, and flash — under $40 (2000 INR)
  • Off-the-shelf product available locally (India)
  • Open-source Linux support (OpenWrt / DD-WRT / Tomato)
  • Lightweight with low power consumption
  • Easy option to extend I/O peripheral access

Why a Wi-Fi router?

With these requirements, I narrowed down to the TP-Link MR3220. While the Raspberry Pi was the ideal solution on paper, it was extremely hard to get in 2011 due to heavy demand.

A Wi-Fi router makes practical sense: everyone already needs one for home connectivity. Adding basic home automation capabilities with little added cost — while saving you from running a 24/7 power-hungry desktop — is a good bargain at ~$35.

For enthusiasts, hobbyists, and students interested in embedded Linux, robotics, home automation, and DIY hardware, a router with USB + OpenWrt lets you skip hardware development and jump straight into firmware and software.

Demo: Android app controlling LEDs over Wi-Fi

No warranty void: You don't need to open your router. The openUI hardware is a USB add-on board that plugs into the router's USB port.

Hardware photos

Collection of Linux hardware boards

My hardware collection — various Linux boards evaluated for home automation.

MR3220 router with openUI USB board

MR3220 router with the openUI USB add-on board connected.

Android app for controlling LEDs

Android app controlling LEDs via Wi-Fi through the MR3220 + openUI setup.

openUI board close-up

Close-up of the openUI USB board.

openUI hardware specs

openUI board with LCD display

openUI board featuring LCD, IR receiver, RTC, and I2C connector.

  • AVR ATtiny2313 — acting as a USB HID device
  • LCD display — for status output
  • RC5 IR receiver — for remote control input
  • PCF8563 RTC — I2C real-time clock with battery backup
  • I2C connector — for extending with additional peripherals
  • ISP header — in-circuit programming for ATtiny2313

Find the schematic, PCB layout, and source code for the openUI hardware and software in this follow-up post.