1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED RPi4 + LibreElec 9 + Hyperion - Alpha 9 + WS2812B + IR-Receiver + UART + Pi-Hole

Discussion in 'Hyperion General' started by davieboy, 7 December 2020.

  1. davieboy

    davieboy Member

    Messages:
    31
    Hardware:
    RPi1/Zero, RPi2, RPi3
    Thought id chip in on this one as there are a lot of posts for advanced complicated setups with capture cards etc, I'm more of a minimal setup kinda guy that wants the lights to come on when kodi is in use and off when not and nothing else :bigsmile: so hopefully it may help others.

    I also thought about using the Ardrino route but the pi only has 1 purpose, to play media from a Emby Server so the onboard GPIO and smoothest Kodi wins and without a doubt Kodi runs way smoother on LibreElec than any distro build so going down they routes was a no no for me when i only need to run Kodi and PiHole so LibreElec with the docker addon from official repo for PiHole keeps the leanest meanest system for my needs.

    With the LED's attached and soldered, the Data wire went to pin 18 of the GPIO along with a 470 ohm resistor, Earth from the LED strip spliced to a GND pin on the GPIO.

    Clean install of Libreelec, then Hyperion install from here -> https://hyperion-project.org/thread...ec-x86_64-rpi-inoffiziell-unofficially.10463/

    After setting up the led's in Hyperion using the WS281X on RPi PWM everything is working sweet, I occasionally had black screen issues, so after setting the kodi gui to 720p solved all of that - lets be honest real 4k on a pi4 is still a few months away plus most of my media is 1080 anyway so it doesn't bother me and it will eventually be working out the box as development on all projects move forward.

    I changed the Platform Capture to DispmanX 740 x 480 pixel (width, height) @ 30Hz capture and it has made a huge difference on Video Drop Outs and the black screens i was getting especially after pressing a button when media was playing, previously the screen would go black and I had to press right to get to the stop button then hit ok (all during black screen) where as now it doesn't.

    Next thing was starting and stopping Hyperion, there may be easier ways than this but i was testing some things out and they worked first time so I just left them there.

    I Installed the following Addon in the official repos - Kodi Callbacks (to control Hyperion)

    Create 2 scripts in the /storage directory, i opted for

    start-hyperion.sh
    Code:
    #!/bin/bash
    systemctl start hyperion
    
    stop-hyperion.sh
    Code:
    #!/bin/bash
    systemctl stop hyperion
    
    Then in the Kodi Callbacks addon, I assigned Task 1 to execute the /storage/start-hyperion.sh script then in the Event section - Event: On screensaver deactivation and to run Task 1

    Same again for Task 2 but to execute the /storage/stop-hyperion.sh and on Event to activate Task 2 on screensaver Activation

    When I change source to kodi and press a button the lights come on, then when done as soon as the screensaver comes on the lights go off. :D

    One thing i have noticed is once Hyperion has been stopped, after a good few hours the first 2 led's on the strip light up, 1x is white and the other is green - no idea what it is but it must be coming from the pi somehow - if anyone knows please let me know :thumbsup:

    Hope this helps someone out as despite the occasional black screen or hiccup this is a very sweet project.

    Thanks to all the people who made this project possible as it's definitely brightened my media experience :LOL::thumbsup:
     
    Last edited: 20 January 2021 at 23:49
    • Like Like x 1
  2. davieboy

    davieboy Member

    Messages:
    31
    Hardware:
    RPi1/Zero, RPi2, RPi3
    Wow seems so long ago I wrote that and how simple that setup was, since then kodi call backs has been disabled and a ton of scripts are now in place and the setup is pretty much fully automated via the tv remote control, I might post a few as I fine tune them but as of now I thought i would shed some light on a subject that was driving me insane and with very few options of solving it without spending at least £20.

    GPIO IR Receiver - Yup its amazing that such a small device connected to 1 pin can have an adverse effect on Hyperion - Mainly the USB capture device, as you may or may not know, all the Pi's running Libreelec and possibly a distro may have a problem with GPIO IR receivers only when there is a USB device connected or in use and some earlier models suffered it from load on the Ethernet port.

    Long story short everything was working fine on my system until I switched over to USB capture for grabbing the other HDMI source, as soon as that happened the IR remote would lag and not respond to keypresses, very frustrating when the remote also controls the lights and the only way around it was to hit the webserver and manually enable or disable the Capture device when needed but where's the fun in that.

    Solution - Buy a Flirc at £20 or other USB IR receiver that may have kernel support or it may not or Build your own, I the spirit of DIY I opted for the latter and invested in a Leonardo Pro Micro, a small Arduino clone that uses a ATmega32u4 chip so basically it is detected as a usb keyboard - Happy days, soldered a few pins and connected the previous IR receiver that was causing problems and boom, lag free remote control operation, no more double jumps or locking up.

    Credit to the guy that wrote this guide http://www.andremiller.net/content/arduino-usb-infrared-remote-receiver-for-kodi I chose not to rig up the LED as the board lights up anyway and i wanted it as discreet as possible, used the testmode an got my remote codes and assigned all of them a keyboard key. Then i can remap them on the fly as required

    Reality now is I have 1 universal remote with 19 buttons that fully controls the TV and Raspberry Pi and Hyperion, One of my power buttons is now mapped to cycle the LEDDEVICE on and off depending on its current state.

    When Tv source button is pressed it cycles between the TV HDMI sources automatically enabling the V4L or GRABBER depending on the source that its going to, which in turn controls a relay that powers up the HDMI splitter as required, pretty sweet.

    When Tv power button is pressed similar script disables all devices and kills the HDMI splitter power supply and vice versa when powered on.

    Hope that can help someone facing similar problems at one point as it gave me serious problems when the USB capture device was enabled.
     
    Last edited: 20 January 2021 at 23:52
  3. davieboy

    davieboy Member

    Messages:
    31
    Hardware:
    RPi1/Zero, RPi2, RPi3
    RS-232 Serial Connection - Yes we are breaking out the big guns now, had this old serial port on the TV for years and never bothered with it until I noticed the section in the TV manual a few weeks ago when checking another setting, then the penny dropped that it may be useful so i took to ebay and ordered a USB To RS232 TTL UART PL2303HX Converter USB to COM Module Serial Cable Adapter as 15 pin vga like plugs are not cool and it was totally worth the £3, hooked the Earth, TX and RX pins up to the pi and enabled UART in the config.txt, quick reboot and connection to the TV successful, no more CEC commands that returned false, unknown or segmentation faults, direct access to check the status of the tv then control it as required, this thing can pretty much change any setting on the tv without having to look at the tv menu, providing your tv manual lists the codes as some don't so you may need to google it. But if you have it, its definitely worth a look if you want automation without going down the IOT route.

    :thumbsup:
     
    • Like Like x 1