RTL8720D and Neopixel

Hi,
I have RTL8720D and I tried to use some Neopixel with it. Neopixel is WS2812 and I connected it to pin 10. This is the sketch:

#include <Adafruit_NeoPixel.h>
#define PIN 10
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  strip.begin();
  strip.setBrightness(50);
  strip.show(); // Initialize all pixels to 'off'
}
void loop() {
  colorWipe(strip.Color(0, 255, 0), 1000); // Green
  //colorWipe(strip.Color(255, 0, 0), 1000); // Green
  //colorWipe(strip.Color(0, 0, 255), 1000); // Green
  colorWipe(strip.Color(0, 0, 0), 1000); // white
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

With this setup, my Neopixel does not work. What am I doing wrong? I use Arduino IDE. I can blink regular LED on that pin. What could be wrong with Neopixel? Should I use some other pin?

Dear @dekip,
Thanks for your question. Currently, the Ameba Arduino SDK (which includes RTL8720DN) is not supporting WS2812 yet. Alternatively, you may proceed to our Github and requesting for this feature. :partying_face:

NeoPixel support has been added, check here for more information,

Has anyone had succes with this? I get errors when compiling

Hi @Olivier_Demoustier, may I know which board are you using and what compilation errors you have gotten? Thank you.

Sorry for the late reply, I was working on other projects. I use BW16.
I need to find that project back, to see the errors…

Hi @Olivier_Demoustier,

No worries, previously, some error issues were solved and updated on GitHub. You may post your enquires here again should you encounter any errors when you are back working on the project. :slight_smile:

Started my project again. :slight_smile:
But still no luck getting neopixel or any kind of WS28xx to work.
Even the example for “WS2812B.h” is not compiling here???
I use windows 10
Arduino IDE v2.0.3
BW16(RTL8720DN)
error text here to download: Dropbox - File Deleted - Simplify your life

#include “WS2812B.h”

#define NUM_OF_LEDS 8
// There are mutiple choice of SPI_MOSI pins depends on different boards. The default is SPI_MOSI/SPI1_MOSI
// AMB21/AMB22 pin 11/ pin21
// AMB23 pin 9/ pin 4
// BW16/BW16 Type C pin 12
// AW-CU488 ThingPlus pin 1/ pin 14
WS2812B led(SPI_MOSI, NUM_OF_LEDS);

void setup() {
Serial.begin(115200);
Serial.println(“WS2812B test”);
led.begin();
//Set a specific LED with a certain color
led.setPixelColor(0, 50, 0, 0);
led.setPixelColor(1, 0, 50, 0);
led.setPixelColor(2, 0, 0, 50);
led.show();
delay(1000);
//Fill the entire LED strip with the same color
led.fill(60, 0, 25, 0, 8);
led.show();
}

void loop() {
delay(500);
}

Hello @Olivier_Demoustier,

You can update your SDK to version 3.1.5 on Arduino IDE under boards manager and you should be able to compile successfully.

Can I download SDK manually, Because Arduino IDE does not know there is an update available?
See picture attached
Screenshot 2023-01-26 132546

Forget previous mail. I’ve found the update.
Going to check if it works now.

Sure, let me know if there’s still compiling error :slight_smile:

works like a charme now. :slight_smile:
Next step is to get DMX out working. But that is in a different topic.
Thanks

mmmm, it does work, but I get random spikes on the LED’s. All cables are very short.
I will investigate more tomorrow.
Here is my code.

#include "WS2812B.h"
#define NUM_OF_LEDS 170
// BW16/BW16 Type C         pin 12
WS2812B led(SPI_MOSI, NUM_OF_LEDS);

#include <WiFi.h>
#include <WiFiUdp.h>

char ssid[] = "TP-ollie003";     //  your network SSID (name)
char pass[] = "12341234";        // your network password
IPAddress ip(2, 0, 1, 101);      // desired IP address
IPAddress gateway(2, 0, 1, 254); // gateway of my network
IPAddress subnet(255, 0, 0, 0);  // subnet mask of my network
IPAddress dns(2, 1, 1, 1);       // dns of my network
WiFiUDP Udp;
#define DMX_SUBNET 0
#define DMX_UNIVERSE 201        //**Start** universe
unsigned int localPort = 5568;  // local port to listen on
#define ETHERNET_BUFFER 638     //540 is artnet leave at 636 for e1.31
unsigned char packetBuffer[ETHERNET_BUFFER];
int c = 4;
int status = WL_IDLE_STATUS;     // the Wifi radio's status
byte Univ;
int VALuniv[513];

//************************************************** 
void setup() {
  pinMode(10, OUTPUT);
  for (int i =0 ; i<20 ; i++){
    digitalWrite(10, LOW);
    delay(50);
    digitalWrite(10, HIGH);
    delay(50);
  }
  digitalWrite(10, LOW);
  led.begin();
  Serial1.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial1.println("WiFi shield not present");
    while (true);
  }
  WiFi.config(ip, dns, gateway, subnet);
  while (status != WL_CONNECTED) {
    Serial1.print("Attempting to connect to WPA SSID: ");
    Serial1.println(ssid);
    status = WiFi.begin(ssid, pass);
    delay(1000);
  }
  Serial1.println();
  Serial1.print("You're connected to the network");
  digitalWrite(10, HIGH);
  Udp.begin(localPort);
}

//**************************************************

int checkACNHeaders(unsigned char* messagein, int messagelength) {
  if ( messagein[1] == 0x10 && messagein[4] == 0x41 && messagein[12] == 0x37) {   
      int addresscount = (byte) messagein[123] * 256 + (byte) messagein[124]; // number of values plus start code
      return addresscount -1; //Return how many values are in the packet.
    }
  return 0;
}

//************************************************** 
void loop() {
   int packetSize = Udp.parsePacket(); //Read UDP packet count
   if(packetSize){
      Udp.read(packetBuffer,ETHERNET_BUFFER); //read UDP packet
      int count = checkACNHeaders(packetBuffer, packetSize);
      if (count) {
        sacnDMXReceived(packetBuffer, count, c); //process data function
      }  
  }
}

//**************************************************
void Send_To_Led(byte Univnr) {
  if (Univnr==1){
    for (int i =0 ; i<171 ; i++){
      led.setPixelColor(i, VALuniv[(i*3)+1], VALuniv[(i*3+1)+1], VALuniv[(i*3+2)+1]); 
    }
    led.show();
  }
}

//**************************************************
void sacnDMXReceived(unsigned char* pbuff, int count, int unicount) {
    byte b = pbuff[113]; //DMX Subnet
    if ( b == DMX_SUBNET) {
          b = pbuff[114];  //DMX Universe
//          byte s = pbuff[111]; //sequence
          if ( b ==DMX_UNIVERSE) {
                if ( pbuff[125] == 0 ) {  //start code must be 0
                for (int i = 126;i < 126+512; i++){
                    VALuniv[i-125]=pbuff[i];
                    }
                    Univ=1;
                    Send_To_Led(Univ);
                } 
          }
          if ( b == DMX_UNIVERSE+1 ) {
                if ( pbuff[125] == 0 ) {  //start code must be 0
                for (int i = 126;i < 126+512; i++){
                    VALuniv[i-125]=pbuff[i];
                    }
                    Univ=2;
                    Send_To_Led(Univ);
                }
              
          }
          if ( b == DMX_UNIVERSE+2 ) {
                if ( pbuff[125] == 0 ) {  //start code must be 0
                for (int i = 126;i < 126+512; i++){
                    VALuniv[i-125]=pbuff[i];
                    }
                    Univ=3;
                    Send_To_Led(Univ);
                }
              
          }
          if ( b == DMX_UNIVERSE+3) {
                if ( pbuff[125] == 0 ) {  //start code must be 0
                for (int i = 126;i < 126+512; i++){
                    VALuniv[i-125]=pbuff[i];
                    }
                    Univ=4;
                    Send_To_Led(Univ);
                }
          }  
    }
}