User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

This page shows how to make a new fresh image with Raspbian+Domoticz+firewall+backup.

If you prefer to purchase a high quality SD already programmed, visit our shop.

Writing an image for Raspberry

We're proposing a quick solution to install a pre-configured image of Raspbian for Raspberry PI3 or PI4, completed with latest Domoticz software and configured to preserve MicroSD flash device (flash cannot be safely written more than 10000 times) and exporting a weekly backup that can easily restored in case of problems.

This image was tested on both Raspberry PI3 and Raspberry PI4 hardware, and uses the last Raspbian Buster distribution.

Flashing this image in a microSD, you are immediately ready to configure your Domoticz devices from the web interface.

Image is available at http://dl.creasol.it/raspberry_domoticz_0x12345678.fsa and can be installed from linux or another raspberry using the raspberry_domoticz.sh script; Windows users can use putty to connect their raspberry by SSH protocol, and winscp or filezilla to transfer files between their windows PC and raspberry. Linux users can use their PC to make the copies.

Features

  • Works with both Raspberry PI4 and Raspberry PI3
  • Raspbian Buster + a recent version of Domoticz
  • Optimized to reduce writing on flash: /tmp and /var/log are in ramfs, not SD, and swap is disabled. Domoticz temporary files are written in /tmp, not in SD
  • Firewall with iptables/netfilter, that can be configured editing /usr/local/sbin/myfirewallpi.sh
  • Backup that automatically create an incremental backup of files changed;  one day per week do a full backup and one day per month do a image creation; backup can be easily exported to an attached USB hard disk or NAS (FTP or CIFS).
  • Domoticz is partially configured with some devices and with Creasol Dombus plugin already installed (Domoticz plugin to use Creasol DomBus devices attached to the Raspberry by a RS485 serial bus).

Extracting the image to a microSD

Connect the microSD to a Linux computer or to Raspberry (using a USB memory reader).
Run the following commands to download the raspberry image from our website and extract it on the SD. Windows users can connect to their raspberry console using putty

#become root
sudo su -
#download the image creation/restore script
apt update
apt -y install curl
curl -o /usr/local/sbin/raspberry_domoticz.sh http://dl.creasol.it/raspberry_domoticz.sh
chmod 700 /usr/local/sbin/raspberry_domoticz.sh
#donwload the image
cd /
curl -o /raspberry_domoticz_0x12345678.fsa http://dl.creasol.it/raspberry_domoticz_0x12345678.fsa
#and now start the raspberry_domoticz.sh script
raspberry_domoticz.sh
 

then the raspberry_domoticz.sh script will guide you to write the image /raspberry_domoticz_0x12345678.fsa on a microSD connected to domoticz by a SD memory USB reader.

This is the output of raspberry_domoticz.sh script, in bold the text written by the user:

Would you like to create an image of the SD [SD => IMAGE] (Y/n/ctrl-c)

n   (no, don't need to create an image, I need to extract an image!)

Would you like to write an image to new SD [IMAGE => SD] (Y/n/ctrl-c)

y   (yes! extract an image to SD)

========== List of attached devices: ==========
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 1 1.9G 0 disk
`-sda1 8:1 1 1.9G 0 part
mmcblk0 179:0 0 58.3G 0 disk
|-mmcblk0p1 179:1 0 400M 0 part /boot
|-mmcblk0p2 179:2 0 4.9G 0 part /
`-mmcblk0p3 179:3 0 24.4G 0 part
Write the name of USB device where image have been placed (for example sda1)

mmcblk0p2  (write the name of device corresponding with root filesystem, where the image was downloaded, or the device containing the image, for example a usb drive)

========== List of files in the selected device ==========
total 508712
....
-rwxr-xr-x 1 root root 520823743 Feb 26 17:39 raspberry_domoticz_0x12345678.fsa
drwx------ 4 root root 4096 Feb 26 17:37 root
...
Write the image filename

raspberry_domoticz_0x12345678.fsa

========== List of attached devices: ==========
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 1 31.1G 0 disk
`-sda1 8:1 1 31.1G 0 part
mmcblk0 179:0 0 58.3G 0 disk
|-mmcblk0p1 179:1 0 400M 0 part /boot
|-mmcblk0p2 179:2 0 4.9G 0 part /mnt/img
`-mmcblk0p3 179:3 0 24.4G 0 part
Write the name of FLASH device to be written (example sdb)

sda  (disk device connected to raspberry or PC, with the microSD card)

If you want to translate texts of raspberry_domoticz.sh in a different language, just modify the script adding the corresponding lines text[LANG,NUMBER] : it's very intuitive. Please send to This email address is being protected from spambots. You need JavaScript enabled to view it. the modified script and your name, so we can publish your improvements.

Access and configuring Raspberry with the programmed image

These are the default credentials for this image:
linux user: pi , password: arangingenni
linux user:root , password: geriandallse
domoticz user: domoticz , password: creasol

It's recommended to change these default passwords!!

Starting raspberry with this image, it will get network configuration from your DHCP server (router), so you can connect it by the browser at url like http://192.168.1.123:8080 (check your dhcp server to get the IP address assigned to raspberry, or do a network scan of your LAN). If you connect raspberry from 192.168.*.* or 172.16.*.* or 10.*.*.* networks, no authentication is required.
Also, ssh service is enabled, so you can enter secure shell (using ssh, putty or any other ssh client) as user pi or root.

How to create an image from Raspberry SD

We've written the bash script raspberry_domoticz.sh (see above) that permits to save a copy of Raspberry memory to a USB drive, and also create new SD with the content of a saved image.

This is useful because:

  1. flash memory cannot be written forever: normally each flash cell can be written up to 10000-100000 times. The proposed image is optimized to limit SD writes.
  2. it's always a good idea to have a backup of the running raspberry, so in case of problem it's possible to restore system from an old image
  3. maybe you need to clone an existing SD and keep images on your PC or NAS

Features:

  • images are compressed... it's stupid to have a 16GB image for a 16GB almost-empty SD !!
  • images can be restored on different SD sizes, so it's possible to use the same image to write SD card with 32GB size or 8 GB size as well
  • creating and restoring an image is really fast, in comparison to other systems

Unfortunally, this system does not work in Windows, but... who are still using windows at these days? Everything is moving to Linux! Android is Linux. Rasbian is Linux. Your routers, access points, TV most probably use Linux operating system! ;-)

 

Frequently Asked Questions FAQ

Some useful commands

ps ax |grep domoticz  : lists all active processes showing only the ones with name domoticz

netstat -lnp |grep domoticz : shows the TCP/UDP ports used by domoticz (normally it uses the port 8080)

lsusb : lists devices connected to USB. lsusb -v shows details on USB devices

How to configure raspberry GPIOs

With this raspbian image, GPIOs can be configured editing /etc/rc.local file and setting the needed gpio as out (if output), in if input, or both if bidirectional.

#/etc/rc.local file
 
#setting gpio using wiringpi tool:
#syntax: gpio export GPIONUMBER out|in|both to set as output, input or I/O
gpio export 24 out # Set as output.
gpio export 23 out 
gpio export 22 out
gpio export 27 out
gpio export 18 out 
gpio export 17 out 
gpio export 25 out #lightOut2
gpio export 8 out #lightOut3
gpio export 7 out #lightOut4
gpio export 12 out #lightOut1

After edited, type /etc/rc.local to reload the script.

How to update the Creasol DomBus plugin to the latest version?

Just type, from root shell, the command creasoldombus_update.sh

Other questions?

For any questions, please check the web and/or write email to linux @ creasol.it and we'll try to put the answer to your questions on this section.

 

Need help about DomBus protocol and devices? join the DomBus channel on Telegram!

 

Pin It