Friday, July 03, 2020

Pimoticz : Vendor neutral Zigbee gateway with Raspi

Tldr: Instructions for preparing Raspi as zigbee gateway in 3 simple steps(git-clone/cd-to-dir/run-setup.sh;reboot)

These days its easy to find Zigbee based home automation devices at very low cost but all those Zigbee devices are targeted to be used with manufacturer provided gateway. This means, users are limited to a few set of zigbee devices supported by the manufacturer's gateway.

Using Commercial-Off-The-Shelf(COTS) hardware, there is a possibility to create your own "vendor neutral automation gateway" which opens up an interesting possibility of supporting more than 800 zigbee devices, but this involves an advanced knowledge of setting up Raspberry-Pi with various hw/sw components.

As an advanced user or DIY enthusiast, here is a list of components one would use to build a Zigbee gateway,

  1. Raspberry-Pi
  2. CC2531-USB-zigbee-Adapter(with koenkk firmware, can be purchased on amazon for ~$12)
  3. Raspberry-Pi OS(32bit)
  4. nodejs (ver 12 or higher)
  5. zigbee2mqtt
  6. mosquitto mqtt broker
  7. Domoticz
  8. zigbee2mqtt-plugin for Domoticz.

As an average user or a beginner to home-automation, its a challenging task to setup all these components to work together on a Raspberry-Pi.

Here is my attempt to simplify this setup using an automated installer script that takes care of installing all the dependencies and needed configuration. In about 5 minutes you should be ready to pair your first Zigbee device with Domoticz.

Items needed.

  1. Raspberry-Pi
  2. Micro sd-card
  3. 5v-power-adapter
  4. CC2531 based USB to zigbee adapter(important!!! to avoid programming setupbuy pre-programmed USb adapter with koenkk-firmware:CC2531_DEFAULT_20190608.zip or higher version)


Raspi-OS Installation steps:
NOTE: CC2531-usb-adapter/keyboard/mouse/monitor/internet-connection are needed during the initial setup only):

  1. Prepare the sd-card using Raspberry-Pi-Imager and install Raspberry-Pi-OS-32BIT(I assume this step is pretty straight forward, there are tons of guides explaining this).
  2. Insert the Raspberry-Pi-OS sd-card, connect key-board/mouse/monitor and internet to your Raspi and and turn on the 5Vdc power.
  3. On first boot, raspi-os will guide you through a setup wizard where you will be asked to setup few details like..
    • Language and key-board-lay-out(important to have a correct local time on your raspi for domoticz to work correctly).
    • Set new password for your "pi" Linux user.
    • check box asking if a black border is visible on the monitor(not important as your raspi will be running in headless mode after comoticz installation).
    • Wifi setup(ignore if you have already connected raspi using LAN wire).
    • Update sw(skip incase if you dont want to wait for all the upgrades to happen).
    • Reboot raspi to allow all the settings to take effect.

Pimoticz Installation steps:

  1. on raspberry PI, open a shell-terminal(using remote ssh login, or directly on Raspi)
  2. git clone https://github.com/hackboxguy/pimoticz.git
  3. cd /home/pi/pimoticz
  4. sudo ./setup.sh -h my-pimoticz (-h hostname is optional).
  5. wait for setup to finish (takes about ~5-6minutes)
  6. sudo reboot



After reboot, start the chrome browser on you raspi(or remote pc) and open http://127.0.0.1:8080 or http://my-pimoticz:8080 (here you will see domoticz webUI showing detected zigbee Coordinator-CC2531-USB-Zigbee-Adapter).


Thursday, February 27, 2020

Yet Another Raspi Media Player(YARMP)

There are tons of raspberry pi based media players, why another one?

  • Ready to use, buildroot based lightweight image < 65MB
  • In 3 easy steps, you can have Raspi playing media file in a loop(audio/video/images)
  • Media starts playing in less than 20seconds after power ON
  • Single image supports all variants of Pi-1(Pi-Zero/Pi-Zero-W/Pi-A/Pi-B/Pi-A+/Pi-B+)
  • Works on old raspi's with lowest 256MB ram variant and sd-card size of 1GB
  • Autoplays Video or Audio or Images which are found on internal sd-card or external-fat-formatted-usb-drive.

How to get the raspi playing media in 3 easy steps
  1. Download this raspi-yarmp.img.xz image to your PC
  2. Using balenaEtcher, write the image to sd-card.
  3. Plugin the sdcard and boot the raspi... Thats it!!! default included video starts playing in a loop.







Ok, I have the default bbc-motion-gallery-video playing now, how do I replace this video with my own on raspi sd-card?
  1. Remove the sd-card from raspi, and plug it into your windows-PC
  2. On your windows-PC, multiple new drives will show-up, browse to the drive USRDAT:\media-files\ and look for file "sample-video.mkv", if your PC doesn't  show USRDAT drive, then try using usb-to-sdcard reader or try sd-card mounting on a Linux-PC.
  3. delete this file(or take a backup) and add your own media file(audio/video or image) under "media-files" directory.
  4. Insert the sd-card onto raspi, and power ON, raspi shall play your newly added media(s) in a loop
Note: In step-2, if you are unable to find USRDAT drive, then just copy your video file to a fat formatter usb-drive insert it on to raspi, and power-cycle(Raspi upon bootup, checks if any media files exists on external-usb-drive, if found, then it will pay this instead of internal sdcard video)


If I attach USB drive having media files to Raspi, can it play the content of my usb-drive instead of internal default video?

  1. Yes, if external USB drive on raspi is found, then playback preference is given to the media files of external USB drive.
  2. Ensure that your USB drive is fat formatted(vfat), and copy single or multiple video/audio/image files to this USB drive, insert it onto Raspi's usb connector, and reboot.

Can I use Raspi-yarmp image as digital album to play my photos?
  1. Yes, copy your photos onto fat-formatted usb-drive or usb-stick, plug it in to raspi usb connector and restart the raspi.
  2. If playback delay is not sufficient or needs adjustment, then edit the /mnt/userdata/rc.local on raspberry pi(check for the section where fbv commandline utility is called)

What If my external USB drive contains Video-Files/Audio-Files/Images, which one will play in a loop?
  1. First preference is given to video files
  2. Second preference is given to audio files(e.g mp3)
  3. Third preference is given to image files (e.g jpg/png/etc)
  4. If none of the files are found, or no external usb drive is found, then default sd-card included bbc-motion-gallery video will play.

Can Raspi-yarmp play videos in a seamless loop? means, when playback switches from one video to another(or when video rewinds to beginning), usually screen goes black for few seconds, can this be avoided?
  1. Yes, by default, if single video file is found, then raspi will play this file in a seamless-loop, means screen going black will not happen when video rewinds to beginning.
  2. Incase if you have multiple video files which needs to be played in a seamless manner, then merge all your videos into one single video using melt-tool

What's the use of Raspi-yarmp like media player? who needs this? where is it applicable?

  1. Can be used as a media-player for digital signage application
  2. If you are a audio/video technician who needs a handy tool to test your audio/video setup, you can use raspi-yarmp on Pi-Zero powerd by battery-bank and use it as hdmi audio-video source when needed.
  3. As an artist, you can show your work on a display running your content in a loop.
  4. In Museum, you can find such a low cost media player handy.
  5. For your science project, you can have a small hdmi display with raspi playing your own content.
  6. Use raspi-yarmp to play your photos  in a loop on a hdmi display(digital photo album)
  7. Many more...!!!

Here is my battery-powered Pi-Zero running raspi-yarmp as digital photo album on a 7inch LCD setup costing <$50






Let me know in comments section if you have suggestions/improvements/question.
Happy hacking...