Skip to content
Archive — this guide belongs to a discontinued product. Details and links may be out of date.

COC Installation V1

For beginners we recommend a fresh system using our SD image of Raspbian! This image contains all the things described below. Be warned that any further update of FHEM or Debian will overwrite eventually our patched kernel and config files for FHEM - making COC look dead or not functional! So check things below after updating!

COC board pressed onto the Raspberry Pi header, annotated "no gap" Make sure there is no gap left. Press the two PCB so you can hear/feel a litlle “click” …

At the 512MB version board of RPi the connector handles have become very big. The hole provided at the COC is 2.9mm only!! Therefor the handle needs to be removed: Removing the connector handle: widen it first, then pull it off UPDATE: The newest RPi charge even uses a 3mm thick connector. This is about 0.1mm too big for the slot at COC. In case you got one of those RPis you must rasp away some micrometers of COCs slot to make it fit.

To free-up the serial line used by COC remove any references to ttyAMA0 in:

  • /etc/inittab - comment or delete: T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
  • /boot/cmdline.txt - and reboot!

RPI3 + JESSIE:

add to: /boot/config.txt dtoverlay=pi3-miniuart-bt

change: /boot/cmdline.txt dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

commands to issue: sudo systemctl stop serial-getty@ttyAMA0.service sudo systemctl disable serial-getty@ttyAMA0.service sudo reboot

edit and add in /etc/init.d/fhem start)-section:

start)
echo "resetting 868MHz extension..."
if test ! -d /sys/class/gpio/gpio22; then echo 22 > /sys/class/gpio/export; fi
if test ! -d /sys/class/gpio/gpio27; then echo 27 > /sys/class/gpio/export; fi
echo out > /sys/class/gpio/gpio22/direction
echo out > /sys/class/gpio/gpio27/direction
echo 1 > /sys/class/gpio/gpio27/value
echo 0 > /sys/class/gpio/gpio22/value
sleep 1
echo 1 > /sys/class/gpio/gpio22/value
sleep 1
(old code follows)

edit/add to /etc/fhem.cfg: for a Raspberry Pi:

define COC CUL /dev/ttyAMA0@38400 1234

for a Banana Pi:

define COC CUL /dev/ttyS2@38400 1234

Those devices are connected to RPis I2C bus. Therefor you need to update the kernel & modules. Either you just take our pre-compiled kernel or you compile yr own sources after you applied our patches. Our kernel will also take care of different RPi board revisions and map the I2C pins on extensions header always to bus 0.

The RPi stores its time (by default without RTC) by using /sbin/fake-clock. You should add a line in save-condition:

if test -e /dev/rtc0; then hwclock -w; fi

This will sync the hwclock at least on a reboot or shutdown. Execute hwclock -w manually i.e. after a ntp-sync. For the sake of the environment, the COC is equipped with a super-capacitor which will last for at least 12 hours of backup once fully charged. DO NOT INSERT A BATTERY - because you need to disable the RTC charger first!

Be aware that culfw on the COC already uses the DS2482-Onewire chip in a CUNO-fashion. Therefor you should not load the ds2482.ko module unless you have disabled HAS_ONEWIRE in culfw or upload the COC.radio_only.hex firmware - see below!

echo “resetting 868MHz extension…” if test ! -d /sys/class/gpio/gpio17; then echo 17 > /sys/class/gpio/export; fi if test ! -d /sys/class/gpio/gpio18; then echo 18 > /sys/class/gpio/export; fi echo out > /sys/class/gpio/gpio17/direction echo out > /sys/class/gpio/gpio18/direction echo 1 > /sys/class/gpio/gpio18/value echo 0 > /sys/class/gpio/gpio17/value sleep 1 echo 1 > /sys/class/gpio/gpio17/value sleep 1

Make sure you stop fhem or any other program occupying ttyAMA0 first!

echo “calling COC bootloader…” if test ! -d /sys/class/gpio/gpio17; then echo 17 > /sys/class/gpio/export; fi if test ! -d /sys/class/gpio/gpio18; then echo 18 > /sys/class/gpio/export; fi echo out > /sys/class/gpio/gpio17/direction echo out > /sys/class/gpio/gpio18/direction echo 0 > /sys/class/gpio/gpio18/value echo 0 > /sys/class/gpio/gpio17/value sleep 1 echo 1 > /sys/class/gpio/gpio17/value sleep 1 echo 1 > /sys/class/gpio/gpio18/value

avrdude -p atmega1284p -P /dev/ttyAMA0 -b 38400 -c avr109 -U flash:w:COC.hex

COC.hex has support for Onewire compiled in. If you bought a “radio only” COC you must use COC.radio_only.hex instead.

For un-watched operation its recommended to utilize the watchdog:

sudo apt-get install watchdog sudo vi /etc/default/watchdog #edit: watchdog_module=“bcm2708_wdog” sudo vi /etc/watchdog.conf #uncomment: max-load-1 = 24 #uncomment: watchdog-device = /dev/watchdog sudo /etc/init.d/watchdog start

Test: : (){ :|:& };: