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

RPi + LibreELEC Rpi 3 + Arduino + WS2812B

Discussion in 'Hardware Support' started by SGR-Samuel, 8 December 2019.

  1. SGR-Samuel

    SGR-Samuel New Member

    Messages:
    1
    Hardware:
    RPi3, +Arduino
    Hi All, really struggling to get this working,

    So I am using Hyperion and Libreelec 8.25, and have successfully installed Hyperion

    The data pin is on pin 6 for the Arduino Sketch, and it flashes red green and then blue twice when booting. After that it stops working. No response from the Hyperion App either.

    Arduino Sketch:

    #include "FastLED.h"

    // How many leds in your strip?
    #define NUM_LEDS 212

    // For led chips like Neopixels, which have a data line, ground, and power, you just
    // need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
    // ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
    #define DATA_PIN 6
    #define CLOCK_PIN 13

    #define COLOR_ORDER RGB

    // Adalight sends a "Magic Word" (defined in /etc/boblight.conf) before sending the pixel data
    uint8_t prefix[] = {'A', 'd', 'a'}, hi, lo, chk, i;

    // Baudrate, higher rate allows faster refresh rate and more LEDs (defined in /etc/boblight.conf)
    #define serialRate 460800

    // Define the array of leds
    CRGB leds[NUM_LEDS];

    void setup() {
    // Uncomment/edit one of the following lines for your leds arrangement.
    // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
    FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
    // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);

    // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);

    // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
    // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);

    // initial RGB flash
    LEDS.showColor(CRGB(255, 0, 0));
    delay(500);
    LEDS.showColor(CRGB(0, 255, 0));
    delay(500);
    LEDS.showColor(CRGB(0, 0, 255));
    delay(500);
    LEDS.showColor(CRGB(0, 0, 0));

    Serial.begin(serialRate);
    Serial.print("Ada\n"); // Send "Magic Word" string to host

    }

    void loop() {
    // wait for first byte of Magic Word
    for(i = 0; i < sizeof prefix; ++i) {
    waitLoop: while (!Serial.available()) ;;
    // Check next byte in Magic Word
    if(prefix == Serial.read()) continue;
    // otherwise, start over
    i = 0;
    goto waitLoop;
    }

    // Hi, Lo, Checksum

    while (!Serial.available()) ;;
    hi=Serial.read();
    while (!Serial.available()) ;;
    lo=Serial.read();
    while (!Serial.available()) ;;
    chk=Serial.read();

    // if checksum does not match go back to wait
    if (chk != (hi ^ lo ^ 0x55))
    {
    i=0;
    goto waitLoop;
    }

    memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));
    // read the transmission data and set LED values
    for (uint8_t i = 0; i < NUM_LEDS; i++) {
    byte r, g, b;
    while(!Serial.available());
    r = Serial.read();
    while(!Serial.available());
    g = Serial.read();
    while(!Serial.available());
    b = Serial.read();
    leds.r = r;
    leds.g = g;
    leds.b = b;
    }
    // shows new values
    FastLED.show();
    }

    Config from Hyperion:
    // Automatically generated configuration file for Hyperion ambilight daemon
    // Notice: All values are explained with comments at our wiki: wiki.hyperion-project.org (config area)
    // Generated by: HyperCon (The Hyperion deamon configuration file builder)
    // Created with HyperCon V1.03.3 (22.10.2017)

    {
    // DEVICE CONFIGURATION
    "device" :
    {
    "name" : "MyPi",
    "type" : "adalight",
    "output" : "/dev/ttyUSB0",
    "delayAfterConnect" : 10,
    "colorOrder" : "rgb"
    },

    // COLOR CALIBRATION CONFIG
    "color" :
    {
    "channelAdjustment" :
    [
    {
    "id" : "default",
    "leds" : "*",
    "pureRed" :
    {
    "redChannel" : 255,
    "greenChannel" : 0,
    "blueChannel" : 0
    },
    "pureGreen" :
    {
    "redChannel" : 0,
    "greenChannel" : 255,
    "blueChannel" : 0
    },
    "pureBlue" :
    {
    "redChannel" : 0,
    "greenChannel" : 0,
    "blueChannel" : 255
    }
    }
    ],
    "temperature" :
    [
    {
    "id" : "default",
    "leds" : "*",
    "correctionValues" :
    {
    "red" : 255,
    "green" : 255,
    "blue" : 255
    }
    }
    ],
    "transform" :
    [
    {
    "id" : "default",
    "leds" : "*",
    "hsl" :
    {
    "saturationGain" : 1.0000,
    "luminanceGain" : 1.0000,
    "luminanceMinimum" : 0.0000
    },
    "red" :
    {
    "threshold" : 0.0000,
    "gamma" : 2.5000
    },
    "green" :
    {
    "threshold" : 0.0000,
    "gamma" : 2.5000
    },
    "blue" :
    {
    "threshold" : 0.0000,
    "gamma" : 2.5000
    }
    }
    ],
    // SMOOTHING CONFIG
    "smoothing" :
    {
    "type" : "linear",
    "time_ms" : 200,
    "updateFrequency" : 20.0000,
    "updateDelay" : 0
    }
    },

    // NO V4L2 GRABBER CONFIG
    // FRAME GRABBER CONFIG
    "framegrabber" :
    {
    "width" : 64,
    "height" : 64,
    "frequency_Hz" : 10.0,
    "priority" : 890
    },

    // BLACKBORDER CONFIG
    "blackborderdetector" :
    {
    "enable" : true,
    "threshold" : 0.0,
    "unknownFrameCnt" : 600,
    "borderFrameCnt" : 50,
    "maxInconsistentCnt" : 10,
    "blurRemoveCnt" : 1,
    "mode" : "default"
    },

    // BOOTEFFECT CONFIG
    "bootsequence" :
    {
    "color" : [0,0,0],
    "effect" : "Rainbow swirl fast",
    "duration_ms" : 3000,
    "priority" : 700
    },

    // JSON SERVER CONFIG
    "jsonServer" :

    And the Log:

    sh in: Hyperion Ambilight Deamon (513)
    ssh in: Version : V1.03.5 (GitHub-66bef6b/fb413cd-1566231780
    ssh in: Build Time: Aug 25 2019 10:39:29
    ssh in: INFO: Selected configuration file: /storage/.config/hyperion.config.json
    ssh in: HYPERION INFO: ColorTransform 'default' => [0; 211]
    ssh in: HYPERION INFO: ColorCorrection 'default' => [0; 211]
    ssh in: HYPERION INFO: ColorAdjustment 'default' => [0; 211]
    ssh in: LEDDEVICE INFO: configuration:
    ssh in: {
    ssh in: "colorOrder" : "rgb",
    ssh in: "delayAfterConnect" : 10,
    ssh in: "name" : "MyPi",
    ssh in: "output" : "/dev/ttyUSB0",
    ssh in: "type" : "adalight"
    ssh in: }
    ssh in: Opening UART: /dev/ttyUSB0
    ssh in: Device blocked for 10 ms
    ssh in: INFO: Creating linear smoothing
    ssh in: HYPERION (CS) INFO: Created linear-smoothing(interval_ms=50;settlingTime_ms=200;updateDelay=0
    ssh in: EFFECTENGINE INFO: 27 effects loaded from directory /storage/hyperion/effects
    ssh in: EFFECTENGINE INFO: Initializing Python interpreter
    ssh in: INFO: Hyperion started and initialised
    ssh in: INFO: Boot sequence 'Rainbow swirl fast' EFFECTENGINE INFO: run effect Rainbow swirl fast on channel 0
    ssh in: BLACKBORDER INFO: threshold set to 0 (0)
    ssh in: BLACKBORDER INFO: mode:default
    ssh in: started
    ssh in: INFO: Json server created and started on port 19444
    ssh in: INFO: Proto server created and started on port 19445
    ssh in: DISPMANXGRABBER INFO: Display opened with resolution: 1920x1080
    ssh in: BLACKBORDER INFO: threshold set to 0 (0)
    ssh in: BLACKBORDER INFO: mode:default
    ssh in: INFO: Frame grabber created and started
    ssh in: Device unblocked
    ssh in: BORDER SWITCH REQUIRED!!
    ssh in: CURRENT BORDER TYPE: unknown=0 hor.size=0 vert.size=0
    ssh in: EFFECTENGINE INFO: effect finished
    ssh out: cat /storage/logfiles/hyperion.log
    ssh in: Hyperion Ambilight Deamon (513)
    ssh in: Version : V1.03.5 (GitHub-66bef6b/fb413cd-1566231780
    ssh in: Build Time: Aug 25 2019 10:39:29
    ssh in: INFO: Selected configuration file: /storage/.config/hyperion.config.json
    ssh in: HYPERION INFO: ColorTransform 'default' => [0; 211]
    ssh in: HYPERION INFO: ColorCorrection 'default' => [0; 211]
    ssh in: HYPERION INFO: ColorAdjustment 'default' => [0; 211]
    ssh in: LEDDEVICE INFO: configuration:
    ssh in: {
    ssh in: "colorOrder" : "rgb",
    ssh in: "delayAfterConnect" : 10,
    ssh in: "name" : "MyPi",
    ssh in: "output" : "/dev/ttyUSB0",
    ssh in: "type" : "adalight"
    ssh in: }
    ssh in: Opening UART: /dev/ttyUSB0
    ssh in: Device blocked for 10 ms
    ssh in: INFO: Creating linear smoothing
    ssh in: HYPERION (CS) INFO: Created linear-smoothing(interval_ms=50;settlingTime_ms=200;updateDelay=0
    ssh in: EFFECTENGINE INFO: 27 effects loaded from directory /storage/hyperion/effects
    ssh in: EFFECTENGINE INFO: Initializing Python interpreter
    ssh in: INFO: Hyperion started and initialised
    ssh in: INFO: Boot sequence 'Rainbow swirl fast' EFFECTENGINE INFO: run effect Rainbow swirl fast on channel 0
    ssh in: BLACKBORDER INFO: threshold set to 0 (0)
    ssh in: BLACKBORDER INFO: mode:default
    ssh in: started
    ssh in: INFO: Json server created and started on port 19444
    ssh in: INFO: Proto server created and started on port 19445
    ssh in: DISPMANXGRABBER INFO: Display opened with resolution: 1920x1080
    ssh in: BLACKBORDER INFO: threshold set to 0 (0)
    ssh in: BLACKBORDER INFO: mode:default
    ssh in: INFO: Frame grabber created and started
    ssh in: Device unblocked
    ssh in: BORDER SWITCH REQUIRED!!
    ssh in: CURRENT BORDER TYPE: unknown=0 hor.size=0 vert.size=0
    ssh in: EFFECTENGINE INFO: effect finished
    ssh in: JSONSERVER INFO: New connection
    ssh in: BLACKBORDER INFO: threshold set to 0 (0)
    ssh in: BLACKBORDER INFO: mode:default


    Can any advise anything?

    Thank you :)