Page 6 sur 7

Re: Montages ESP32 S3 WROOM

Posté : 09 oct. 2026, 20:28
par patlum
:PetitPoucejpg: :PetitPoucejpg:
Le NE 555 est un composant que j'utilise beaucoup.
Simple, pas cher, facile à utiliser et qui rend de grand service dans une électronique à la portée de tous.

Re: Montages ESP32 S3 WROOM

Posté : 09 oct. 2026, 20:32
par ramasoft
Ah oui, c'est un composant incontournable et pas cher en plus.

Re: Montages ESP32 S3 WROOM

Posté : 09 oct. 2026, 20:40
par Amigorl
J'en ai 50... Ça suffira ? :mdr3:

Re: Montages ESP32 S3 WROOM

Posté : 10 oct. 2026, 00:02
par Clem68
Patrick

Intéressant, la démo avec le NE555 et plus simple, bien entendu suivant l'usage du projet.

Exercice: N°19

Moteur pas à pas
ex19.jpg
Le sketch:

Code : Tout sélectionner

/**********************************************************************
  Filename    : Drive Stepper Motor
  Description : Use ULN2003 to drive the stepper motor.
  Auther      : www.freenove.com
  Modification: 2024/06/19
**********************************************************************/
// Conncet the port of the stepper motor driver
int outPorts[] = {14, 27, 26, 25};

void setup() {
  // set pins to output
  for (int i = 0; i < 4; i++) {
    pinMode(outPorts[i], OUTPUT);
  }
}

void loop()
{
  // Rotate a full turn
  moveSteps(true, 32 * 64, 3);
  delay(1000);
  // Rotate a full turn towards another direction
  moveSteps(false, 32 * 64, 3);
  delay(1000);
}

//Suggestion: the motor turns precisely when the ms range is between 3 and 20
void moveSteps(bool dir, int steps, byte ms) {
  for (unsigned long i = 0; i < steps; i++) {
    moveOneStep(dir); // Rotate a step
    delay(constrain(ms,3,20));        // Control the speed
  }
}

void moveOneStep(bool dir) {
  // Define a variable, use four low bit to indicate the state of port
  static byte out = 0x01;
  // Decide the shift direction according to the rotation direction
  if (dir) {  // ring shift left
    out != 0x08 ? out = out << 1 : out = 0x01;
  }
  else {      // ring shift right
    out != 0x01 ? out = out >> 1 : out = 0x08;
  }
  // Output singal to each port
  for (int i = 0; i < 4; i++) {
    digitalWrite(outPorts[i], (out & (0x01 << i)) ? HIGH : LOW);
  }
}

void moveAround(bool dir, int turns, byte ms){
  for(int i=0;i<turns;i++)
    moveSteps(dir,32*64,ms);
}
void moveAngle(bool dir, int angle, byte ms){
  moveSteps(dir,(angle*32*64/360),ms);
}


@+

Re: Montages ESP32 S3 WROOM

Posté : 10 oct. 2026, 08:09
par likiki
Cool

Re: Montages ESP32 S3 WROOM

Posté : 10 oct. 2026, 21:40
par Clem68
Exercice: N°20

Afficheur LCD 1602
ex20.jpg
Le sketch:

Code : Tout sélectionner

    /**********************************************************************
      Filename    : Drive LiquidCrystal I2C to display characters
      Description : I2C is used to control the display characters of LCD1602.
      Auther      : www.freenove.com
      Modification: 2022/10/25
    **********************************************************************/
    #include <LiquidCrystal_I2C.h>
    #include <Wire.h>

    #define SDA 14                    //Define SDA pins
    #define SCL 13                    //Define SCL pins

    /*
     * note:If lcd1602 uses PCF8574T, IIC's address is 0x27,
     *      or lcd1602 uses PCF8574AT, IIC's address is 0x3F.
    */
    LiquidCrystal_I2C lcd(0x27,16,2);
    void setup() {
      Wire.begin(SDA, SCL);          // attach the IIC pin
      if (!i2CAddrTest(0x27)) {
        lcd = LiquidCrystal_I2C(0x3F, 16, 2);
      }
      lcd.init();                    // LCD driver initialization
      lcd.backlight();                // Open the backlight
      lcd.setCursor(0,0);            // Move the cursor to row 0, column 0
      lcd.print("hello, world!");    // The print content is displayed on the LCD
    }

    void loop() {
      lcd.setCursor(0,1);            // Move the cursor to row 1, column 0
      lcd.print("Counter:");          // The count is displayed every second
      lcd.print(millis() / 1000);
      delay(1000);
    }

    bool i2CAddrTest(uint8_t addr) {
      Wire.beginTransmission(addr);
      if (Wire.endTransmission() == 0) {
        return true;
      }
      return false;
    }


@+

Re: Montages ESP32 S3 WROOM

Posté : 12 oct. 2026, 21:08
par Clem68
Exercice: N°21.1

Télémétrie ultrasonique
ex21.jpg
Le sketch:

Code : Tout sélectionner

/**********************************************************************
  Filename    : Ultrasonic Ranging
  Description : Use the ultrasonic module to measure the distance.
  Auther      : www.freenove.com
  Modification: 2022/10/25
**********************************************************************/
#define trigPin 13 // define TrigPin
#define echoPin 14 // define EchoPin.
#define MAX_DISTANCE 700 // Maximum sensor distance is rated at 400-500cm.
//timeOut= 2*MAX_DISTANCE /100 /340 *1000000 = MAX_DISTANCE*58.8
float timeOut = MAX_DISTANCE * 60;
int soundVelocity = 340; // define sound speed=340m/s

void setup() {
  pinMode(trigPin,OUTPUT);// set trigPin to output mode
  pinMode(echoPin,INPUT); // set echoPin to input mode
  Serial.begin(115200);   // Open serial monitor at 115200 baud to see ping results.
}

void loop() {
  delay(100); // Wait 100ms between pings (about 20 pings/sec).
  Serial.printf("Distance: ");
  Serial.print(getSonar()); // Send ping, get distance in cm and print result
  Serial.println("cm");
}

float getSonar() {
  unsigned long pingTime;
  float distance;
  // make trigPin output high level lasting for 10μs to triger HC_SR04
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  // Wait HC-SR04 returning to the high level and measure out this waitting time
  pingTime = pulseIn(echoPin, HIGH, timeOut);
  // calculate the distance according to the time
  distance = (float)pingTime * soundVelocity / 2 / 10000;
  return distance; // return the distance value
}


@+

Re: Montages ESP32 S3 WROOM

Posté : 13 oct. 2026, 16:41
par Clem68
Exercice: N°21.2

Circuit identique à l'exercice précédent.

Ajout d'une bibliothèque tierce dans le code:UltrasonicSensor

Le sketch:

Code : Tout sélectionner

/**********************************************************************
  Filename    : Ultrasonic Ranging
  Description : Use the ultrasonic module to measure the distance.
  Auther      : www.freenove.com
  Modification: 2022/10/25
**********************************************************************/
#include <UltrasonicSensor.h>

UltrasonicSensor ultrasonic(13, 14);

void setup() {
  Serial.begin(115200);
 
  int temperature = 22;
  ultrasonic.setTemperature(temperature);
}

void loop() {
  int distance = ultrasonic.distanceInCentimeters();
  Serial.printf("Distance: %dcm\n",distance);
  delay(300);
}


@+

Re: Montages ESP32 S3 WROOM

Posté : 14 oct. 2026, 21:26
par Clem68
Exercice: N°22

Clavier matriciel
ex22.jpg
Le sketch:

Code : Tout sélectionner

    /**********************************************************************
      Filename    : Get Input Characters
      Description : Call the Keypad function to set the matrix keyboard and get the value for the matrix keyboard
      Auther      : www.freenove.com
      Modification: 2022/10/25
    **********************************************************************/
    #include <Keypad.h>

    // define the symbols on the buttons of the keypad
    char keys[4][4] = {
      {'1', '2', '3', 'A'},
      {'4', '5', '6', 'B'},
      {'7', '8', '9', 'C'},
      {'*', '0', '#', 'D'}
    };

    byte rowPins[4] = {14, 13, 12, 11}; // connect to the row pinouts of the keypad
    byte colPins[4] = {10,  9,  8, 18};  // connect to the column pinouts of the keypad

    // initialize an instance of class NewKeypad
    Keypad myKeypad = Keypad(makeKeymap(keys), rowPins, colPins, 4, 4);

    void setup() {
      Serial.begin(115200); // Initialize the serial port and set the baud rate to 115200
      Serial.println("ESP32S3 is ready!");  // Print the string "UNO is ready!"
    }

    void loop() {
      // Get the character input
      char keyPressed = myKeypad.getKey();
      // If there is a character input, sent it to the serial port
      if (keyPressed) {
        Serial.println(keyPressed);
      }
    }


@+

Re: Montages ESP32 S3 WROOM

Posté : 15 oct. 2026, 00:18
par Amigorl
Le télémètre est très intéressant, existe t il un modèle plus petit ?

Re: Montages ESP32 S3 WROOM

Posté : 15 oct. 2026, 22:06
par Clem68
Le télémètre est très intéressant, existe t il un modèle plus petit
Aucune idée, regarde sur Ali ou Amazon

Exercice: N°22.1

Piloter un servomoteur avec un pavé numérique
ex22.1.jpg
Le sketch:

Code : Tout sélectionner

/**********************************************************************
  Filename    : Combination Lock
  Description : Make a simple combination lock.
  Auther      : www.freenove.com
  Modification: 2022/10/26
**********************************************************************/
#include <Keypad.h>

#define SERVO_PIN 21  //define the pwm pin
#define SERVO_CHN 0  //define the pwm channel
#define SERVO_FRQ 50  //define the pwm frequency
#define SERVO_BIT 12  //define the pwm precision
#define BUZZER_PIN 17 // Define the buzzer pin

void servo_set_pin(int pin);
void servo_set_angle(int angle);

byte rowPins[4] = {14, 13, 12, 11}; // connect to the row pinouts of the keypad
byte colPins[4] = {10,  9,  8, 18}; // connect to the column pinouts of the keypad

// define the symbols on the buttons of the keypad
char keys[4][4] = {
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

// initialize an instance of class NewKeypad
Keypad myKeypad = Keypad(makeKeymap(keys), rowPins, colPins, 4, 4);

char passWord[] = {"1234"}; // Save the correct password

void setup() {
  servo_set_pin(SERVO_PIN);
  pinMode(BUZZER_PIN, OUTPUT);
  Serial.begin(115200);
}

void loop() {
  static char keyIn[4];    // Save the input character
  static byte keyInNum = 0; // Save the the number of input characters
  char keyPressed = myKeypad.getKey();  // Get the character input
  // Handle the input characters
  if (keyPressed) {
    // Make a prompt tone each time press the key
    digitalWrite(BUZZER_PIN, HIGH);
    delay(100);
    digitalWrite(BUZZER_PIN, LOW);
    // Save the input characters
    keyIn[keyInNum++] = keyPressed;
    // Judge the correctness after input
    if (keyInNum == 4) {
      bool isRight = true;            // Save password is correct or not
      for (int i = 0; i < 4; i++) {  // Judge each character of the password is correct or not
        if (keyIn[i] != passWord[i])
          isRight = false;            // Mark wrong passageword if there is any wrong character.
      }
      if (isRight) {                  // If the input password is right
        servo_set_angle(90);          // Open the switch
        delay(2000);                  // Delay a period of time
        servo_set_angle(0);            // Close the switch
        Serial.println("passWord right!");
      }
      else {                          // If the input password is wrong
        digitalWrite(BUZZER_PIN, HIGH);// Make a wrong password prompt tone
        delay(1000);
        digitalWrite(BUZZER_PIN, LOW);
        Serial.println("passWord error!");
      }
      keyInNum = 0; // Reset the number of the input characters to 0
    }
  }
}

void servo_set_pin(int pin) {
  ledcAttachChannel(pin, SERVO_FRQ, SERVO_BIT, SERVO_CHN);
}

void servo_set_angle(int angle) {
  if (angle > 180 || angle < 0)
    return;
  long pwm_value = map(angle, 0, 180, 103, 512);
  ledcWrite(SERVO_PIN, pwm_value);
}
Si le code tapé sur le clavier est mauvais,c'est le buzzer qui retentit.



@+

Re: Montages ESP32 S3 WROOM

Posté : 16 oct. 2026, 08:17
par likiki
:hhhaaaa: pas mal.

Re: Montages ESP32 S3 WROOM

Posté : 16 oct. 2026, 14:13
par Clem68
Exercice: N°23.1

Télécommande infrarouge
ex23.1.jpg
Le sketch:

Code : Tout sélectionner

    /**********************************************************************
      Filename    : Infrared Remote Control
      Description : Decode the infrared remote control and print it out through the serial port.
      Auther      : www.freenove.com
      Modification: 2024/07/01
    **********************************************************************/
    #include "Freenove_IR_Lib_for_ESP32.h"

    const uint16_t recvPin = 21;              // Infrared receiving pin
    Freenove_ESP32_IR_Recv ir_recv(recvPin);  // Create a class object used to receive class

    void setup() {
      Serial.begin(115200);      // Initialize the serial port and set the baud rate to 115200
      Serial.print("IRrecvDemo is now running and waiting for IR message on Pin ");
      Serial.println(recvPin);  //print the infrared receiving pin
    }

    void loop() {
      ir_recv.task();                  //Get IR receice data.
      if(ir_recv.nec_available()){    //The data of the NEC protocol is checked
        //Print IR data.
        Serial.printf("IR Code:  %#x\r\n", ir_recv.data());
      }
    }
Ouvrir le moniteur série:

A chaque appui sur une touche, le code hexadécimal correspondant à la touche s'affiche.
Si on laisse la touche enfoncée, le code F s'affichera



@+

Re: Montages ESP32 S3 WROOM

Posté : 16 oct. 2026, 14:24
par likiki
:PetitPoucejpg:

Tu peut mettre un Delay (500) après affichage du code de touche. Cela évite les ffffff

Re: Montages ESP32 S3 WROOM

Posté : 19 oct. 2026, 21:26
par Clem68
Tu peut mettre un Delay (500) après affichage du code de touche. Cela évite les ffffff
Exact

Exercice: N°23.2

Contrôle d'une LED par télécommande infrarouge
ex23.2.jpg
Le sketch:

Code : Tout sélectionner

    /**********************************************************************
      Filename    : Control LED through Infrared Remote
      Description : Remote control the LED with the infrared remote control.
      Auther      : www.freenove.com
      Modification: 2024/07/01
    **********************************************************************/
    #include "Freenove_IR_Lib_for_ESP32.h"

    const uint16_t recvPin = 21;  // Infrared receiving pin
    Freenove_ESP32_IR_Recv ir_recv(recvPin);  // Create a class object used to receive class

    int ledPin = 13;              // the number of the LED pin
    int buzzerPin = 14;          // the number of the buzzer pin

    void setup()
    {
      //Initialize the ledc configuration
      ledcAttachChannel(ledPin, 1000, 8, 0);// set the frequency,solution_bits,channel to GPIO pin
      pinMode(buzzerPin, OUTPUT);          // set buzzer pin into output mode
    }

    void loop() {
      ir_recv.task();                  // Get IR receice data.
      if(ir_recv.nec_available()){      // The data of the NEC protocol is checked
        handleControl(ir_recv.data());  // Handle the commands from remote control
      }
    }

    void handleControl(unsigned long value) {
      // Make a sound when it rereives commands
      digitalWrite(buzzerPin, HIGH);
      delay(100);
      digitalWrite(buzzerPin, LOW);
      // Handle the commands
      switch (value) {
        case 0xff6897:              // Receive the number '0'
          ledcWrite(ledPin, 0);    // Turn off LED
          break;
        case 0xff30CF:              // Receive the number '1'
          ledcWrite(ledPin, 7);    // Dimmest brightness
          break;
        case 0xff18E7:              // Receive the number '2'
          ledcWrite(ledPin, 63);    // Medium brightness
          break;
        case 0xff7A85:              // Receive the number '3'
          ledcWrite(ledPin, 255);  // Strongest brightnss
          break;
      }
    }

Lorsque l'on appuie sur la touche 0 ou 1 ou 2 ou 3 la luminosité de la LED augmente ou diminue si on fait la procédure inverse. Également le buzzer retentit à chaque appui sur une touche de la télécommande.



@+

Re: Montages ESP32 S3 WROOM

Posté : 20 oct. 2026, 21:17
par Clem68
Exercice: N°24.1

Contrôle température et humidité
ex24.1.jpg
Le sketch:

Code : Tout sélectionner

    /**********************************************************************
      Filename    : Temperature and Humidity Sensor
      Description : Use DHT11 to measure temperature and humidity.Print the result to the serial port.
      Auther      : www.freenove.com
      Modification: 2022/10/26
    **********************************************************************/
    #include "DHTesp.h"

    DHTesp dht;    //Define the DHT object
    int dhtPin = 21;//Define the dht pin

    void setup() {
      dht.setup(dhtPin, DHTesp::DHT11);//Initialize the dht pin and dht object
      Serial.begin(115200);              //Set the baud rate as 115200
    }

    void loop() {
      flag:TempAndHumidity newValues = dht.getTempAndHumidity();//Get the Temperature and humidity
      if (dht.getStatus() != 0) {//Judge if the correct value is read
        goto flag;              //If there is an error, go back to the flag and re-read the data
      }
      Serial.println(" Temperature:" + String(newValues.temperature) +
      " Humidity:" + String(newValues.humidity));
      delay(2000);
    }




@+

Re: Montages ESP32 S3 WROOM

Posté : 21 oct. 2026, 00:05
par Amigorl
:bienv:

Alors ça ça m'intéresse pour contrôler la température de la maison, le taux d'humidité, en cas d'absence, le tout accessible dur un smartphone à l'autre bout du monde.

Un p'tit serveur web, le wifi de l'Esp32 connecté à la box et le tour est joué...

Un p'tit contrôle d'accès pour la sécurité et un dyndns pour bénéficier d'une url lisible.

Re: Montages ESP32 S3 WROOM

Posté : 21 oct. 2026, 21:50
par Clem68
:merciiii:

Voici une version 2

Exercice: N°24.2

Contrôle température et humidité V2
ex24.2.jpg
Le sketch:

Code : Tout sélectionner

    /**********************************************************************
      Filename    : Temperature and Humidity Sensor
      Description : Use DHT11 to measure temperature and humidity.Print the result to the LCD1602.
      Auther      : www.freenove.com
      Modification: 2024/07/01
    **********************************************************************/
    #include <Wire.h>
    #include <LiquidCrystal_I2C.h>
    #include "DHTesp.h"

    #define SDA 14                    //Define SDA pins
    #define SCL 13                    //Define SCL pins

    DHTesp dht;                      // create dht object
    LiquidCrystal_I2C lcd(0x27,16,2); //initialize the LCD
    int dhtPin = 21;                  // the number of the DHT11 sensor pin

    void setup() {
      Wire.begin(SDA, SCL);          // attach the IIC pin
      if (!i2CAddrTest(0x27)) {
        lcd = LiquidCrystal_I2C(0x3F, 16, 2);
      }
      lcd.init();                    // LCD driver initialization
      lcd.backlight();                // Open the backlight
      dht.setup(dhtPin, DHTesp::DHT11); //attach the dht pin and initialize it
    }

    void loop() {
      // read DHT11 data and save it
      flag:TempAndHumidity DHT = dht.getTempAndHumidity();
      if (dht.getStatus() != 0) {      //Determine if the read is successful, and if it fails, go back to flag and re-read the data
        goto flag;
      } 
      lcd.setCursor(0, 0);              //set the cursor to column 0, line 1
      lcd.print("Temperature:");        //display the Humidity on the LCD1602
      lcd.print(DHT.temperature); 
      lcd.setCursor(0, 1);              //set the cursor to column 0, line 0
      lcd.print("Humidity  :");        //display the Humidity on the LCD1602
      lcd.print(DHT.humidity); 
      delay(2000);
    }

    bool i2CAddrTest(uint8_t addr) {
      Wire.beginTransmission(addr);
      if (Wire.endTransmission() == 0) {
        return true;
      }
      return false;
    }




@+

Re: Montages ESP32 S3 WROOM

Posté : 22 oct. 2026, 21:51
par Clem68
Exercice: N°25

Capteur de mouvement infrarouge
ex25.jpg
Le sketch:

Code : Tout sélectionner

    /**********************************************************************
      Filename    : Infrared Motion Sensor
      Description : LED lamp is controlled by Infrared Motion Sensor
      Auther      : www.freenove.com
      Modification: 2022/10/26
    **********************************************************************/
    int sensorPin = 13; // the number of the infrared motion sensor pin
    int ledPin = 14;    // the number of the LED pin

    void setup() {
      pinMode(sensorPin, INPUT);  // initialize the sensor pin as input
      pinMode(ledPin, OUTPUT);    // initialize the LED pin as output
    }

    void loop() {
      // Turn on or off LED according to Infrared Motion Sensor
      digitalWrite(ledPin, digitalRead(sensorPin));
      delay(1000);              // wait for a second
    }
A chaque détection de mouvement, la LED s'allume.



@+

Re: Montages ESP32 S3 WROOM

Posté : 22 oct. 2026, 22:50
par patrice_b
:bienv: :bienv:

Sacré dossier bien documenté !!

Re: Montages ESP32 S3 WROOM

Posté : 23 oct. 2026, 17:34
par Clem68
:merciiii: !

Exercice: N°26

Capteur d'altitude
ex26.jpg
Le sketch:

Code : Tout sélectionner

    /**********************************************************************
      Filename    : Acceleration detection
      Description : Read the MPU6050 data and print it out through the serial port
      Auther      : www.freenove.com
      Modification: 2022/10/26
    **********************************************************************/
    #include <MPU6050_tockn.h>
    #include <Wire.h>

    #define SDA 13
    #define SCL 14

    MPU6050 mpu6050(Wire);//Attach the IIC
    int16_t ax,ay,az;//define acceleration values of 3 axes
    int16_t gx,gy,gz;//define variables to save the values in 3 axes of gyroscope

    long timer = 0;

    void setup() {
      Serial.begin(115200);
      Wire.begin(SDA, SCL);          //attach the IIC pin
      mpu6050.begin();               //initialize the MPU6050
      mpu6050.calcGyroOffsets(true); //get the offsets value
    }

    void loop() {
      if(millis() - timer > 1000){   //each second printf the data
        mpu6050.update();            //update the MPU6050
        getMotion6();                //gain the values of Acceleration and Gyroscope value
        Serial.print("\na/g:\t");
        Serial.print(ax); Serial.print("\t");
        Serial.print(ay); Serial.print("\t");
        Serial.print(az); Serial.print("\t");
        Serial.print(gx); Serial.print("\t\t");
        Serial.print(gy); Serial.print("\t\t");
        Serial.println(gz);
        Serial.print("a/g:\t");
        Serial.print((float)ax / 16384); Serial.print("g\t");
        Serial.print((float)ay / 16384); Serial.print("g\t");
        Serial.print((float)az / 16384); Serial.print("g\t");
        Serial.print((float)gx / 131); Serial.print("d/s \t");
        Serial.print((float)gy / 131); Serial.print("d/s \t");
        Serial.print((float)gz / 131); Serial.print("d/s \n");
        timer = millis();
      }
    }
    void getMotion6(void){
      ax=mpu6050.getRawAccX();//gain the values of X axis acceleration raw data
      ay=mpu6050.getRawAccY();//gain the values of Y axis acceleration raw data
      az=mpu6050.getRawAccZ();//gain the values of Z axis acceleration raw data
      gx=mpu6050.getRawGyroX();//gain the values of X axis Gyroscope raw data
      gy=mpu6050.getRawGyroX();//gain the values of Y axis Gyroscope raw data
      gz=mpu6050.getRawGyroX();//gain the values of Z axis Gyroscope raw data
    }




@+

Re: Montages ESP32 S3 WROOM

Posté : 23 oct. 2026, 18:20
par likiki
:PetitPoucejpg: :PetitPoucejpg: :PetitPoucejpg:

Re: Montages ESP32 S3 WROOM

Posté : 24 oct. 2026, 17:29
par Clem68
:merciiii:

Exercice: N°27

Bluetooth
ex27.jpg
Le sketch:

Code : Tout sélectionner

    /**********************************************************************
      Filename    : BLE_USART
      Description : Esp32 communicates with the phone by BLE and sends incoming data via a serial port
      Auther      : www.freenove.com
      Modification: 2024/07/01
    **********************************************************************/
    #include "BLEDevice.h"
    #include "BLEServer.h"
    #include "BLEUtils.h"
    #include "BLE2902.h"
     
    BLECharacteristic *pCharacteristic;
    bool deviceConnected = false;
    uint8_t txValue = 0;
    long lastMsg = 0;
    String rxload="Test\n";
     
    #define SERVICE_UUID           "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"
    #define CHARACTERISTIC_UUID_RX "6E400002-B5A3-F393-E0A9-E50E24DCCA9E"
    #define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"
     
    class MyServerCallbacks: public BLEServerCallbacks {
        void onConnect(BLEServer* pServer) {
          deviceConnected = true;
        };
        void onDisconnect(BLEServer* pServer) {
          deviceConnected = false;
          //pServer->getAdvertising()->start(); //Reopen the pServer and wait for the connection.
        }
    };
     
    class MyCallbacks: public BLECharacteristicCallbacks {
        void onWrite(BLECharacteristic *pCharacteristic) {
          String rxValue = pCharacteristic->getValue();
          if (rxValue.length() > 0) {
            rxload="";
            for (int i = 0; i < rxValue.length(); i++){
              rxload +=(char)rxValue[i];
            }
          }
        }
    };
     
    void setupBLE(String BLEName){
      const char *ble_name=BLEName.c_str();
      BLEDevice::init(ble_name);
      BLEServer *pServer = BLEDevice::createServer();
      pServer->setCallbacks(new MyServerCallbacks());
      BLEService *pService = pServer->createService(SERVICE_UUID);
      pCharacteristic= pService->createCharacteristic(CHARACTERISTIC_UUID_TX,BLECharacteristic::PROPERTY_NOTIFY);
      pCharacteristic->addDescriptor(new BLE2902());
      BLECharacteristic *pCharacteristic = pService->createCharacteristic(CHARACTERISTIC_UUID_RX,BLECharacteristic::PROPERTY_WRITE);
      pCharacteristic->setCallbacks(new MyCallbacks());
      pService->start();
      pServer->getAdvertising()->start();
      Serial.println("Waiting a client connection to notify...");
    }

    void setup() {
      Serial.begin(115200);
      setupBLE("ESP32S3_Bluetooth");
    }
     
    void loop() {
      long now = millis();
      if (now - lastMsg > 100) {
        if (deviceConnected&&rxload.length()>0) {
            Serial.println(rxload);
            rxload="";
        }
        if(Serial.available()>0){
            String str=Serial.readString();
            const char *newValue=str.c_str();
            pCharacteristic->setValue(newValue);
            pCharacteristic->notify();
        }
        lastMsg = now;
      }
    }
Le tuto

Résultat:
ex27.1.JPG
ex27.2.JPG
@+

Re: Montages ESP32 S3 WROOM

Posté : 24 oct. 2026, 17:47
par likiki
:bienv: :bienv: :bienv: :bienv: :bienv: :bienv: :bienv:

Re: Montages ESP32 S3 WROOM

Posté : 25 oct. 2026, 09:00
par Amigorl
Alors ça, c'est très intéressant !

Si je comprends bien il s'agit de pourvoir établir une pseudo liaison série via DentBleue : :bienv:

Question :

De quel chapeau sort la valeur 6E400001-B5A3-F393-E0A9-E50E24DCCA9E ?