Hi,
In my attic I have a bananaPi running as server. I also have pimatic running on it. The bananaPI runs bananian which is a bare-bones headless debian OS for the bananapi giving me way more memory and a much faster system than a raspbian setup. Unlike Raspbian it doesn’t come with the appropriate tools/software to read/write from/to our GPIO pins (the first 26 pins are identical to those on a RPi B ).
So we need to do some manual tricks to get our sensors and the like running. This HowTo describes that for a ds18b20 on (default) gpio pin 4. Other devices on gpio pin 4 should work identical.
Note: I created a user next to the root user. I avoid using the root user as much as possible. In this HowTo I will switch to the root user and back.
In case we do not have the neccessary compile/build tools installed yet we need to install some:
sudo apt-get install build-essential pkg-config gcc git make
We also need libusb:
sudo apt-get install libusb-1.0 libusb-dev
Now we will install the sunxi tools. We need these to modify the script.bin file:
git clone https://github.com/linux-sunxi/sunxi-tools
cd sunxi-tools
make
Now we need to modify the script.bin file which resides in our boot partition which is normally hidden after boot. (As my bananapi runs completely of a sata-harddisk only using a minimal bootloader from a minimal SD-card, I have an /opt folder not part of a normal install)
I switch to root user, mount the bootloader partition from the sd-card, switch into the sunxi-tools folder (on my HD) and convert the binary script.bin file to an ascii text file:
su -
mount -o,rw /dev/mmcblk0p1 /mnt
cd /opt/software/sunxi-tools
./bin2fex /mnt/script.bin script.fex
Now we will modify our created ascii text script.fex file:
nano script.fex
by adding at the bottom:
[w1_para]
gpio = 4
(Save and close.)
Now we will convert back and unmount the bootloader partition.
./fex2bin script.fex /mnt/script.bin
umount /mnt
If not done yet, add your modules to the /net/modules file and reboot afterwards:
# modules for the gpio and the DS18B20 sensor
w1-gpio
w1-therm
After boot you will NOT see the modules loaded if you do a lsmod, but it will still function.
Get the ID of your sensor:
cd /sys/bus/w1/devices
ls -l
totaal 0
lrwxrwxrwx 1 root root 0 okt 3 15:45 28-031562c01eff -> ../../../devices/w1_bus_master1/28-031562c01eff/
lrwxrwxrwx 1 root root 0 okt 3 16:26 w1_bus_master1 -> ../../../devices/w1_bus_master1/
Now add a device to your pimatic config.json:
{
"id": "ds18b20-bpi",
"name": "ds18b20 example",
"class": "DS18B20Sensor",
"hardwareId": "28-031562c01eff",
"interval": 180000
},
This did it for me.
Hope it works for you as well.