Teensy 4.x + ESP32 Stack

@mjs513 - While I am waiting for this:
Checking for the ability to merge automatically...
I Think I am going to set up my SPI RA8876 driver for the GIGA. It has been a while since I had it running on the GIGA. I can't remember if there was two available SPI ports on it or not?
https://github.com/wwatson4506/GIGA-RA8876-SPI and
https://github.com/wwatson4506/GIGA-RA8876-GFX-Common
I think it has been two years since I adapted the driver for the GIGA. Will have to refresh my memory.

Cool, there does not appear to be any conflicts with the pull request:
https://github.com/mjs513/Teensy-WiFi-Apps/pull/1
Three AM morning again. Now for a break:sleep:
EDIT: Also merged last pull request...
 
Last edited:
Yes, that's exactly why I use it. I'm currently working on a motorcycle computer with some LEDs that would be too bright at night. It wuld be too complicated to add a light sensor. Not sure if this idea works - it's all "work in progress".
 
Yes, that's exactly why I use it. I'm currently working on a motorcycle computer with some LEDs that would be too bright at night. It wuld be too complicated to add a light sensor. Not sure if this idea works - it's all "work in progress".
"Great Minds...." Ha Ha!
 
@wwatson @mjs513
On the RA8876 I think the keyboard should get bigger
1790007423820.png

I also did not add the back button (below it) as the cancel and done will go back...

Still don't like some of the hard coded things of library, may hack on it later...
 
@wwatson - @KurtE - @KenHahn

Since I am a glutton for punishment pulled out the 7in parallel capacitive display and using the old adapter I had made got the RA8876_t4_8080 library working in 8bit mode with the weather. Did find a typo in common that I will send the fix for.

Here is what the adapter looks like
1790017263559.png


Typical screen shots and using @KurtE's larger keypad settings:
1790017311940.png
1790017329953.png


1790017351678.png


and yes I updated to use Serial1 on the C5 and am using Wire2 on the Teensy for Touch.

@wwatson - you want the updates :)

A bit under the weather (change in season cold) so going to rest now.

Cheers
 
Recovered all of my GIGA libraries and have the RA8876 SPI TFT working again. Just going through all of the examples to make sure I have all of the required dependant libraries. Man there is a lot of them!!! So far every thing seems to be working...
 
@KenHahn @sparkfro

I wish that there would be more solutions and/or Shields/Carrier boards that also support the Micromod, which in my wish list of things,
would have connectors for displays, USB, SDIO and would be nice to have WiFi and BT...

I have my own Carrier board, that I did a while ago that works OK and I had a few partially assembled for me by PCBWay (all of the surface mount small pad spacing things...) Luckily I put in a Teensy 4 like connector for the times I might want an Audio adapter... Which comes in handy here.



1790259668372.png


I have plugged into it one of the C5 boards, I had all of the pins soldered in, so I right no have stacking pins
with the 3.3v pin and D0 removed...

And was able to update the Teensy_esp32.ino sketch to match:
Code:
/**********************************************
*  Setup display and touch
***********************************************/
// Configre ESP32 stack
//#define MINIDEVBOARD    //C3 on minidev board
//#define ILI9488_DISP // esle ST7796
#define XPT_TOUCH  //else FT6236
//#define INVERT_ST7796_DISPLAY
#define USE_KEYBOARD
//#define printForecast
#define orientation 3  // or 1 (landscape)

// Configure Display CS, DC and RST pins
// Pin assignments (adjust to your hardware/display setup)
#define TFT_CS   32
#define TFT_DC    9
#define TFT_RST  31

// Config Touch Pins
#if defined(XPT_TOUCH)
#define CS_PIN  28
#define TOUCH_SPI SPI
#else
#define TOUCH_WIRE Wire
#endif
And it appears to work:
1790259932412.png
 
Sorry, I know not what I am requesting 😆

But I 🤔 so far we have created two sketches one that runs on the ESP32 that does our specific searches and the other that runs on
the Teensy. But if I look at some other boards out there like:
Arduino UNO-R4 - It has two processors Renesas RA.... and an ESP32-S3
Arduino Portenta C33 has again a Renesas processor as well as an ESP32-C3
...

But with these boards, they don't reprogram the ESP32 each time they wish to run a different WiFi or BT program, but instead they have
a "Bridge" software, where, for example with my Port of the Weather app to the UNO R4, for the most part I simply had to change the
name of the library and the client object, and mostly everything else was unchanged (Wifi code...)
A bunch of the other code changed like the display and touch code, where I now have two versions including an HX8357 UNO touch
display shield running in 8 bit parallel mode (display library is using Adafruit_GFX)...
1790283381285.png


But wondering how hard that might be to do...
 
They may be running the ESP32-AT software on the ESP32. That allows another microcontroller to treat them like a slave processor using the AT command set.

If that is what they are doing, there wasn't a version available for the C6 (and maybe the C5) as used in the ESP32 stacks. Not sure about the C3 like used on the Mini. I think you can use the ESP-IDF software to make a version that would run on those boards. At a minimum I think you have to swizzle the pins around to remap how they are being used in that setup.
 
Sorry for OFF-Topic, but this was ... too.. interesting and scary.

Hmm, I was wondering how hard it would be to get an AI to create an HTML page. I uploaded your photo as an example… After 6 seconds, the response came in the form of the attached HTML file.
I had to zip it up because the forum doesn't allow HTML.
It's starting to get scary :(

It had only your Picture. Not more Information.

There are still a few minor display bugs, but... I think those could be fixed in 2–3 minutes... phew.
Just try the attached html.
Screenshot:


1790285469521.png


edit: fixed in 2 seconds....
1790286562748.png
 

Attachments

  • weather_display_open_meteo.zip
    6.3 KB · Views: 33
Last edited:
Fixed and german.

Again, sorry for beeing off-topic. You can keep going ;)

Waiting for the terminator...
 

Attachments

  • wetteranzeige_open_meteo_de.zip
    6.6 KB · Views: 24
Last edited:
Here is the weather_display_v5_RA8876 on the GIGA R1:
GIGA_weather_app.jpg

Still need to setup the touch screen on SPI1. Looks like I will need female to female jumper wires. Not sure if I have them...
 
I was fishing around for another app that can make better use of the Teensy as well as the ESP32 functionality so that they both have to pull their own weight a little more.

I ended up working with ChatGPT to create an MP3 internet radio player. It was my first time trying to use ChatGPT for a program development that I otherwise wouldn’t be able to do on my own, though I have played with Gemini a bit.

It was more complicated than I expected to get clean playback but seems well sorted now. It implements the main mechanics of streaming and playing MP3 files controlled via a touch interface on the LCD.

1790370564111.jpeg


It makes use of the ESP32 for fetching the music files off the internet and streaming the MP3 content to the Teensy over the 4Mbps serial link. It uses SomaFM Radio which is a free streaming service. The channel selections are arbitrary and can easily be changed in the ESP32 code.

The Teensy then uses @PaulStoffregen MP3 library to decode the incoming MP3 stream and uses the Audio library and the audio adapter to play it. It also handles the display and touch as well as controls the ESP32 over the serial link.

Since the MP3 stream is unidirectional and only using the ESP32 >> Teensy part of the serial link, the Teensy uses the Teensy >> ESP32 part of the serial link for XON/XOFF flow control and sending requests for channel switching, so it still only requires 2 pins total between the microcontrollers which I thought was pretty clever.

The MP3 decode library can be downloaded from here: https://github.com/PaulStoffregen/Teensy-MP3

Paul’s library had a couple of possible bugs that got fixed in the process by AI (cue @Mcu32 ;) ) so the play_mp3queue.cpp library file should be replaced with the one that is attached to be safe.

The ESP32_InternetRadio_V6_1 will need you to add your network name and password as usual.

I set it up initially on the Mini Platform since it didn’t require any wiring to make all the needed connections and I didn’t want to worry about debugging wiring issues along with everything else.

Of course, it will also work on the Teensy/ESP32 stacks with the usual minor serial link changes and hooking up an audio adapter and optionally a display. The code is configured for the ST7796 as used on the Mini, but it will start playing without a display attached.

It was pretty difficult to get the audio to play cleanly, so there are lots of serial print statements and some code snippets that were used to debug the setup. Same for the STATS screen. They were left in as they provide some interesting/useful info for future work.

If you try it, when programming the ESP32 be sure to keep the USB CDC on boot: disabled or if you enable it to see the ESP32 serial output, be sure to keep the serial monitor window open. If you close it, the ESP32 will stop until you open it again. I believe the ESP32 TX buffer overflows once the PC stops consuming the serial stream and when the window is opened back up, it resets the ESP32 and it's happy again. I haven’t figured out how to prevent that yet, but it's not a big issue if you are aware of it.
 

Attachments

  • Teensy_InternetRadio_v7.ino
    27.9 KB · Views: 28
  • ESP32_InternetRadio_v6_1.ino
    15.1 KB · Views: 24
  • play_mp3queue.cpp
    7.4 KB · Views: 26
Haha.. if you only knew...
That lib was a port of the now ancient famous mp3 decoder of RA-Player from Real Networks - written for an ancient ARM cpu, ported to the Teensy 3.1 (or was it T3.0? don't remember...) by Frank Boesing. I had NO Idea that a copy for that old code still exists. It was the first working version. Thanks for finding it. Paul has just a copy.

There is a much more capable version on his Github account with more codecs..like the better AAC and more.
(But I think there are some/many bugs too - runs pretty stable, though - it's archived.)
Again, thanks for the find.

Now, there are ports of that code running on ESP32 (no additional cpu). A great radio project exists.
 
Last edited:
The original choice was AudioCodec, but we switched gears as noted below in the AI interaction. I don't know if the logic was solid or not about support for the live UART stream.

In any case, it worked for this application. AI did fix a couple small things in the library because we were chasing dropped audio, but I don't know if those changes ended up being necessary for the final implementation. I didn't bother going back and compiling with the original source once we got the dropped data problem fixed but would be easy enough to do.
----------------

Good. Since you haven't installed a decoder yet, I'd actually change my recommendation slightly.

There are two relevant choices. The newer AudioCodec library is an actively maintained fork and supports MP3 up to 320 kbps on Teensy, but its documented playback sources are SD, built-in flash, and serial flash—not a live UART stream.

More interesting for our application is Paul Stoffregen's Teensy-MP3 library, which describes itself as an “MP3-Queue-like for Teensy Audio Library” and includes a play_mp3queue implementation. A queue interface is much closer to exactly what we need: continually feed compressed MP3 bytes arriving from Serial7 into the decoder.

So before installing AudioCodec, I recommend we use Teensy-MP3 for this project.
 
Back
Top