Going to try my hand at sniffing the data driving a WS2812 chain for some future projects, and I’m wondering if anyone has tried this or knows of any existing resources for doing this. I’m fairly confident I can implement it with some RP2040 PIO since I have some pi pico boards laying around. Web searches for the topic aren’t turning up much of use, just a billion tutorials for driving the bus.

My only concern that might pose a problem is if the GPIO pins introduce noise or create other issues on the bus I’m trying to observe.

  • hendrik@palaver.p3x.de
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    14 days ago

    Not sure how easy it is to sample a digital signal that fast. The specs say it’s 350ns - 800ns. So my calculator says that’s about 3MHz. I don’t think noise etc will be an issue. And an opendrain input should be fine and not mess with the bus. You’ll likely have to find a good approach to read at that speed. Or find a suitable peripheral.

    The correct tool might be an oscilloscope / logic analyzer.

    But maybe have a look at some projects like “micro logic analyzer for RP2040”, seems it’s possible to sample digital signals up to 100MHz. There’s several projects like that out there. But I think the correct search term is “RP2040 logic analyzer”.

    I don’t think a lot of people “sniff” some WS2812 bus. You can have a look at other project’s code to generate all sorts of effects.

    • cmnybo@discuss.tchncs.de
      link
      fedilink
      English
      arrow-up
      4
      ·
      14 days ago

      The WS2812 only runs at 800kbps. That’s well within the capabilities of one of those 24 MHz FX2 based USB logic analyzers that you can get for less than $10. Sigrok has a protocol decoder for the WS2812 LEDs.

      • GandalfDG@beehaw.orgOP
        link
        fedilink
        English
        arrow-up
        1
        ·
        14 days ago

        well, it’s more being able to detect long vs. short pulses, as it’s not the logic level but the pulse width that encodes the bits.

        • cmnybo@discuss.tchncs.de
          link
          fedilink
          English
          arrow-up
          2
          ·
          14 days ago

          With a 24MHz sample rate, there will be 30 samples per bit. The narrowest a pulse for the WS2812 can be is 220 ns, which will be about 5 samples. That’s more than enough to decode it.

    • GandalfDG@beehaw.orgOP
      link
      fedilink
      English
      arrow-up
      3
      ·
      14 days ago

      fortunately the RP2040’s programmable IO can run at 40x that 3MHz rate, so with a working program I should be able to differentiate short and long pulses and convert them back to bits. My application shouldn’t need to know exact colors, rather just detecting certain patterns or an on/off threshold state for a specific light in the chain.

  • GandalfDG@beehaw.orgOP
    link
    fedilink
    English
    arrow-up
    1
    ·
    13 days ago

    looking at the schematics of the device I want to monitor more closely, it looks like it’s actually using addressable LEDs with a two-wire protocol, which actually makes things even easier because I can just sample on the provided clock edges. I think these are colloquially DotStar rather than NeoPixel devices. For reference I’m designing some mods for a modern pinball machine and it would be useful to know the state of lights on the playfield since I can’t hook into the code directly.