Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Reading WS2812b leftover data through I2S

Hello there,

I am currently trying to read the leftover WS2812b LED strip data which was sent using a single channel I2S. The data sent from the board (through I2S) looks like this:

with around 34 mV for high and around 2~6 mV on low. I decided not to send FFF, but 888 instead.

I am aiming to calculate the length of the LED strip. Each LED chip will read the first 24 bits of the data, cascade (discard) it, then pass it to the next one. Therefore, the strategy is to get the data after being cascaded by the last chip and calculate the length of it (which later will be divided by 24 to see how many are left).

The question is: How will I be able to read those data? I tried reading as usual (set a buffer for the i2s, start it, listen for it (delay), stop it, then check its buffer), but I got my buffer filled with all FFF instead. and a thing is that... when I tried to read anything from the pin, although I am not sending any data (the LED strip is not powered on, but connected to other's ground), there will be data, which should not happen. I assigned pin 22, 23, 24, 25 to be the i2s input pin (which will be assigned and unassigned when used or unused), and they are configured as follows:

nrf_gpio_cfg_sense_input(DIN1_PIN, NRF_GPIO_PIN_PULLDOWN, NRF_GPIO_PIN_SENSE_HIGH);

Thank you in advance.

  • Hi,

    That is right, the data I shifted in is the same on both input and output (it's actually 00010000 00000000 01010000).

    Ah.. okay... I did not remember about timing, especially when both are not connected directly.

    During this time (receiving data time), the nRF does not have to do anything else. Therefore, I think it may be safe to do GPIO reading for several ms, right? That being said, is 1.78 V safe for nRF52's GPIO Input? (Yes, as I checked the documentation). And what about the current? my multimeter seems like did not read any current from the Data Out of WS2812b (or there should not be?)

    As well, will nRF52 be able to detect the voltage change, between 0.x mV and 1.8 V on the GPIO output? I was thinking to reserve a time for nRF52 to count (in us (microsecond)), then once it detected signal change, read the second one (remember both time). Then, analyze it and decide if it's a 1 or 0 and so on. Do you think this will be a good idea?

    Thank you.

  • Hi,

    Regarding current the inputs have a high impedance, so you will see very little current on the data line. That is correct and expected.

    I assume you want to know if the nRF can detect voltage change on a GPIO input? That is a good idea. You can combine a comparator and timer with PPI and measure the time between the edges of the data signal by triggering timer capture registers from the comparator. That will be handled mostly in HW, but you would need to generate a interrupt for every bit and read the timer registers before the start of the next bit, so you will still have to handle the interrupts in a timely manner.

  • Hi,

    Alright, I will try that. Or do you have other idea you would like to suggest?

    And is there any other things that I may need to notice?

    I noticed from the Documentation Library that I will need to use the Analog Pins (AIN0 ~ AIN7). Therefore, I suppose Digital Pins will not be able to do it? Assuming I'm using a comparator

    Thank you

  • Hi,

    Yes, the comparator (and the other analog peripherals) can only be used with the 8 analog pins (see pinout in Product spec). Nothing else comes to mind at this point.

  • Hi,

    Oh, alright.

    By the way, I got a suggestion: keep using i2s to read the data. While the clock may not be synchronized, we create a Clock Phase Locking, setting an interrupt on the other board; which when triggered, will start the i2s over there and hopefully will be able to read and understand the data. What would you say about this?

Related