besoin d'aide

bonjour, qui peux m'aider il y a une probleme dans mon code recepteur le but est pour lire deux valeurs analogique avec RF 433mhz et la librarie virtual wire

#include <VirtualWire.h>

int ledPin = 13;
int Sensor1Data;
int Sensor2Data;
// RF Transmission container
char Sensor1CharMsg[4];
char Sensor2CharMsg[4];
void setup() {
  Serial.begin(115200);
  
  // sets the digital pin as output
  pinMode(ledPin, OUTPUT);      
    
    vw_set_ptt_inverted(true); 
    vw_set_rx_pin(12);
    // Bits per sec
    vw_setup(2000);     
    // Start the receiver PLL running
    vw_rx_start();       

} // END void setup

void loop(){
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
    
    // Non-blocking
    if (vw_get_message(buf, &buflen)) 
    {
    int i;
        // Turn on a light to show received good message 
        digitalWrite(13, true); 
    
        // Message with a good checksum received, dump it. 
        for (i = 0; i < buflen; i++)
    {            
          // Fill Sensor1CharMsg Char array with corresponding 
          // chars from buffer.   
          Sensor1CharMsg[i] = char(buf[i]);
 
    }
             Sensor1CharMsg[buflen] = '\0';
  float   Sensor1Data = atoi(Sensor1CharMsg)*(5.0/ 1023.0);
        Serial.print(Sensor1Data);
        
        // Null terminate the char array
        // This needs to be done otherwise problems will occur
        // when the incoming messages has less digits than the
        // one before. 
   
        
        // Convert Sensor1CharMsg Char array to integer
   
        // DEBUG 
      
        
        // END DEBUG
                
        // Turn off light to and await next message 
        digitalWrite(13, false);
        
    }
    
}

le code transmetteur je croie vraie

#include <VirtualWire.h>

int ledPin = 13; 
     int Sensor1Pin = A2;
    int Sensor2Pin = A3; 
     int Sensor1Data;
 char Sensor1CharMsg[4];
     int Sensor2Data;
 char Sensor2CharMsg[4];
void setup() {
 pinMode(Sensor1Pin,INPUT);
 pinMode(Sensor2Pin,INPUT);
 vw_set_tx_pin(12);
 vw_set_ptt_inverted(true); 
 vw_setup(2000);     // Bits per sec
 pinMode(ledPin,OUTPUT);
}
void loop() {
  
  // Read and store Sensor 1 data
    Sensor1Data = analogRead(Sensor1Pin);
  // Convert integer data to Char array directly 
        itoa(Sensor1Data,Sensor1CharMsg,10);
         Serial.print(Sensor1Data);
         Serial.println(Sensor1CharMsg);
         delay(10);
          digitalWrite(13, true); // Turn on a light to show transmitting

         vw_send((uint8_t *)Sensor1CharMsg, strlen(Sensor1CharMsg));
 vw_wait_tx(); // Wait until the whole message is gone
 // Turn off a light after transmission
 delay(30); 
     Sensor2Data = analogRead(Sensor2Pin);
  // Convert integer data to Char array directly 
        itoa(Sensor2Data,Sensor2CharMsg,10);
           Serial.print(Sensor2Data);
           Serial.println(Sensor2CharMsg);
           delay(10);
 //
 digitalWrite(13, true); // Turn on a light to show transmitting
 vw_send((uint8_t *)Sensor2CharMsg, strlen(Sensor2CharMsg));
 vw_wait_tx(); // Wait until the whole message is gone
 // Turn off a light after transmission
 delay(30); 
 
} // END void loop...

mercii :wink: :wink:

si votre analogRead retourne une valeur >= 1000 alors vous allez faire un dépassement de mémoire (Sensor1CharMsg ou Sensor2CharMsg) car itoa(Sensor1Data,Sensor1CharMsg,10); ajoutera un '\0' à la fin de la chaîne

J-M-L:
si votre analogRead retourne une valeur >= 1000 alors vous allez faire un dépassement de mémoire (Sensor1CharMsg ou Sensor2CharMsg) car itoa(Sensor1Data,Sensor1CharMsg,10); ajouter un '\0' à la fin de la chaîne

nn la valeur est <= 1000 tu peut répéter le code avec deux capteurs svp car je compile le code mais toujours il y a un erreur et merci pour votre reponse
dsl pour la mauvaise écriture

Si dans l'émetteur vous mettez "123" dans la première chaîne de caracteres et "567" dans la seconde qu'est ce qu'il s'affiche sur la console dans le récepteur?