ESPnow protocol with Teensy4.1

New_bee

Active member
I am just wondering if anyone has successfully transmitted data using ESPnow wireless protocol.

I have the following boards

ADXL1002
Teensy4.1
ESP8266-01 -2X
ESP-C3-12F -2X

I have connected the ADXL1002 to the Teensy4.1 but struggling with sending the data via ESPnow
 
Yes I have it working fine. Teensy Commanding an ESP32C3 to switch a Sonoff(ESP8266) on/off via ESPNow.
Please show your code for the three processors.
You do realise that ESP Now commands for ESP8266 and ESP32 are slightly different (they still talk to each other).
 
Yes I have it working fine. Teensy Commanding an ESP32C3 to switch a Sonoff(ESP8266) on/off via ESPNow.
Please show your code for the three processors.
You do realise that ESP Now commands for ESP8266 and ESP32 are slightly different (they still talk to each other).

This is the code I am using to read the raw value of the ADXL1002 but I dont know the how to wire the ESP32 or ESP8266 to it

HTML:
#include <ADC.h>

#define ADXL1002_PIN A9
#define ZERO_G_VOLTAGE 1.65 // in volts
#define SENSITIVITY 0.4 // in volts/g

ADC *adc = new ADC();
elapsedMicros sinceLastSample; // timer for sampling
const uint32_t samplingIntervalUs = 1; // sampling interval in microseconds

void setup() {
  Serial.begin(2000000);
  adc->adc0->setAveraging(1); // set number of averages
  adc->adc0->setResolution(12); // set bits of resolution
  adc->adc0->setConversionSpeed(ADC_CONVERSION_SPEED::VERY_HIGH_SPEED); // change the conversion speed
  adc->adc0->setSamplingSpeed(ADC_SAMPLING_SPEED::VERY_HIGH_SPEED); // change the sampling speed
  sinceLastSample = 0;
}

void loop() {
  if (sinceLastSample >= samplingIntervalUs) {
    sinceLastSample = 0; // reset the timer
    int rawValue = adc->analogRead(ADXL1002_PIN);
    float voltage = rawValue * 3.3 / 4095.0;
    float acceleration = (voltage - ZERO_G_VOLTAGE) * (1000.0 / SENSITIVITY);
    Serial.println(rawValue);
  }
}
 
but struggling with sending the data via ESPnow
There is NO ESPNow code in that code.
Where is the code for the ESPs?

but I dont know the how to wire the ESP32 or ESP8266 to it
Why not send it over serial from the Teensy to the ESP and then use ESPNow to send between ESPs.
 
There is NO ESPNow code in that code.
Where is the code for the ESPs?


Why not send it over serial from the Teensy to the ESP and then use ESPNow to send between ESPs.
Can you help with the serial connection ?

Teensy TX ----- ESP RX
RX ----- TX
GND --------GND
3.3V ---------3.3V
 
Yep, that should work, though I would not recommend powering the ESPs from the Teensy (ESP takes too much power), so no need for the 3V3 connection.
 
Back
Top