Autor Thema: working: integrated CUL for Arduino Yun, +FHEM, +Homekit  (Gelesen 216 mal)

Offline core_c

  • New Member
  • *
  • Beiträge: 5
Hi all,
We managed to (slightly) change the nanoCUL software so it runs on an Arduino Yun's AVR atmega32u4. No more need for a USB-connected CUL. We created a shield with a 868MHz CC1101 radio, a relay to control a boiler/heater and we'd added a 128x32 OLED (mainly because it looked cool).
The relay and OLED are controlled by the AVR, so that code has been added to the original culfw software. We added 2 new commands to control the additional hardware.
FHEM runs on the Linux side of the Yun. FHEM and CUL communicate over the only available serial connection: serial1.
All this was working pretty quickly. However, to add Homekit support, we had to do a lot of trouble. The obvious solution (fhem-homebridge) was too slow to make the Yun pair in time with an iOS device. It took 7 minutes for just the pair-setup procedure to finish. The pair-verify procedure also took several minutes to complete. The Yun is not fast enough to script it's way through all the crypting needed to make Homekit work.
Then we found PHK. After lots of fiddling with the code, so we could test it, we got it running: and it was fast: Fast enough to be able to pair with Homekit. => Pairing is performed in a flash.
Meanwhile we've rewritten the original PHK quite a lot :)  The code we now have, is still "personal": meaning, we just added support for the devices we use (MAX! themostats, our yunCUL, our relay and the OLED). We did not need more, so we did not add more.. simple.
It all works wonderful now. We control MAX! devices, serve Homekit requests, and control a heater from FHEM (PWM/PWMR).
It rocks!

If there is interest, we could publish information.
Gefällt mir Gefällt mir x 1 Liste anzeigen

Offline Ranseyer

  • Sr. Member
  • ****
  • Beiträge: 920
    • Homepage
Antw:working: integrated CUL for Arduino Yun, +FHEM, +Homekit
« Antwort #1 am: 13 März 2018, 17:11:07 »
Information is always good. Thanks for sharing...

Gesendet von meinem VTR-L09 mit Tapatalk

FHEM mit FTUI. Homematic-Funk für Thermostate und Licht. MySensors als Basis für eigene HW.
Zentrale ist der MAPLE-CUL mit RFM69+HModUART-AddOn.
Doku zu meinen Projekten. Platinen falls verfügbar gerne auf Anfrage.
Gefällt mir Gefällt mir x 1 Liste anzeigen

Offline RaspiLED

  • Hero Member
  • *****
  • Beiträge: 1402
  • Es begann alles so klein ;-)
Antw:working: integrated CUL for Arduino Yun, +FHEM, +Homekit
« Antwort #2 am: 13 März 2018, 20:03:06 »
Yes, please share ;-)
Regards, Arnd

Raspi2 mit FHEM, CUL, Signalduino, MySensors, HomeBridge, Presence, Bravia, ...
Raspberry Pi mit FHEM, CUL, Signalduino, MySensors, HomeBridge, Presence, WifiLight2, Bravia, ...

Offline core_c

  • New Member
  • *
  • Beiträge: 5
Antw:working: integrated CUL for Arduino Yun, +FHEM, +Homekit
« Antwort #3 am: 16 März 2018, 00:29:43 »
I am creating a list of how to setup an Arduino Yun. We've been working on this project from october 2017 until januari 2018. There are things done that i can not recall. Most of those things have to do with cross-compiling (install a header-file here, add a library to the kernel.. that sort of things). We compiled the latest LEDE 17.01.4 on an Apple PPC, running Debian. We tried to keep the kernel as small as neccessary (at first) to stay under the original Yun's 1280K limit. Later we abandoned that, because to make it work with Homekit support, our kernel was growing >1280K.
We did make a Fritzing design with the connections, but that design is not entirely complete (the relay is not added to that Fritzing file). However, all other connections are accurate (the cc1101 radio, the oled, a logic-level converter).
The culfw software has been adjusted just a little bit (we used the nanoCUL software as a blueprint), to make it work on the Yun. Just a few files were changed, and 2 files were added (the oled.h and .cpp files). We use the I2C pins for the OLED now, and relocated the radio Rx INT to the Yun's INT.6 (that is pin 7 on the Yun). The culfw software was compiled on a VM running ubuntu (but i even managed to compile it on the Yun, using yun-gcc).
We also have some information about how to flash the Yun (AVR & AR). Our kernel does not fit in the original Yun, so we had to upgrade the bootloader with a newer uboot, so we could flash a kernel that is >1280K. (in fact, any size kernel).
I could just upload our files, but on an original Yun, it would not simply work. We selected the appropriate kernel libraries/files in our custom compiled LEDE. It took a while to systematically find out what was needed to get a kernel that has the minimal needed setup. Nevertheless, it would be cool for people to see the main program files we made: main.cpp, HAP.h, HAP.cpp, FHEM.h & FHEM.cpp.  If your kernel is correct, those files compile to a single program. Run the program (perhaps as a service), run FHEM (You need to extroot a Yun for that), and Homekit requests are handled by the program.
The program is made for our needs. And i do not want to give support to make it work on Your Yun. You have to find out yourself.  Anyway..   Here's a zip with some files.

Offline core_c

  • New Member
  • *
  • Beiträge: 5
flashing a Yun the right way..
« Antwort #4 am: 16 März 2018, 00:39:07 »
Here is an old from our private github.
It is old because we first tried to make Homekit work using FPU-emulated kernel, NodeJS, fhem-homebridge, nxhack repository, etc..
We succeeded in that, we got it all cross-compiled, got it all running, but the Yun was too slow to pair in time with Homekit.
But the information in the readme about flashing a bootloader and firmware is of interest. <<

Offline core_c

  • New Member
  • *
  • Beiträge: 5
Fritzing yunCUL..
« Antwort #5 am: 16 März 2018, 00:44:41 »
Here is our (incomplete) Fritzing layout..
Remember, the relay is not connected.
The CC1101 868MHz radio, logic level converter & OLED connections are accurate.

Offline core_c

  • New Member
  • *
  • Beiträge: 5
UJE yunCUL. FHEM + Homekit + OLED
« Antwort #6 am: 16 März 2018, 01:02:24 »
Here are 2 photos of our yunCUL prototype:

and i attached our yunCUL software.

I would like to thank the people who provided us with the information we needed to make it all work:
nxhack Hirokazu MORIKAWA (cheat sheet and Yun related stuff)
etwmc Wai Man Chan (PHK)
justme-1968 (homebridge-fhem)
and of course the makers of FHEM

EDIT!:  Fast Frank   of course i thank You too..   we did it together.
I don't have to say it to You, but i must mention your name as well.  Thanks mate!
« Letzte Änderung: 16 März 2018, 01:25:24 von core_c »