Teensy 4.x + ESP32 Stack

Quick question, I am not totally experienced using the ESP32...
I see on Page 1:
1789163110691.png


So we are using D1/D2 for Serial1... Or alternatively other pins D7/D8 For other Serial...

Now suppose I load a new program on the T4.1, can I setup another pin to communicate between The two.
Like ESP32 D3 pin connected to Arduino D2 pin?

I assume in Setup I would comment out the line I added:
Code:
//  gpio_reset_pin(GPIO_NUM_21);

Can I add something like:
Code:
#ifdef RESET_PIN  
  pinMode(RESET_PIN, INPUT_PULLUP);
  attachInterrupt(digitalPinToInterrupt(RESET_PIN), reset_esp32, FALLING);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(250);
  digitalWrite(LED_BUILTIN, LOW);
  #endif

...
// -------------------------------------------------------------------
// Maybe reboot ESP32
// -------------------------------------------------------------------
void reset_esp32() {
  esp_restart();
}
Wondering if the ESP has LED_BUILTIN defined. It compiles, figured it might be the User LED?

And then on Teensy 4.1 add in code to
Code:
#ifdef ESP32_RESET_PIN
  pinMode(ESP32_RESET_PIN, OUTPUT);
  digitalWrite(ESP32_RESET_PIN, HIGH);
#endif

And in the ping code:
Code:
  uint8_t ping_count = 0;
  while (!esp32Attached) {
    #ifdef ESP32_RESET_PIN
    ping_count++;
    if (ping_count == 5) {
      Serial.println("Reset ESP32");
      digitalWrite(ESP32_RESET_PIN, LOW);
      delay(1);
      digitalWrite(ESP32_RESET_PIN, HIGH);
      delay(1000);
      ping_count = 0;
    }
    #endif
    Serial.println("Ping ESP32-C3...");
    ESP32SERIAL.print("?");
Idea is to try a few times and if that fails to maybe then try to reset the ESP32...

So far I am not noticing if it is working or not...

Ideas?
 
These ESP32 modules have 1 available serial port (Serial1). By default it is attached to D6 and D7 as shown in the original pin map below. One unique feature of ESP32 is that virtually any function can be remapped to any pin. We can either remap it to D7/D8 for Serial5 on the Teensy or D1/D2 for Serial1 on the Teensy.

You can use other pins between the Teensy and ESP32 for whatever purpose you want as long as they are not both set as outputs.

Your reset idea should work. @defragster and I were discussing trying to do something similar to 'resync' the devices if needed.

Any pins not being used for the serial port (or other purposes) should have the gpio_reset_pin(GPIO_NUM_xx); done. That disconnects it from any internal logic like the SPI bus or I2C as an extra safety precaution that they don't accidentally get driven and cause contention. You have to use the GPIO number and not the D number.

LED_BUILTIN is defined and is on GPIO15 as shown here. It is not used anywhere else on the module so safe to use for user LED.

1789164704759.png
 
Last edited:
I have been curious if a bidirectional ISR link could be setup that would allow either processor to directly control something on the other processor via an ISR, whether it be so that either processor could reset the other or have it do some other thing without having to communicate.

Basic idea is that both pins are set as Input/pullup. Both have a LOW or FALLING ISR attached. If either processor wants to initiate the ISR in the other, it sets the pin as output and pulls it LOW.
 
LED_BUILTIN is defined and is on GPIO15 as shown here. It is not used anywhere else on the module so safe to use for user LED.
Confusingly, on my esp32-s3 modules, the polarity is reversed. Setting LED_BUILTIN to HIGH turns *off* the LED and setting it to LOW turns it *on*
 
bidirectional ISR link could be setup that would allow either processor to directly control something on the other processor
@tonton81 wrote a lib for controlling one MCU from another? Scrolling his repositories first I see this that isn't it but:
There is a newer: https://github.com/tonton81/ESP32_CAN

The other must have been built into the SPI_TRANSFER libraries? And the short ESP32's don't touch those pins, or even Teensy i2c on #18&19.
 
Confusingly, on my esp32-s3 modules, the polarity is reversed. Setting LED_BUILTIN to HIGH turns *off* the LED and setting it to LOW turns it *on*
Yep - I sort of saw that as well - as in the sketch mentioning trying to turn on LED and then off and it was left on...
 
As a simple proof of concept test of the shared ISR idea, I had ChatGPT help create a program that uses Teensy pin 2 and the mating ESP32 pin D3 to create a bidirectional ISR link that either processor can trigger. If you type 's' into the serial monitor of either microcontroller, it will flash the LED on the other microcontroller.

Should be able to easily change it to force a reset or some other task. I didn't bother setting up serial comm between the two since it wasn't being used

It will also work on the C5, just need to change the gpio_reset pins. If I forget to include them as I sometimes do, the software still seems to work OK.

As a reminder, you should have the power disconnected on one of the USB cables to use both at once. I use a short USB extender cable off Amazon that has a built-in power switch. https://www.amazon.com/dp/B0DL55JC2Z?th=1


1789236461566.jpeg


Teensy Code
Code:
[code]
/*
   Teensy 4.1 to ESP32-C5/C6 handshake test

   Teensy pin 2 <----> XIAO ESP32-C5/C6 D3

   Normally:
      Pin 2 = INPUT_PULLUP

   To signal the ESP32:
      1. Detach interrupt
      2. Change pin to OUTPUT
      3. Drive LOW
      4. Wait 20 ms
      5. Return to INPUT_PULLUP
      6. Reattach interrupt

   When the ESP32 pulls the line LOW:
      Teensy ISR sets a flag
      Teensy built-in LED flashes for 100 ms
*/

const int SIGNAL_PIN = 2;
const int LED_PIN    = LED_BUILTIN;   // Teensy 4.1 = pin 13

volatile bool signalReceived = false;

unsigned long ledOffTime = 0;

//--------------------------------------------------
// Interrupt Service Routine
//--------------------------------------------------
void signalISR() {
  signalReceived = true;
}

//--------------------------------------------------
// Signal the ESP32-C6
//--------------------------------------------------
void signalESP32() {

  Serial.println("Sending signal to ESP32");

  // Prevent our own LOW transition from triggering ISR
  detachInterrupt(digitalPinToInterrupt(SIGNAL_PIN));

  // Pull shared line LOW
  pinMode(SIGNAL_PIN, OUTPUT);
  digitalWrite(SIGNAL_PIN, LOW);

  delay(20);

  // Release the shared line
  pinMode(SIGNAL_PIN, INPUT_PULLUP);

  // Allow line to return HIGH before restoring interrupt
  delayMicroseconds(50);

  // Restore interrupt
  attachInterrupt(
    digitalPinToInterrupt(SIGNAL_PIN),
    signalISR,
    FALLING
  );
}

//--------------------------------------------------
// Setup
//--------------------------------------------------
void setup() {

  Serial.begin(115200);

  // Built-in LED
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);       // LED OFF

  // Shared handshake line
  pinMode(SIGNAL_PIN, INPUT_PULLUP);

  attachInterrupt(
    digitalPinToInterrupt(SIGNAL_PIN),
    signalISR,
    FALLING
  );

  Serial.println();
  Serial.println("Teensy 4.1 ready");
  Serial.println("Handshake pin = 2");
  Serial.println("Type S to signal ESP32-C6");
}

//--------------------------------------------------
// Main loop
//--------------------------------------------------
void loop() {

  //------------------------------------------------
  // Check for signal from ESP32
  //------------------------------------------------
  if (signalReceived) {

    // Safely clear ISR flag
    noInterrupts();
    signalReceived = false;
    interrupts();

    Serial.println("Signal received from ESP32");

    // Flash Teensy built-in LED
    digitalWrite(LED_PIN, HIGH);

    ledOffTime = millis() + 1000;
  }

  //------------------------------------------------
  // Turn LED back off
  //------------------------------------------------
  if (ledOffTime != 0 &&
      (long)(millis() - ledOffTime) >= 0) {

    digitalWrite(LED_PIN, LOW);

    ledOffTime = 0;
  }

  //------------------------------------------------
  // Serial Monitor test
  //------------------------------------------------
  if (Serial.available()) {

    char c = Serial.read();

    if (c == 's' || c == 'S') {
      signalESP32();
    }
  }
}
[/CODE]

ESP32-C6 Code
Code:
```cpp
/*
  ESP32-C6 to Teensy 4.1 handshake test

   XIAO D3 / GPIO21 <----> Teensy 4.1 pin 2

   Normally:
      D3 = INPUT_PULLUP

   To signal the Teensy:
      1. Detach interrupt
      2. Change pin to OUTPUT
      3. Drive LOW
      4. Wait 20 ms
      5. Return to INPUT_PULLUP
      6. Reattach interrupt

   When Teensy pulls the line LOW:
      ESP32 ISR sets a flag
      ESP32 built-in LED flashes for 100 ms
*/

const int SIGNAL_PIN = D3;       // XIAO D3 = GPIO21
const int LED_PIN    = LED_BUILTIN;       //GPIO15 user LED, active LOW

volatile bool signalReceived = false;
unsigned long ledOffTime = 0;

//--------------------------------------------------
// Interrupt Service Routine
//--------------------------------------------------
void ARDUINO_ISR_ATTR signalISR() {
  signalReceived = true;
}

//--------------------------------------------------
// Signal the Teensy
//--------------------------------------------------
void signalTeensy() {

  Serial.println("Sending signal to Teensy");

  // Prevent our own LOW transition from triggering ISR
  detachInterrupt(digitalPinToInterrupt(SIGNAL_PIN));

  // Pull shared line LOW
  pinMode(SIGNAL_PIN, OUTPUT);
  digitalWrite(SIGNAL_PIN, LOW);

  delay(20);

  // Release shared line
  pinMode(SIGNAL_PIN, INPUT_PULLUP);

  // Allow line to return HIGH
  delayMicroseconds(50);

  // Restore interrupt
  attachInterrupt(
    digitalPinToInterrupt(SIGNAL_PIN),
    signalISR,
    FALLING
  );
}

//--------------------------------------------------
// Setup
//--------------------------------------------------
void setup() {

  Serial.begin(115200);

  gpio_reset_pin(GPIO_NUM_0);  
  gpio_reset_pin(GPIO_NUM_1);   // Change to GPIO_NUM_17 if using Serial1 on teensy
  gpio_reset_pin(GPIO_NUM_2);   // Change to GPIO_NUM_19 if using Serial1 on teensy
  gpio_reset_pin(GPIO_NUM_16);
  gpio_reset_pin(GPIO_NUM_18);
  gpio_reset_pin(GPIO_NUM_20);
//  gpio_reset_pin(GPIO_NUM_21);
  gpio_reset_pin(GPIO_NUM_22);
  gpio_reset_pin(GPIO_NUM_23);

  // XIAO built-in LED is active LOW
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, HIGH);     // LED OFF

  // Shared handshake line
  pinMode(SIGNAL_PIN, INPUT_PULLUP);

  attachInterrupt(
    digitalPinToInterrupt(SIGNAL_PIN),
    signalISR,
    FALLING
  );

  Serial.println();
  Serial.println("XIAO ESP32-C6 ready");
  Serial.println("Handshake pin = D3 / GPIO21");
  Serial.println("Type S to signal Teensy");
}

//--------------------------------------------------
// Main loop
//--------------------------------------------------
void loop() {

  //------------------------------------------------
  // Check for signal from Teensy
  //------------------------------------------------
  if (signalReceived) {

    signalReceived = false;

    Serial.println("Signal received from Teensy");

    // XIAO LED is active LOW
    digitalWrite(LED_PIN, LOW);

    ledOffTime = millis() + 1000;
  }

  //------------------------------------------------
  // Turn LED back off
  //------------------------------------------------
  if (ledOffTime != 0 &&
      (long)(millis() - ledOffTime) >= 0) {

    digitalWrite(LED_PIN, HIGH);

    ledOffTime = 0;
  }

  //------------------------------------------------
  // Serial Monitor test
  //------------------------------------------------
  if (Serial.available()) {

    char c = Serial.read();

    if (c == 's' || c == 'S') {
      signalTeensy();
    }
  }
}
```
 
Afternoon all

As you all know @KurtE and I have been trying to get the Keypad working on the Giga as well as other issues with the giga - Teensy is alot easier. Anyways figured out a way to get larger button sizes for the display by specifying the size in the .h file
C++:
#if __has_include("ST7796_t3.h") ||  __has_include("ILI9488_t3.h")
#define BUTTON_SIZE 40
#define ROW_DELTA 42;  //size + 2
#else
#define BUTTON_SIZE 30
#define ROW_DELTA 32;  //size + 2
#endif
1789242437897.png


I just finished pushing up the changes to the keypad library and the tweaks for the teensy_esp32 sketch.

PS. also zipped the sketches so its easier to download just a single sketch.

@wwatson you might want to take a look to see if it works on the RA8876 :)

Cheers
Mike
 
Afternoon all

As you all know @KurtE and I have been trying to get the Keypad working on the Giga as well as other issues with the giga - Teensy is alot easier. Anyways figured out a way to get larger button sizes for the display by specifying the size in the .h file
C++:
#if __has_include("ST7796_t3.h") ||  __has_include("ILI9488_t3.h")
#define BUTTON_SIZE 40
#define ROW_DELTA 42;  //size + 2
#else
#define BUTTON_SIZE 30
#define ROW_DELTA 32;  //size + 2
#endif
View attachment 39834

I just finished pushing up the changes to the keypad library and the tweaks for the teensy_esp32 sketch.

PS. also zipped the sketches so its easier to download just a single sketch.

@wwatson you might want to take a look to see if it works on the RA8876 :)

Cheers
Mike
Funny you should ask :LOL: I'm working on that right now. In the process of recovering my hard drives I was able to find my original XPT2046 library that I used for the RA8876 SPI resistive touch screen. The XPT2046_touchscreen library never did play nice with the RA8876. So I modified another driver from:
Code:
/*
 * Copyright (c) 2015-2016  Spiros Papadimitriou
 *
 * This file is part of github.com/spapadim/XPT2046 and is released
 * under the MIT License: https://opensource.org/licenses/MIT
 *
 * This software is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied.
 */
I am currently redoing it to try and bring it closer to the authors original library. It works and all that is left is reworking the calibration sketch. The driver uses the pen interrupt on pin 2 of the T4.1 for triggering instead of the Z_THRESHOLD to trigger. The z1 and z2 values were to noisy and erratic to use as a processed trigger. Possibly due to several factors including hookup wire length and SPI speed. I tried lowering the SPI speed to 1000000 but that changed nothing.

Anyway I will try and catch up:)
 
A bit of an update, I noticed that without a screen touch the raw x and raw y values always return 0xffff. I might be able to use that to signal a screen touch if the raw x or raw y value changes from 0xffff without having to waste a I/O pin on an interrupt...
 
#ifdef RESET_PIN pinMode(RESET_PIN, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(RESET_PIN), reset_esp32, FALLING);
Quick note: the code I tried earlier more or less works, when I
define RESET_PIN D3 and not just 3.

It actually reboots as the Teensy starts up, probably mainly because I did a pinMode(2, OUTPUT); near the start which defaulted to LOW...
which rebooted.

EDIT: I changed my Teensy side code to start up with the pin INPUT_PULLUP...
If 10 times through the ping code it fails, I then set it to output and set low wait 5ms and then set back to INPUT_PULLUP.
Now I program it, it goes:
Code:
Ping ESP32-C3...
Ping ESP32-C3...
Ping ESP32-C3...
Ping ESP32-C3...
Ping ESP32-C3...
Ping ESP32-C3...
Ping ESP32-C3...
Ping ESP32-C3...
Ping ESP32-C3...
Reset ESP32
Ping ESP32-C3...
ESP32-C3 Connected!
 
Last edited:
Yeah, pin labeling is a little confusing on the ESP32.

If you use just a number it assumes you mean the GPIO #, so you'd be addressing GPIO3 which isn't being brought out on that module. To reference the intended pin, you can either use 21 or D3.

Between the C5 and the C6, the GPIO numbers change adding more confusion, but the D number stay the same, so it's generally the better option.

The gpio_reset_pin(); requires the use of the GPIO number which I find confusing switching between the two, but doing a little searching, it looks like you can use the following to allow use of the D pin labeling there as well. The driver/gpio.h is where the pin enumerations live. It adds the D labeling, but you still need to explicitly type cast it to get it to compile

Code:
#include "driver/gpio.h"

void setup() {
    gpio_reset_pin((gpio_num_t)D3);
}

I'm going to start using this as working strictly with the D numbering is a lot less confusing especially when bouncing between versions of the ESP32.
 
Alcon

Just got my c5 stack and decided to try the WiFiScan for the c5 which shows 2G and 5G connections:

Code:
Scan done
35 networks found
Nr | SSID                             | RSSI | CH | Encryption
 1 | CyberPalin                       |  -22 | 11 | WPA+WPA2
 2 | CyberPalin-Guest                 |  -22 | 11 | WPA2
 3 | CyberPalin5g                     |  -30 | 40 | WPA+WPA2
 4 | Fios-2RnJp                       |  -53 |  6 | WPA2
 5 | [LG_Oven]3a82                    |  -54 | 11 | WPA2
 6 | Fios-2RnJp                       |  -62 | 161 | WPA2
 7 | Fios-2RnJp                       |  -65 | 48 | WPA2
 8 | LF_930_6243                      |  -76 | 11 | WPA2
 9 | SpectrumSetup-D2                 |  -78 |  1 | WPA2
10 | SPASERVICE                       |  -79 |  6 | WPA2
11 | TMOBILE-D512                     |  -81 |  8 | WPA2+WPA3
12 | 4A7E1A                           |  -82 |  6 | WPA+WPA2
13 | Verizon_C3G7C6                   |  -84 |  1 | WPA2
14 | Get your own WiFi                |  -84 | 10 | WPA2
15 | Fios-QQRHJ                       |  -84 | 11 | WPA2
16 | skyrock                          |  -86 |  1 | WPA2
17 | Verizon_C696KD                   |  -86 |  6 | WPA2
18 | Fios-HN6cj                       |  -87 |  1 | WPA2
19 | Verizon_TWVGZ9                   |  -87 | 11 | WPA2
20 | lexi deco                        |  -88 |  8 | WPA2
21 | TMOBILE-0535                     |  -90 |  2 | WPA2+WPA3
22 | HP-Print-4E-Officejet Pro 8610   |  -90 |  6 | WPA2
23 | Verizon_C3G7C6                   |  -90 | 153 | WPA2
24 | TMOBILE-0535                     |  -91 |  2 | WPA2+WPA3
25 | Fios-BYcd3                       |  -91 |  4 | WPA2
26 | SPASERVICE                       |  -92 |  1 | WPA2
27 | vanessany22                      |  -93 | 11 | WPA2
28 | TMOBILE-0535                     |  -93 | 153 | WPA2+WPA3
29 | SpectrumSetup-D2                 |  -93 | 157 | WPA2
30 | SpectrumSetup-A8                 |  -94 |  6 | WPA2
31 | Fios-QQRHJ-5G                    |  -94 | 40 | WPA2
32 | 4A7E1A 5G                        |  -95 | 36 | WPA+WPA2
33 | TMOBILE-5480                     |  -95 | 40 | WPA2+WPA3
34 | Spectrum Mobile                  |  -95 | 157 | WPA2-EAP
35 | lexi deco                        |  -96 | 40 | WPA2
-------------------------------------
-------------------------------------
2.4 Ghz wifi band mode scan:
-------------------------------------
Scan start
Scan done
21 networks found
Nr | SSID                             | RSSI | CH | Encryption
 1 | CyberPalin                       |  -21 | 11 | WPA+WPA2
 2 | CyberPalin-Guest                 |  -22 | 11 | WPA2
 3 | [LG_Oven]3a82                    |  -52 | 11 | WPA2
 4 | Fios-2RnJp                       |  -54 |  6 | WPA2
 5 | LF_930_6243                      |  -75 | 11 | WPA2
 6 | SpectrumSetup-D2                 |  -78 |  1 | WPA2
 7 | 4A7E1A                           |  -78 |  6 | WPA+WPA2
 8 | SPASERVICE                       |  -81 |  6 | WPA2
 9 | Verizon_C3G7C6                   |  -83 |  1 | WPA2
10 | Fios-QQRHJ                       |  -85 | 11 | WPA2
11 | Verizon_TWVGZ9                   |  -86 | 11 | WPA2
12 | HP-Print-4E-Officejet Pro 8610   |  -88 |  6 | WPA2
13 | SPASERVICE                       |  -89 |  1 | WPA2
14 | TMOBILE-0535                     |  -89 |  2 | WPA2+WPA3
15 | Verizon_C696KD                   |  -89 |  6 | WPA2
16 | lexi deco                        |  -89 |  8 | WPA2
17 | skyrock                          |  -91 |  1 | WPA2
18 | Fios-HN6cj                       |  -92 |  1 | WPA2
19 | Verizon_364XFZ                   |  -92 | 11 | WPA2
20 | SpectrumSetup-A8                 |  -93 |  6 | WPA2
21 | vanessany22                      |  -96 | 11 | WPA2
-------------------------------------
-------------------------------------
5 Ghz wifi band mode scan:
-------------------------------------
Scan start
Scan done
11 networks found
Nr | SSID                             | RSSI | CH | Encryption
 1 | CyberPalin5g                     |  -32 | 40 | WPA+WPA2
 2 | Fios-2RnJp                       |  -60 | 161 | WPA2
 3 | Fios-2RnJp                       |  -62 | 48 | WPA2
 4 | Verizon_C3G7C6                   |  -89 | 153 | WPA2
 5 | SpectrumSetup-D2                 |  -89 | 157 | WPA2
 6 | Spectrum Mobile                  |  -90 | 157 | WPA2-EAP
 7 | TMOBILE-0535                     |  -92 | 153 | WPA2+WPA3
 8 | lexi deco                        |  -93 | 40 | WPA2
 9 | Fios-QQRHJ-5G                    |  -93 | 40 | WPA2
10 | 4A7E1A 5G                        |  -94 | 36 | WPA+WPA2
11 | TMOBILE-5480                     |  -94 | 40 | WPA2+WPA3
-------------------------------------

Nice so many more - also it did pick up my 5g network.
 
Ok guys did a little rework of the ESP32 Code for the weather app - should cover C3/C5/C6 now automatically - just one note C5/C6 uses Serial5. Also reworked the Teesny code so covers all combinations of Displays/Touch screen - I hope :)

Pasting the code here now if any wants to give it a try. This is what the Keyboard now looks like

1789427662126.png


Tomorrow want to add the interrupt code to auto restart when the Teensy reboots :)

Cheers

@wwatson - feel better soon :)
 

Attachments

  • esp32_teensy_v1-260914a.zip
    3.3 KB · Views: 27
  • teensy_esp32-260914a.zip
    74.9 KB · Views: 27
Ok guys did a little rework of the ESP32 Code for the weather app - should cover C3/C5/C6 now automatically - just one note C5/C6 uses Serial5. Also reworked the Teesny code so covers all combinations of Displays/Touch screen - I hope :)

Pasting the code here now if any wants to give it a try. This is what the Keyboard now looks like

View attachment 39837

Tomorrow want to add the interrupt code to auto restart when the Teensy reboots :)

Cheers

@wwatson - feel better soon :)
My T4/C5 stack just arrived today, so I thought I might play along. I downloaded the two ZIP files in P66 (thanks @mjs513 !!), but I get the following error when I try to build the Teensy side (am I missing a file that I should be getting from somewhere else ??):

1789435473284.png


Mark J Culross
KD5RXT
 
Using a bare C6 from @KenHahn - hadn't seen any Bt scanner code - and first look was a BRAVE search and its AI gave me a working start.

I merged it with WiFi scan and they both worked - but the 4MB C6 needed alternate Code/Spiff size to hold it.

Went back to Bt scan only. Stopped Auto rescan as their scan returns lots of DUPES, so added CRC of the MAC to quickly check a list and skip Dupes on same pass and later passes.

Seat here found 12 ... 14 .. 20 .. 30 ... 37 ... 42??? So I figured 64 would be safe, why are there 40++ detected Bt devices ????

Added option for 5 sec auto scan and walked away ... came back to a REBOOT after Fault as the count was 71!!!! And I hadn't bothered to limit check the addition of new MAC's.

Bumped the MAX to 128 and added check before INC. Array of Struct with CRC and the MAC are not sorted - so added PRINT sorted on first of the 6 hex bytes so they could easily be SCANNED and checked.

So, this code isn't PROTO_SUPPLIES_STACK ready from ESP to Teensy - but just SerMon from ESP32.

One device appears with no MAC/RSSI and a printer shows up - sometimes with garbage text and loss of readable MAC/RSSI, About all else does not present a "NAME" - so identifying the devices will be hard - maybe lookup of the MAC for the maker from the sorted list?

During typing of this the unique MAC count just hit 50 from 30. Opps make that 52? It is good that Bt is LOW POWER!!! Opps 53!

Here are the FIFTY FOUR FIFTY SEVEN found here:

Code:
MAC: 22:7b:ac:75:11:ab    NEW :: CRC: -855540023    Name: , Address: 22:7b:ac:75:11:ab, <>        RSSI: -99
MAC: 71:be:6b:93:68:8e    NEW :: CRC: -1780347026    Name: , Address: 71:be:6b:93:68:8e, <>        RSSI: -98
Devices found: 13
PAK to Scan again [more than 2 chars erases known MACs] 's' ShowAll : 'd' Toddle Dupe display : 't' 5sec Auto Update
Num MAC Known 57

=== 57 Known Bt MAC IDs ===
MAC: 00:1F:36:0E:06:FE  CRC 7F0CACE5
MAC: 01:68:6D:1D:EB:49  CRC 431B7D9B
MAC: 02:56:53:03:EA:DD  CRC 33AB6E26
MAC: 06:C3:EF:10:18:AC  CRC F990AACE
MAC: 06:B6:34:16:F8:C1  CRC 50076952
MAC: 0E:FB:87:3A:B8:F0  CRC 83006608
MAC: 0E:5A:52:6E:B9:15  CRC 7D03385F
MAC: 0F:79:DC:66:23:CB  CRC D96EB3DD
MAC: 10:DE:46:46:5D:C7  CRC BB531F66
MAC: 11:F0:28:7E:24:0D  CRC 7A3380AF
MAC: 15:90:7F:EF:A0:4B  CRC 12CBE9C2
MAC: 16:0B:74:D9:DE:18  CRC 86B0C778
MAC: 18:13:19:EA:BB:66  CRC AC7CCD85
MAC: 19:15:D3:93:77:F3  CRC 4D9A49B4
MAC: 1A:DD:A3:24:DF:77  CRC 354EA1D1
MAC: 1A:EF:65:6C:E0:C6  CRC 27B88EB3
MAC: 1A:FE:C9:22:CB:A8  CRC DBFB87C0
MAC: 1B:1B:8A:CD:C5:D8  CRC 150A2036
MAC: 1C:77:E9:93:25:BF  CRC 96D4D682
MAC: 1D:50:92:CC:F3:9C  CRC 80B2ABC8
MAC: 1F:EB:A0:41:4F:F7  CRC 8BB2D25B
MAC: 20:67:46:46:9C:52  CRC F07AF36A
MAC: 21:90:5C:9B:5D:68  CRC 6F2A82A7
MAC: 22:47:04:F5:10:69  CRC AC4B93F9
MAC: 22:7B:AC:75:11:AB  CRC CD017EC9
MAC: 24:CE:33:DB:83:5C  CRC 9514140F
MAC: 24:E6:81:9A:34:26  CRC B9D2B171
MAC: 26:50:46:9A:CB:1F  CRC 4C264E0B
MAC: 28:99:11:0C:56:CD  CRC 915F1127
MAC: 2A:73:33:8F:25:B6  CRC 947E2FBF
MAC: 2B:39:86:CA:0E:C4  CRC D9E7A008
MAC: 2C:65:4F:DA:F7:9A  CRC 67CF9681
MAC: 2E:E6:20:E6:05:51  CRC B8499E6E
MAC: 2E:05:82:7D:A9:28  CRC EA729F83
MAC: 2F:17:72:17:FC:1A  CRC F7332804
MAC: 31:AF:87:76:3D:23  CRC 9B1121BF
MAC: 37:86:64:E6:AC:12  CRC 81C46290
MAC: 38:23:78:43:3E:FC  CRC 9EC90E8
MAC: 3A:08:F4:C1:11:48  CRC 691BA663
MAC: 3B:44:03:12:B8:DF  CRC BA9464BE
MAC: 3C:F9:AB:A7:5F:FD  CRC C0D3B17D
MAC: 3D:45:26:3A:00:76  CRC 7309D9BB
MAC: 3E:FF:4B:63:85:95  CRC 7A3C5E8D
MAC: 45:B3:D1:D6:34:D9  CRC 1506B9BE
MAC: 4B:74:83:86:2F:FA  CRC 72D0BF74
MAC: 4C:2B:0A:47:38:55  CRC 9640E8FF
MAC: 4F:02:3D:36:CE:B8  CRC 7897CDA5
MAC: 50:1D:25:57:EA:64  CRC CA92DC86
MAC: 55:8F:66:45:8B:FE  CRC CBA69934
MAC: 64:E8:33:00:63:99  CRC E061DBC5
MAC: 71:BE:6B:93:68:8E  CRC 95E20F6E
MAC: 73:88:E6:3D:63:6E  CRC 7960C67C
MAC: 74:87:92:7F:5E:DB  CRC A09500CD
MAC: 79:C9:2A:28:31:82  CRC BA2F3543
MAC: 7C:07:CF:84:BA:9D  CRC D87BAB31
MAC: 7F:89:64:70:67:33  CRC 7D66A7D9
MAC: E2:BB:9E:20:44:53  CRC 710387E8
==================

Note - made another post and hit Bt Scan and:
Code:
MAC: 03:95:60:91:87:42    NEW :: CRC: -89616538    Name: , Address: 03:95:60:91:87:42, <>        RSSI: -91
MAC: 25:13:15:4f:33:04    NEW :: CRC: -786699278    Name: , Address: 25:13:15:4f:33:04, <>        RSSI: -90
MAC: 23:8a:c9:18:46:a5    NEW :: CRC: 767323479    Name: , Address: 23:8a:c9:18:46:a5, <>        RSSI: -92
MAC: 17:89:25:1c:98:ac    NEW :: CRC: 137385045    Name: , Address: 17:89:25:1c:98:ac, <>        RSSI: -89
MAC: 33:f7:5a:2a:7b:47    NEW :: CRC: -2082537492    Name: , Address: 33:f7:5a:2a:7b:47, <>        RSSI: -92
MAC: 25:47:ef:6b:2d:e6    NEW :: CRC: 1347561101    Name: , Address: 25:47:ef:6b:2d:e6, <>        RSSI: -78
MAC: 2f:45:82:fa:44:5f    NEW :: CRC: -1206489004    Name: , Address: 2f:45:82:fa:44:5f, <>        RSSI: -72
MAC: 2f:08:14:33:b9:2c    NEW :: CRC: 1983791213    Name: , Address: 2f:08:14:33:b9:2c, <>        RSSI: -77
MAC: 64:33:54:7a:1f:30    NEW :: CRC: -850159097    Name: , Address: 64:33:54:7a:1f:30, <>        RSSI: -91
MAC: 52:b7:4f:ed:f4:ca    NEW :: CRC: -995088597    Name: , Address: 52:b7:4f:ed:f4:ca, <>        RSSI: -97
MAC: e2:bb:9e:20:44:53    NEW :: CRC: 1896056808    Name: ET-2850 Series, Address: e2:b <>        RSSI: -69

no  MAC    Name: EF-R21969 <>        no  RSSI
Devices found: 13
PAK to Scan again [more than 2 chars erases known MACs] 's' ShowAll : 'd' Toddle Dupe display : 't' 5sec Auto Update
Num MAC Known 68


MAC: 24:ce:33:db:83:5c    NEW :: CRC: -1793846257    Name: , Address: 24:ce:33:db:83:5c, <>        RSSI: -92
MAC: 0e:55:c8:e3:d2:0c    NEW :: CRC: 639712305    Name: , Address: 0e:55:c8:e3:d2:0c, <>        RSSI: -98
Devices found: 14
PAK to Scan again [more than 2 chars erases known MACs] 's' ShowAll : 'd' Toddle Dupe display : 't' 5sec Auto Update
Num MAC Known 70

EDIT - code updated - didn't see it was viewed?
 

Attachments

  • BtScan_ESP32.ino
    4.5 KB · Views: 24
Last edited:
Looking to find known MAC for phone in list it isn't there
Also, the first pairs are the maker - and the sorted list doesn't show groups.

And going to this site for manufacturer lookup doesn't recognize numbers reported

  • MAC Randomization: Many modern BLE devices (phones, wearables) broadcast randomized MAC addresses to prevent tracking. Scanning for a specific MAC may fail if the device rotates its address.
  • Since phones (iOS and Android) rotate their BLE MAC addresses every ~15 minutes by default, filtering by MAC is unreliable for consumer devices
 
Last edited:
Sorry shut down for the night and just saw your post. The ILI9341_t3_keypad is a modified of @KrisKasprzak lib that I modidifed for ILI9488 and ST7796. It can be downloaded here:

Thanks !! And, of course, now I see the reference in your readme that you posted in P47 !!

Mark J Culross
KD5RXT

P.S. Have some honey-dos to attend to today, so hopefully I'll get a chance to play some more later today . . . MJC
 
Evening all
Think I got a single Teensy-esp32 sketch that will support the ILI9488, ST7796 Displays with either the FT6236 or XPT2046 Touch drivers including special support for the minidev board that requires you invert the display. The sketch also has the `ESP.restart` command sent across `ESPSerial` as opposed to setting up interrupts. Configuration is setup at the beginning of the sketch:

C++:
/**********************************************
*  Setup display and touch
***********************************************/
// Configre ESP32 stack
//#define MINIDEVBRD    //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   10
#define TFT_DC    9
#define TFT_RST   8

// Config Touch Pins
#if defined(XPT_TOUCH)
#define CS_PIN  7
#define TOUCH_SPI SPI1
#else
#define TOUCH_WIRE Wire
#endif

String DEFAULT_CITY = "Disneyland";

On the `esp32-teensy` side it automattically configures the boards based on esp32 cX chip. NOTE: `Serial5` is the default for the C5/C6. Going to post but am attaching the sketches.

Cheers.
 

Attachments

  • esp32_teensy_v1-260915a.zip
    3.4 KB · Views: 26
  • teensy_esp32-260915a.zip
    75.1 KB · Views: 26
Downloaded and gave it a try on the Mini.

On the ESP32 it has this define.
Code:
#if defined(ARDUINO_XIAO_ESP32C3)
#define RX2 20  // Connect to Teensy 4.1 TX
#define TX2 21  // Connect to Teensy 4.1 RX
Technically it is not an XIAO module. I usually use the generic ESP32C3 Dev Module and it wouldn't compile due to that mismatch. I tried using the XIAO board type and it did compile and work OK so probably fine as-is.

On the Teensy there is a mismatch on the #define names (BRD vs BOARD) so it didn't find the ESP32-C3 on the first pass.
Code:
// Configre ESP32 stack
#define MINIDEVBRD    //C3 on minidev board
Then later
Code:
#if defined(MINIDEVBOARD)
#define ESP32SERIAL Serial7  //7 for C3, 5 for C5/C6

On the keyboard, I updated to the latest, but the keyboard looks the same small size except the large 'Back' button is missing at the bottom, but it still sees the button press. I might not have gotten something updated correctly.
 
On the keyboard, I updated to the latest, but the keyboard looks the same small size except the large 'Back' button is missing at the bottom, but it still sees the button press. I might not have gotten something updated correctly.
Ok this is I forgot to push the changes I made to get the larger buttons on the ILI9488/St7796 displays. Changes are now available.


Technically it is not an XIAO module. I usually use the generic ESP32C3 Dev Module and it wouldn't compile due to that mismatch. I tried using the XIAO board type and it did compile and work OK so probably fine as-is.
Fixed and pushed changes to the repo. Easy enough to change to be correct correct configuration.

On the Teensy there is a mismatch on the #define names (BRD vs BOARD) so it didn't find the ESP32-C3 on the first pass.
Fixed thanks for testing - thought I had tested before posting but have been having some issues lately with configuration. Changes pushed

Here is the link to the repo again:


To make it easier here are the updated files:

EDIT: forgot to mentioned testes 5g connection and no issues.
 

Attachments

  • teensy_esp32-260916a.zip
    75.1 KB · Views: 28
  • esp32_teensy_v1-260916a.zip
    3.4 KB · Views: 23
Last edited:
Finally got back with the living and was recompiling weather_station_v5 and got this error:
Code:
Alternatives for HX8357_t3n.h: []
ResolveLibrary(HX8357_t3n.h)
  -> candidates: []
Multiple libraries were found for "font_Arial.h"
In file included from /home/wwatson/Arduino/libraries/ILI9341_fonts/src/font_ArialBlack.c:1:
 Used: /home/wwatson/Arduino/libraries/ILI9341_fonts
 Not used: /home/wwatson/arduino-1.8.19-TD1.62/hardware/teensy/avr/libraries/ILI9341_t3
/home/wwatson/Arduino/libraries/ILI9341_fonts/src/font_ArialBlack.h:13:18: fatal error: HX8357_t3n.h: No such file or directory
   13 |         #include "HX8357_t3n.h"
      |                  ^~~~~~~~~~~~~~
compilation terminated.
Using library SPI at version 1.0 in folder: /home/wwatson/arduino-1.8.19-TD1.62/hardware/teensy/avr/libraries/SPI
Using library ST7735_t3 at version 1.1.0 in folder: /home/wwatson/arduino-1.8.19-TD1.62/hardware/teensy/avr/libraries/ST7735_t3
Using library PNGdec at version 1.1.6 in folder: /home/wwatson/Arduino/libraries/PNGdec
Using library ILI9341_fonts at version 1.0 in folder: /home/wwatson/Arduino/libraries/ILI9341_fonts
Using library XPT2046_Touchscreen at version 1.4 in folder: /home/wwatson/arduino-1.8.19-TD1.62/hardware/teensy/avr/libraries/XPT2046_Touchscreen
Using library QNEthernet_WIFI-0.37.0 at version 0.38.0-snapshot in folder: /home/wwatson/Arduino/libraries/QNEthernet_WIFI-0.37.0
Using library ArduinoJson at version 7.4.3 in folder: /home/wwatson/Arduino/libraries/ArduinoJson
Using library ILI9341_t3_Keypad-ST7796_keyboard in folder: /home/wwatson/Arduino/libraries/ILI9341_t3_Keypad-ST7796_keyboard (legacy)
Error compiling for board Teensy 4.1.
Can't seem to find that .h file anywhere??
 
Back
Top