RPi4 + LibreElec 9 + Hyperion - Alpha 10 + WS2812B + IR-Receiver + UART + Docker - Pi-Hole - Netdata

  • 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/t…ziell-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. This was not required after setting the GUI to 720, once GUI was set platform capture worked flawlessly at 1080


    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

    Bash
    #!/bin/bash
    systemctl start hyperion


    stop-hyperion.sh

    Bash
    #!/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: Resolved


    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:

  • 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/con…-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. Heres a vid of it in action


    External Content youtu.be
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.


    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.

  • 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:

  • So after recent setbacks I seem to have a stable setup now with a decent HDMI splitter - over 1 week with everything working as it should - result.


    The build has escalated since the original throw it together and see what works but couldn't be happier with Hyperion setup.


    I have been building schematics since day 1 mainly out of habit as it makes it easier to improve and diagnose faults later on down the line, now that I have checked the completed circuit I will share it. High Res pic attached


    After doing the final tests the overall power consumption is way lower than expected, <5A total draw from everything so at least the Higher PSU future proofs the build for better LEDS in the future without having to rewire things - new strip and bigger fuse :).


    WS2812IC - is the LED's I ended up with, unsure if they are a cheaper rip off or what not but either way they are very bright and can light up the room, colours are decent, I plan to upgrade for better LEDS with 2 data lines when TV is due a replacement. but for the sake of throwing some figures out there to explain the over exaggerated low fuse capacity on the circuit here is my findings ( I settled on 5A and will go 1 size up if it ever blows but TBH going by current consumption I cant see it happening and will probably reduce it down to 3A to protect the LED's).
    Using Hyperion remote i set a solid colour at full brightness on all LED's this resulted in a 1.6-2.0A overall current draw, When i set all the LEDS to White or as close to white as possible for the LED the total draw was 2.024A the biggest consumer was Red it consumed a huge 2.05A :LOL: so in Theory these can technically be powered by a semi decent 5v phone charger.


    With TV grabber, Platform capture or a Hyperion effect the total current draw ranged from as low as 0.5 - 2.05A depending on the amount of lit LED's at any given time but consumption is lower than the solid colour.


    Pi4 power consumption was very minimal during basic checks with 2 USB2 devices connected, 1 being video capture operating at 1280x720 and tested again with platform capture operating at 1920x1080 and at the very most the total Pi consumption was around the 1.6A when fully loaded but will spend a day running specific tests on that to see where it really demands the power, I have a sneaky suspicion that the official plug will only be required if using 2x USB HDD's while reading or writing to them but i will test that soon.


    I will post the scripts used once they are finished as there are a few issues i am resolving but overall its working great :thumbsup:


    Current Parts List:
    Pi4 model B rev 1.4
    3M WS2181B
    HDMI Splitter
    20w switching PSU
    2 chan 5v Relay Module
    Micro USB bare metal Lead + USB-C adapter
    USB2 1080p - Video Capture Card
    Ardruino Micro Pro + KY-022 IR Module
    USB - Serial RS-232


    Consumables:
    2 Core wire - 1.5mm - 2.5mm
    Heatshrink
    Glass Fuses
    Micro Toggle Switches
    Fuse Holder Leads


    Total Build cost of around £130 - bulk of that was for a decent HDMI splitter (around £45 inc delivery)



    HYPERION-WIRING.png

  • yes clear drawing and everything, you are much better in illustrator than me hahaha. :thumbsup:



    but i have a question, i see that you use a 5 volts 2 channel switch, does it switch with a remote on 433/868 Mhz or only trough GPIO output of raspi?
    reason i ask i see only 1 channel connected on K1 (IN1) NC connected but K2 isn't used (IN2) on NC toggle commands?
    i see that you connected 5 volts line to the ledstrip in parallel from the 2 channel swith and manual switch


    and whats the reason for the USB to rs232 enable_uart=1 in config.txt what can you do with this on your raspi exactly?



    nice setup and good 4k-splitter :D:classy:

  • 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



    thats the power and/or GPIO connected to the strip, every time the power comes on and feeds the strip thus Hyperion.NG boots up and steers the lights then its okay.
    the moment the signal is off ( data flow from GPIO isnt flowing anymore) Hyperion is off/raspi is off but ledstrip is still connected to 5 volts line GPIO and ground then following happens.


    with a little current you can test this with fingers, just touch the dataline :). So as long the ledstrip is connected to PSU ( 5 volts/GND ) and GPIO connected to data the minimal of current diffrence in line and/or GPIO will result in some/one/or string of leds wil light ( soft)



    the only thing you can do to resolve completely is cut of 5 volt feed, which you did already :biggrin:
    what you discribed is because the leds is really sensitive for sudden dataflow/current


  • Absolutely hopeless in Illustrator and that would involve a VM or worse - a reboot into windows :roflmao: plus Inkscape does everything


    Yes its a bit of both mate, My current setup still uses the manual switch and K2 is unused but as an extra Relay would be super useful for killing the supply to the ledstrip with minimal effort so i included it and faded them out and added a note to show its possible to peeps, you'd need to run a wire to the GPIO to control the switch though. When im building my case I will move to that exact setup because if the Pi is not there I don't need power to the strip and its the cleanest way i can see.


    Controlling the relay - a simple true or false, 1 or 0, high or low to that pin is all that's required so very flexible in how you use it, mine goes like this


    Remote Press -> Ir Receiver (detects hex code) -> Ardruino Micro PRO (takes hex and converts it to keyboard keystroke) -> Pi via USB (Pi thinks someone just pressed a physical keyboard button) -> Libreelec (takes that keyboard press and remaps it via keyboard.xml to run a script) = Some script just ran to pull the GPIO to activate or deactivate relay


    I explained the UART in a post above mate but ill give you a few real life examples of it in action, the config section is just to enable the interface - This would be the alternative method of connecting an Ardruino to a Pi without a USB cable, Instead of the Ardruino I am going straight into the TV's serial line as it allows full control of every single thing I can get to in my TV menu without having to go near a menu button, even picture modes and TV retune if required.


    I only use 2 HDMI sources so i have 1 button on the remote that i want to press to change to the other Input, I don't want to use the specific TV remote as its got too many buttons i don't use, plus then its maybe 3-5 presses to get to the source i want to be on, time is too precious for all that jazz ;), instead i control it all with my media centre remote. 1 press of 1 button, the sequence above happens, then it runs a script cycle_source.py Then the following happens...


    First it uses the serial line to find out exactly what source the TV is currently on,
    If its on kodi it enables the K1 relay via GPIO, Changes the TV source via Serial Line, disables the GRABBER and enables the V4L via Hyperion JSON-RPC


    If its on the other source it does the opposite - so each time button is pressed it cycles the source, capture devices and LEDS to suit.


    Another script runs on another button to enable or disable the LEDDEVICE depending on current state via JSON-RPC


    Another runs when TV power button is pressed and turned off we steal that code too and run another script to kill the relay and disable all the grabbers and LED's





    Yeah spot on mate, I solved that ages ago and forgot to remove it :LOL:

  • Current Connected Hardware
    Pi4 Model B rev 1.4

    WS2812B operated directly on the GPIO
    USB 2 Capture Card
    Ardruino Nano IR rEceiver via USB

    Current In Use Software

    LibreELEC - Kodi
    Hyperion Alpha 9
    Docker
    PIHole - Via Docker
    Netdada - Via Docker
    plus a few other odds and ends here and there - nothing major

    Notes

    Pi runs 24/7 - but there are 2 sections with no data, 1 is before the container was started and the other was a local Power Outage.
    Platform Capture plays media on Emby Server via Ethernet & Embycon Plugin - This reflects on the graphs below
    PiHole - This filters all traffic on the entire home network form the router through this single Pi.


    Main reason is to share the spec of it running as this is all on stock settings and the Pi is barely even breaking a sweat and because it may help others without having to trawl the internet., 8gb of RAM is overkill as i don't think i have ever saw it use more than 1GB at any given time thus far, but happy to see the CPU ticking over with plenty of resources available.


    Total CPU usage is around the 20% mark and when only running Kodi and PiHole it idles around 10%


    Gb Ethernet is handling the traffic like it should be so yeah, very happy with the stats, Even with Netdata running and collecting the stats the overall usage is fine and I see no reason to limit anything further.


    After looking at the specs I have came to the conclusion regarding the 720p USB capture problem I had, that the device may very well be capable of the 1080p but I dont think the LEDS are capable of coping with that much data so an LED upgrade will be in the pipeline.


    Enjoy

  • Changed it up again since last post, Instead of Adruino Nano as the MCU i went for a Wemos D1 Mini Clone running WLED - Everything else is still the same


    Grabbed a quick vid of it in action using the awesome Fluid Hue Sim Test 2 by MrPacMan36 on YouTube


    Few Things: Tv is 20-30 cm away from walls at side and around 80cm away from the walls in the middle but still effective, few leds on the pi & D1 light the wall up and if anything the camera over exaggerates the amount of light and the LED backlight


    Another is because GUI is limited to 720 to prevent the black screens Youtube add-on is limited to 720p ;(


    External Content youtu.be
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.

  • Hey peeps, just thought id post an update, system still rock solid and running like a champ - virtually maintenance free, cant say the same for the HDMI usb grabber though, ran into a few problems when using that where it would work fine then cut off, device would disappear, started happening every now and then and got more frequent, finally got fed up when it ran for 30 secs then cut off - wled would then displayed the default rainbow effect rather than the usb capture image - result being a fu@@ed usb capture card as internal grabber still worked flawlessly.


    Hyperion still as awesome as ever :thumbup:

  • davieboy

    Changed the title of the thread from “RPi4 + LibreElec 9 + Hyperion - Alpha 9 + WS2812B + IR-Receiver + UART + Docker - Pi-Hole - Netdata” to “RPi4 + LibreElec 9 + Hyperion - Alpha 10 + WS2812B + IR-Receiver + UART + Docker - Pi-Hole - Netdata”.
  • With recent events and 5 terminals open i thought id run a quick check on it all, system settings reporting over 110 days total uptime with 26 days system uptime due to power shutdown.


    with netdata being installed a while ago i thought id have the 4 month of stats and hoped to possibly see the video card failing but unfortunately i didn't enable db logging back then so only 30 days was possible X( but would of been cool to see


    System Recap: Pi4 switched on 24/7 running Libre-Elec 9.2.6 - Main Network media player - Hyperion using Internal Grabber @1080 - PiHole filters all home network traffic.


    Overall its been running buttery smooth - video capture card issue aside that was just more annoying than anything else, everything ticked over as expected, Hyperion just as stable as ever and never any need to do anything apart from toggle the desired capture device on or off when card was failing.


    Since upgrade to Alpha10 everything looks normal and functioning as expected except better ^^ time will tell though


    Media play is heavily used but specs seem above board, cpu avg of 40% utilization, avg load of 1.5 and runs at around 2gb ram, its hardly breaking a sweat so shouldn't need to worry about any cooling issues.


    nothing sticks out really except that entropy levels were getting a tad high, with it running pihole and LE using 4.19 kernal i investigated increasing it but with 3413 avail and maxing out at times @ 3200 there's not much that can be done without building a custom Libreelec - would be easier to install haveged if it was a distro but as its not plus it is not constantly maxing out i will leave it as it is.


    Sd card still has plenty of space and no signs of any bottlenecking so Netdata DB will be going ahead ^^ few screenshots of graphs attached


    LE 10 is making good progress to and hopefully there will be a stable version of that out soon - Hopefully be some nice eye candy changes to the UI :/

  • db engine quite easy to setup, if you already have netdata installed and have sufficient space on SD card and some spare ram its just a case of uncommenting a few lines in your netdata.conf


    Code
    memory mode = dbengine
    page cache size = 32


    use your current running setup to work out the next value based on what you decide here

    https://learn.netdata.cloud/do…e-needed-to-store-metrics


    then uncomment this line to your netdata.conf and change the value to the one you calculated

    Code
    dbengine multihost disk space = 1277


    The above should allow 3 months of logging, hopefully if it works and it will or should use 1277MB (just over 1gb) of storage space and consume ~200mb of ram while doing so


    ------------------------------------------------------------------


    If you dont have netdata installed and want to see your own stats you can easily install it


    If libreelec just install Docker from the official kodi addons and paste the code below

    if distro based os just follow the instructions at official docker docs for your distro https://docs.docker.com/engine/install/ once you select the distro and CPU architecture its a copy an paste of a few commands


    then a simple copy an paste the code below into the terminal then hit enter, docker pulls netdata in and sets it all up for you


    code below is good to go on LE but distro you should change the paths /storage/dockers to suit the rest should be ok



    Once its done its stuff run 1 more

    Code
    docker start netdata


    you should now be able to go to http://your-pi-ip-address:19999 and see your stats being collected :thumbup:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!