TLC5940 shift register library throwing Unknown Board error

Hello all - please advise if you might be able to assist at all… I am new to the ESP32 Wroom 32D and also to Platformio and Visual Studio Code too.

I have a sketch that has been working in the Arduino IDE and on the Atmel 328 chip very sucessfully, but I want to add some more to it and have bought a AZ Devkit C ESP32 board to make it easier. The speed, number of timers and the Wifi are the main reasons for my move.

Having bashed the keyboard for far too long now, trying to make it work with the Tlc5940 library listed in Platformio’s interface (from Paul Stoffregen and built upon Alex Leonne’s work maybe), I just can’t get it to recognise the board, with the “unknown error” message showing in the terminal. I have run some very simple sketches that didn’t need additional libraries and so the IDE is in principle running correctly. There are many errors that mention pin names and I imagine that this is part of the same problem.

The heirachy of the problem libary files is shown in red as follows: pinouts>>chip_includes.h, pinouts>>tlc_config.h and then Tlc5940.cpp too (this is not my file).

I would really like to continue specifically with this library and if anyone could shed light on how to overcome the problems I’d very much appreciate it.

Many thanks!

If you’re talking about the library at PlatformIO Registry, the library does not work the ESP32. The author of the library does some checks on which platform the library is being used, and it’s only valid for some AVR chips and some Teensies. For all else,

Sadly the library’s manifest is wrong here in telling you that it supports “all known architectures”. There’s code missing to support the ESP32.

Sadly Sparkfun’s port of the library, GitHub - sparkfun/SparkFun_TLC5940_Arduino_Library: Library for the TLC5940, is also not available for the ESP32, as well as the ALA library (Update library to work on ESP8266 & 32 · Issue #21 · bportaluri/ALA · GitHub).

So, looking at another possible library or project, while searching on Github, I found the project GitHub - botanicfields/BF-005: 16 Segment LED x 16 driven by TLC5940 and M5Stack which contains ESP32 specific code for driving the chip. A question on stackoverflow (arduino - ESP32 + TLC5940 - Stack Overflow) also hints to the same project.

So, you have a couple of options:

  • ask the author of the first Tlc5940 library, or the people at Sparkfun who maintain a fork for it, to expend its functionality to work on the ESP32
  • copy and adapt the driver code in the BF-005 project linked above
  • deep-dive into the above library and the TI TLC5940 datasheet yourself to expand the Tlc5940 library
  • write your own library from scratch
  • or, do not use the chip. As I see it, the chip gives you 16 PWM output with 12-bit resolution and some LED driver specific functionsd. The ESP32 has good hardware PWM on-chip, with its LEDC peripheral (literally, LED controller). It also has 16 channels and up to 16 bits of resolution (but also depending on the driven frequency, too), surpassing the TI chip in these two categories. You can learn more about it and its usage with Arduino here, here and the original Espressif documentation, for example. Of course, that doesn’t really help you if you have a pre-existing board with that chip and you need to talk to it, without having access to the LEDs yourself.

Thanks for such a quick and comprehesive response firstly…

I have a custom pcb based on the 328 and three TLC’s, but that’s yesterdays prototype and so I am able to start again. I looked at the files from Alex and because I’m not that sure about all syntax, I stopped trying to square the wheel and asked here. I use 45 of the channels and always enjoyed having three spare :-). I don’t need the higher resolution and never had any quarms about the TLC;s frequency. Incidentally, one of my noob questions became: Where is the manifest recorded and by whom - the author, or…?

I’ll take a look at your suggestions and thanks very much again for your kind help

What I was refering to is that on the lib page linked above, you see

Claiming Espressif32 support. PlatformIO displays that based on a meta-information file, library.properties in this case, in the library, where the author stated

where * means “everything / all”. But then that’s not true if it only works for some AVR and ARM chippies :sweat_smile:.

C’est la vie - as we say in England - and it makes sense that it is taken direct from the depository, verbatum.

Thanks again!