Communication issues between Raspberry and Arduino

  • Hi guys! I recently arrived here, I'm building an ambilight system and I need some help.
    I'm using Raspberry Pi 2 with LibreElec, Arduino Mega, Led strip 2812b EasyCap, and converter from HDMI to AV.
    I already set up the whole system, I'm able to connect to raspberry and take a screenshot on real time. Also I tested separately the strip with a little sketch and is all working.
    The problem comes when I connect the Raspberry and Arduino, I do not know if they are communicating at all, I do not see any response from the Leds. I think it may be because of incorrect sketch, I searched for a couple of them and none of it worked for me.
    I hope that you have the answer for this trouble, I'm so close to this project that I'm really exited but I got stuck on this.
    Thank you in advance!

  • Yes! I used the same sketch changing the normal parameters like: DataPin, LedCount, brightness(not relevant), the BaudRate left the same:9600, and nothing else! I don't know if I have to change something else in function of my setup.
    I understood that the other things were for a direct connection of the led strip with RaspBerry so I ignore thouse steps.

  • Okey, I apologize if I can not understand couple of things, my language is spanish.
    What I could understand was that I had to modify the file .json in the path /storage/.config and add this lines:
    "Gpio": 18,
    "Dmanum": 5,
    "Freq": 800000,
    "Pwmchannel": 0,
    Under "devices". Also I interpreted that I do not need to use Arduino.
    What I could not finish to understand is the part of the converter SPI to ws2812, For what I would need that? If I want the communication to be USB.
    Thank you.

  • If you go on to YouTube and type in search box " ambilight tv " you will find one by the Mad Scientist. He gives a complete tutorial how to make and do the ambilight tv, he has also given the arduino.ino software. This is the set up I'm using and it works for me.. hope it helps. Regards Bill

  • I think its a problem with the prefix.


    const char prefix[] = {0x41, 0x64, 0x61, 0x00, 0xD4, 0x81}; // Prefix at the start of the transmission
    char buffer[sizeof(prefix)]; // Temporary buffer for receiving the prefix data


    // to calculate your prefix, the first 4 bytes will never change: const char prefix[] = {0x41, 0x64, 0x61, 0x00, this never changes.
    // the next byte is equal to the number of LED - 1 --> (232-1)=231. 231 transformed in HEX. 231 in hex is E7 (use google)
    // the last byte is equal to the XOR value of the calculated value just above and 0x55 (byte just calculated (E7) XORED with 0x55) = B2 use this link http://xor.pw/? and in input 1 put 55 and in input 2 put your HEX value.
    :thumbup:

  • Okey, I had a crazy month with my job so now I'm resuming the project!
    First of all thank you for answering to this issue. Now I'll post my Hyperion configuration and the Sketch that I'm using.
    That Arduino sketch was downloded from https://hyperion-project.org/w…o-sketch-WS2801-to-WS2801 and change the followings lines:

    #include <Adafruit_NeoPixel.h>
    #define ADA_DATAPIN 6 // Datapin
    #define ADA_LEDCOUNT 254 // Number of LEDs used
    #define ADA_BRIGHTNESS 100
    Adafruit_NeoPixel strip = Adafruit_NeoPixel(ADA_LEDCOUNT, ADA_DATAPIN, NEO_RGB + NEO_KHZ800);
    #define MAX_PIXELS 254 // Number of pixels in the string


    I followd all the instructions of https://learn.adafruit.com/ada…-uberguide/best-practices and going to the next steps. I was able to
    run the standartest successfully and, like before, take screenshots with Raspberry Pi. When I connect via USB the Raspberry Pi and the Aruino
    and use the sketch that I'm posting I have no reaction in the system, still able to take screenshots but after the "Intro" that is set on the sketch
    nothing happends.


    That thing with prefix, I saw it before in other sketch and also calculated the values, but in this sketch I did't find it.

  • Ok.... none of this adds up !


    This is good because I know this will never work.


    Option 1) forget the arduino.
    If your Pi is HDMI connected to your screen.
    Use the config.json you have now and connect the led strip directly to the raspberry Pi on gpio pin 18.
    This is how the ws281x device type works.


    Option 2) use the arduino with the sketch you have - I know it well because it's mine.
    While it has a serial interface it's shit and was added because I wanted a separate light inside my Pi as well as the proper strip.
    Ignore the serial capability and instead use the SPI pins MOSI and SCK between the Pi and arduino
    Reconfigure Hyperion to use ws2801 (yes, 2801 it's not a typo)


    Option 3) use a different sketch the supports the adalight serial protocol:
    https://github.com/hyperion-pr…ino/adalight/adalight.ino
    And reconfigure Hyperion to use the adalight device type

  • To use SPI pins do I have to change the sketch?
    So if I understand correctly I connect 3 pins: SPI_MOSI, SPI_MISO and SPI_CLK to the correct ping of Arduino
    and change the type of led. Is that correct?

  • For the SPI side you only need MOSI and CLK - miso is not used.


    I think I know the problem - I've never used a MEGA and the pin mapping has changed.



    #define Josh2812_PIXEL_PORT PORTD // Port of the pin the pixels are connected to
    #define Josh2812_PIXEL_DDR DDRD // Port of the pin the pixels are connected to
    #define Josh2812_PIXEL_BIT 4 // Bit of the pin the pixels are connected to



    Change:
    Josh2812_PIXEL_BIT 4
    To:
    Josh2812_PIXEL_BIT 7


    Then use arduino digital pin 38

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!