post

Zigbee and Domoticz

Part 2 of the Domoticz project: Zigbee devices added.
The living room now has 4 Domoticz Zigbee lights!

post

Zigbee and Domoticz

After the installation and configuration for Domoticz with RFLINK and P1 Smartmeter and Bresser Weatherstation hr real home automation started with adding Zigbee devices to the system.

On my wish list were of course light switches and environment sensors like temperature, humidity, presence/movement detection, light (lux).
Now there are many high quality and affordable Zigbee devices on the market, so far so good. A reliable system which gains popularity fast.

Domoticz support for Zigbee devices is not native, it requires plugins and more. The MQTT system has to be used, with an MQTT broker and the Zigbee2MQTT software.
MQTT (Mosquitto is the preferred product on a Raspberry Pi) is the backbone for many home automation solutions, not limited to Zigbee, I may need it for Tasmota integration also.

Zigbee integration has to be done with Zigbee2MQTT, software combined with hardware to access the Zigbee mesh network as Coordinator. Also widely used in home automation, mostly with a Zigbee USB stick as hardware, making it manufacturer independent, no need for limited bridges etc by Zigbee manufacturers as Philips Hue etc.
The list of supported Zigbee devices is limited in Zigbee2Mqtt, but most popular ones are there.

Getting the Zigbee devices into Domoticz uses a plugin called Zigbee2MQTT – Domoticz Python Plugin
The list of supported Zigbee devices is even more limited in Zigbee2Mqtt, a severe limitation!
CHECK THIS LIST FIRST BEFORE BUYING Zigbee hardware. Support of the plugin is one mans evening hobby and therefore slow and limited!
I made the ‘error’ of buying the (quite unique) AduroSmart ERIA smartplug dimmer, supported in Zigbee2Mqtt, but not in Zigbee2MQTT – Domoticz Python Plugin. I made a github issue for support the ‘new device’, but it may take long or never to get support.

Step 1: MQTT Mosquitto

Install following this guideline.
Do also the tests. Note that this installs Mosquitto without much security! Fine for local usage.

Step 2: zzh! CC2652R Multiprotocol RF Stick


I choose the modern zzh! CC2652R Multiprotocol RF Stick, a tiny “USB stick” form-factor development board for multiprotocol RF tinkering! Designed and sold on Tindie by Electrolama in United Kingdom. Easy to add firmware, no special programmer hardware, excellent range.



First step is to add the hardware to a Zigbee network from the Pi. The excellent zzh! CC2652R Multiprotocol RF Stick does the job nicely.

Install the firmware folllowing the Flash Guide and the Coordinator Firmware

First on the Raspberry Pi perform the next command:

ls /dev

and note the ttyUSBx devices. The P1 Smartmeter was ttyUSB0.
Now insert the USB Zigbee stick in the Raspberry Pi (power off and insert the stick, then power on) and do this again:

ls /dev

and note the newly ttyUSBx device, ttyUSB0 ea=nd ttyUSB1, the USB Zigbee stick or the P1 SMartmeter.
If more than one ttyUSBx is attached the Raspberry Pi will randomly give it a sequence number at boot, so ttyUSB0 can become ttyUSB1 and prevent your home system from working.
Therefore find out the id of the port.

ls-l /dev/serial/by-id

and copy the part belonging to the USB stick, for me: usb-1a86_USB_Serial-if00-port0 for the next step.

Step 3: Zigbee2MQTT

Zigbee2MQTT is the toolset required.
With the correct serial port in use identified, edit your Zigbee2mqtt configuration.yaml with that information (scroll down in the editor, the instructions are a bit unclear here!

serial:
  port: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0

You see the USB Zigbee stick working if you followed the instruction guide to the letter.

Step 4: Zigbee2MQTT – Domoticz Python Plugin

Python plugin for Domoticz to add integration with zigbee2mqtt project. This the part where Domoticz gets the Zigbee devices.

Install following the instructions on the github page and reboot Domoticz (better restart from Domoticz, so you know it works after a reboot!).
In Domoticz you now get an extra tab, called Custom, with Zigbee2MQTT as page and a new Hardware type Zigbee2MQTT. Check the settings, if no security and local MQTT then leave most fields.

(May 11 2021) I had to restore to an older version, before the commits to humidity/temperature/pressure which also broke the WSDCGQ11LM sensors.

git reset --hard b708fc4

Step 5: Add Zigbee devices, pairing

Now power on Zigbee hardware, in a process called pairing. Get the Zigbee device in factory mode, as it is after first ever power on, or pressing buttons. See the docuumentation, every device does it differently.
Allow new hardware on the Settings page “Accept new Hardware Devices Allow for 5 Minutes”
Zigbee devices are entered into Zigbee2MQTT automatically if you check “Allow new zigbee devices to join” on the Domoticz Zigbee2MQTT page, keep that page open!

Refesh and Zigbee hardware will appear in the list. Click in this list on a newly added Zigbee hardware and see the devices you can add to Domoticz devices. This process is really different from native Hardware and Device Domoticz support and not automatic, so look and choose carefully.

From now on it is standard Domoticz, Zigbee devices are available.

(May 11 2021) I had to restore the plugin to an older version before the commits to humidity/temperature/pressure which broke the WSDCGQ11LM sensors.

cd domoticz/plugins/zigbee2mqtt
git reset --hard b708fc4

and restart the system.

Zigbee devices

Philips Hue white A60 bulb E27
Philips Hue Go
Aquara Temperature/Humidity/Pressure sensor
WSDCGQ11LM. Very small, affordable, reasonably correct sensor values.
Replace batteries immediately, one was already empty, the other bad. CR2032 type.
Aqara human body movement and illuminance sensor
RTCGQ11LM. Lux and movement. Small, affordable, reasonably correct sensor values. Temperature (very inaccurate), Lux and movement.

BASICZBR3 Zigbee smart switch
No problems, works fine. Easy to pair, safe to attach wires. Router. Sold for Euro 12,50 at Tinytronics Eindhoven.

Sonoff SNZB-03 – Motion Sensor

CR2450 battery. Small PIR sensor. End device. Performs well.

Domoticz, Arduino, Raspberry, Weatherstation, Smartmeter


My new Home Automation System, to see power usage, weather conditions, doorbells and later on switches!

Domoticz, Smartmeter, RFlink and Bresser weatherstation

A combination of Raspberry Pi and Arduino: my Domoticz system.

Domoticz is a Home Automation system design to control various devices and receive input from various sensors. Open source and free!

I wanted a local home automation system to see:

  • P1 Smartmeter power information
  • The Solar Goodwe Inverter controlling the  12 Solar panels on the roof
  • Weather information of the sensors around the house and nearby
  • RF 433 MHz devices like the KlikAanKlikUit doorbell, weather sensor, switches
  • Notification if doorbell pushed on phonoe and PC with camera snaphot
  • Weather information of the Bresser 5 in 1 Weatherstation
  • control Zigbee devices (Philips Hue)
  • control Tasmota (Sonoff and diy) devices via Wifi
  • Not being dependent of cloud computing on switching on lamps, local database
  • Whatever I may design or build later on

So I did some research and found with Domoticz I could do all this. This page tells how it currently looks like/
Not realized yet is the Zigbee part, and I have not started on converting my Sonoff’s to Tasmota. The other wishes are operational!
The dashboard of Domoticz system is out of the box not very appealing, that will be next.

Hardware
A Home Automation system will be 24/7 running and, with all the sensors attached, quite busy updating the database. So low power, enough computing power, enough and dfast reliable storage and reliability are key.

  • A Raspberry 4 with 2 GB is the central CPU. A SSD of 120 GByte with RPi boot supported AMS 51xx IC USB 3 adapter as storage. No SD card!
  • A RFLink as sold by Nodo to receive and send via 433 MHz, Arduino Mega2560 via USB serial and an Aurel 433 MHz module
  • A P1 Smartmeter cable, serial USB FTDI basedfor my ESRM5 Smartmeter
  • Ethernet and Wifi via onboard Raspberry Pi
  • In the ‘meterkast’, meter cupboard, close to the Smartmeter and the Internet route/switch
  • A CCC2652RB Zigbee USB stick, which are Out of Stock at the moment
    • Domoticz

      Domoticz is easy to setup on a Raspberry Pi. Install Raspberry Pi Lite with Raspberry Pi Imager (press CTRL-Shift-X to set the SSH and password!).
      Do the usual Raspberry Pi Operating system configurration, with Ethernet connected, with raspi-config with Putty for local time setting (important!) , Wifi settings, hostname, boot order.
      Write down the used IP addresses for Ethernet and Wifi!
      Reboot!
      Just follow the installation guide on the Domoticz wiki for setting up Domoticz, again via SSH and copy the commands from the Wiki into the SSH session.

      Place the Raspberry in the meter cupboard and startup, and see Domticz in your browser. Check Ethernet and Wifi access.
      Look at settings like Login without password for Local Networks (no username/password), automatic backups etc.

      Dutch DSMR smart meter with P1 port
      I bought the USB P1 Smartmeter cable for my Smartmeter ESMR5 type from Smartmeterdashboard.
      Every Smartmeter seems a bit different (open collector, inversed data), and this cable works for my ESRM5
      The USB part is a FTDI based USB serial adapter, the P1 side a RJ11 connector for the Smartmeter.

      P1 Smartmeter is supported out of the box in Domoticz and give many devices with the power information. Electicity and Gas usage.

      Goodwe Solar Power Inverter readout
      My solar panels are connected to a Goodwe inverter. The inverter sends the data collected to the SEMS Portal, which has an API.
      So A Goodwe SEMS Portal hardware device is available in Domoticz. Easy to add, and gives all information on the Solar inverter.

      Camera’s
      I have two cheap Chinese camera’s, good quality, ONVIF support, not much documentation, so what is the snapshot image url required for Domoticz??

      After some searching I found the answer on the Domoticz forum, use the ONVIFER application

      • Install ONVIF IP Camera Monitor (Play Store, Android for me)
      • Find the camera and make it work with the user and admin of the camera
      • Scroll down and see the snapshot image url
      • Fill this in Add Camera

      For my camera’s it was: http://192.168.x.y/web/auto.jpg?-usr=&-pwd=&

      RFlink for 433 MHz devices
      I had to make a choice for a device to receive and transmit RF 433 MHz signal. Two hardware solutionas are available, RFXCOM and RFLink.
      The choice became easier when I found out the RFXCOM is perhaps the better solution, but quite expensive and sold out.

      So it was RFlink, an Arduino ATmega2560 with a RFlInk shield for the low level 433 MHz transceiver. I bought a DIY kit from Nodo shop and soldered it together, easy job! The package consists of a gateway RFlink PCB (comes with 433 MHz Transceiver Aurel and an I2C connector), an Arduino Mega Compatible, 433Mhz antenna and USB cable. Load (alas closed) RFLInk firmware witht eh Arduino IDe and connect.

      So far the RFLink has detected two outdoor temperature/humidity sensors and my KlikAanKlikuit doorbell as devices.

      The doorbell has now notifications!

      Notifications

      I have implemented notifications for pushing the doorbell with:

      • Email
      • PushSafer (with image, use the camera URL as shown above)
      • PushBullet

      Buienradar
      Buienrader, the ducth weather site has an API for weather information, available in Domoticz.
      Easy to add, just make sure you have right Station ID (list here in the forum)

      Bresser 5-in-1 weatherstation, Weather Underground

      A weatherstation with outdoor and indoor sensors for temperature, humidity, wind direction, wind strength, pressure.

      A simple and affordable system, with the ability to upload to Weather Undergroud and Weathercloud. The last has a nice brwoser view of the weather data of your own weatherstation.

      Weather Underground has an API and an API key if you have a Personal Weather Station. Add the Hardware and you get several devices with the weatherstation information.

notepadqq and wxhexeditor

sudo apt update
sudo apt install snapd
sudo reboot

sudo snap install notepadqq

sudo apt install wxhexeditor

localhost bonjour avahi

Resolving raspberrypi.local with mDNS
On Raspberry Pi OS, multicast DNS is supported out-of-the-box by the Avahi service.

sudo nano /etc/hostname

sudo nano /etc/hosts

Install FPC and Lazarus 2021

Resources for installing FPC and Lazarus:

https://blog.boberglund.com/

https://wiki.freepascal.org/Build_current_FPC_and_Lazarus_for_Raspbian

post

Testing USB Serial TTL adapters

A program, SerialTester,  a guide and test results.

Also updated Prolific PL2303HXA driver misery solution.

 

post

Raspberrry Pi 400, first steps

First steps with the Raspberry Pi 400, first impressions
November 2, 2020. My birthday!
Early, checking twitter. Eben Upton says good morning. The Pihut responds and some tweets about children follow.
I recognize the pattern: if Eben is up this early online, it must be an announcement. And yes, there it is: the new Pi 400!
A Pi 4 in a keyboard, a homage to the home computers of the 80ties, a relief for those who worry about a naked PCB with untidy cabling in a school class, and all that value and performance for a low price!

So I gave myself a present, and ordered the Pi 400 immediately at The Pi Hut. After a week (quite fast this time for UK mail!) it arrives, a small rectangular package. Inside the Pi 400 and a power supply. I ordered the Pi 400 itself, not the package. I have enough cables, mouse etc.. And I do not want to use a SD card.

After installation and configuration, covered below, the fun starts. What a nice little machine! Reminds me of the home computers in the 80ties of previous century, which I tested and wrote so much about then. But in an modern format, with a modern and capable operating system, hardware fast enough for the most tasks, easy to integrate in my home network and systems.
Cool, compact, well protected, a mature operating system, Linux Debian nicely adapted to the Pi 400 and satisfies the needs of a regular user like me, with a Windows 10, Synology NAS and Pi’s network. You can see a lot of thought and work has gone into the design of the Pi 400 and it pays off!

Will it be my main PC? No, not really. That will be the Intel with Windows 10 power for photo and video editing, large software development, ergonomic and excellent Microsoft keyboard and mouse with three large displays,  large fast disks, lots of memory and CPU power.

Will it be my second PC? Yes, there is enough I/O and enough performance for web browsing, mail, media center, software and hardware development for the Pi with e.g.  Lazarus, for the other Pi’s here. With some cheap simple USB and SSD devices it keeps affordable and good enough.

All in all, it has found a place on my desk and in my network, it will be of real value to me!

What I cover here is:
Configuration
Installation to SSD
Audio: USB Audio and fight with Bluetooth
Camera, USB webcam
Overclocking
File Manager, access my Windows and Synology network shares
GPIO connector


Configuration
I opted for the Pi 400, US keyboard, and not the package. I have enough cables and mouses, and plan to skip the SD card completely.

Nicely packaged, online documentation only. Here is the (hard to find!)  Beginner’s Guide, 4th edition pdf download. Well written, recommended for new users. After many years working with Pi’s (since 2012) and keeping up to date with the blog and the forum, I found configuring and setting up the PI 400 quite easy.
As you can see in the photo I added to the Pi 400:
– USB hub into the USB 2 port, four USB ports for the next USB devices
– mouse (any USB mouse will do, I use the Raspberry Pi Mouse)
– USB audio adapter (a cheap one)
– USB webcam (an older simple one)
– HDMI mini to HDMI female  adapter cable to a DVI adapter to  (no HDMI on this Displayport/DVI/VGA)  IIyama monitor!.
– CAT5 Ethernet cable to the GHz network
– USB C power adapter, the official one
– USB-3 Eluteng adapter to SATA 120GB SSD disk (this Eluteng, has ASM IC, works fine)


Installation to SSD, no SD required!
I am not that fond of the SD card as system disk for a computer. Though in the real world it does work fine for most of us, it not designed for heavy computer use, wears out and is not that fast. For embedded usage it is ok, for a desktop a real larger computer hard disk is better. So for the Pi 400 I choose a SSD with an Eluteng USB 3 adapter. USB booting is now working well on the Pi 4 out of the box.

So I took the SSD to my WIndows PC, started the Raspberry PI Imager, choose the “Raspberry Pi OS (32-bit) with desktop” as OS and the SSD as “SD card” (yes, that is supported!).
Writing the image was very fast compared to imaging an SD card!

The SSD was then attached to a USB-3 port of the Pi 400, and power switched on. It took some time, be patient, not too much status messages shown, file system expanded, reboot and then the Raspberry PI OS screen appeared and the usual questions asked. Which HDMI port? It seems not to matter!
The automatic updating/upgrading took quite some time, but after another reboot, the Pi 400 was up and running. Subsequent boots are very fast compared to SD booting!
The SD card reader? Not required for the OS, free to use, with automatic mounting.


Audio, USB Audio and fight with Bluetooth
A desktop PC without audio is not done. The Pi 400 has standard audio via HDMI. Now HDMI monitors may have a loudspeaker, but not high quality.
HDMI to DVI does not support audio. Other PI’s have analog audio out, the PI 400 does not have this, and it is not a real loss, it is of mediocre quality).

 

 

So what options for audio do I have?
– a cheap and good quality USB Audio adapter. That works well, good stereo analog audio to the soundbar on my desk.
– Bluetooth audio. Connecting and pairing to my soundbar Bluetooth succeeded, VLC plays audio fine.

But Chromium refuses to play. Known bug it seems with the current version of Chromium, I read more complaints on the forum. Note that I did not install any additional Bluetooth component, PulseAudio seems to break any chance of audio. Builti-n Bluetooth support is enough (but not pleasant to work with, as on all OS’es it seems). Chromium will hopefully be repaired soon.

Update: Fixed in New Raspberry Pi OS release — December 2020

Bluetooth sound now works for all web sites I tried, youtube, radio stations.
Do the update as https://www.raspberrypi.org/blog/new-ra … mber-2020/ describes.

Camera, USB webcam

A desktop PC without a webcam is not done, So I searched in my drawers and found an older USB Webcam. Not the best quality, but it shows a normal USB webcam works fine on the Pi 400.

 

 

 

 

 

This requires an additional software install, in a terminal type:

sudo apt install fswebcam.

A simple test with a webcam testpage showed it functions fine. as shown in the photo.


Overclocking
The Pi 400 runs un 1.8GHz and stays cool with that large metal cooling plate.
Overclocking is not really necessary, but some extra is always welcome. And the Pi stays just as cool!
Stay with recommended values not violating warranty:, perform the following in a terminal

sudo nano /boot/config.txt

Change the line with arm_freq to:

arm_freq=2000

Add the line

over_voltage=6

and reboot.


File Manager, access my Windows and Synology network shares
My network is made up of many systems. My main workstation is a power Windows 10 notebook with more screens. Further I ahev many Raspberry Pi’s, ESP8266, ESP32 nodes around. Arduino and propriety media servers, Chromecast. Several security camera’s served by Synology . My main storage is made up of two Synology NAS servers

So I took a look at what the Raspberry Pi OS Filemanager offers, And I was pleasantly surprised with the current state and posiibilities!

First I unleashed the ‘hidden’ things:


Uncheck:
Display simplified user interface and menus
Check
– Filesystem root
– Devices
– Networks
– Volume and Mounts


Now when I click on Networks in the left folderview, I see part of my network, the two Synology NAS systems.

Clicking on the Synology NAS (File Sharing) gives a list of shares on this NAS server (SMB network)

Now the file manager asks for username and password (and workgroup name). It offers to remember those, but most of the time it forgets anyway.
If you make a mistake in name or password, the fields are just cleared, no error appears.

Now you see the folders in the share and can work with the files. Depending on share and user also writing, determined by the NAS admin.


When you choose the Windows Network, nothing is shown but an empty panel and in the top field the text ‘smb:///’. Change smb:/// to smb://<computername>, where <computername> is the name of a Windows PC.
In my case it is smb://asusho


The shares of the Windows PC are now shown, select one and the usual username password form is shown. Fill in a LOCAL user on the Windows PC, which has access to the share you want. The usual Windows username, an email address, does not work. Create if needed a local Windows user and grant access to the share.


If all checks out, you have now access to the share, in this case the data disk of my Windows PC asusho.


GPIO connector
The well known 40 pin GPIO connector is available, on the backside. Now that is not too handy for the many HATs available.

I expect to see some aftermarket solutions for that with cables and cases!

A short 40 pin flatcable female-female, e,g, as supplied with a T-Cobbler makes it easy to connect to a breadboard as seen in the photo.

Note that these 40pin connecters have notches on the top, which fit nicely in the Pi 400 and the T-Cobbler connector. So no mistakes in orientation may be made, as with the other Pi’s.

3.5 Inch RPi Display Touch – XPT2046 (480×320) – Install

https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=178443&p=1699671&hilit=xpt2046#p1699671