arduino kablosuz haberleşme 3 transmitter 1 receiver Yardım!!!
  • Merhabalar konuyla ilgili biraz olsun bilgisi olan birileri yardımcı olabilirmi ?
    Kodlar alttki gibidir. Transmiterdan gelen bilgi ne olursa olsun receiver serial monitorda, data on pipe=5 olarak görülüyor. data on pipe değerini receiverdan nasıl=2,3 ve 4 olarak alabilirim ? bütün iş transmitterdaki "unsigned char ADDRESS0[5] = { 0xb3,0x43,0x88,0x99,0x45}satırında ve receiverdaki ( radio.available(&pip) değerindebitiyor diye düşünüyorum


    ----------------------------RECEİVER-------------------------------------------------
    #include < SPI.h>
    #include < nRF24L01.h>
    #include < RF24.h>
    #include "printf.h"

    RF24 radio (8, 10);//yours
    //RF24 radio(9,10);//mine

    #define PLOAD_WIDTH 32 // 32 unsigned chars TX payload
    byte pip;
    byte pload_width_now;
    byte newdata;
    unsigned char rx_buf[PLOAD_WIDTH]= {0};
    struct dataStruct1{
    float p1;
    float t1;
    float s1;
    }transmitter1_data;

    struct dataStruct2{
    float p1;
    float t1;
    float s1;
    }transmitter2_data;

    struct dataStruct3{
    float p1;
    float t1;
    float s1;
    }transmitter3_data;

    unsigned char ADDRESS2[1]= {0xb2};
    unsigned char ADDRESS3[1]= {0xb3};
    unsigned char ADDRESS4[1]= {0xb4};
    unsigned char ADDRESS5[1]= {0xb5};


    unsigned char ADDRESS1[5] =
    {
    0xb1,0x43,0x88,0x99,0x45
    }; // Define a static TX address

    unsigned char ADDRESS0[5] =
    {
    0xb0,0x43,0x88,0x99,0x45
    }; // Define a static TX address

    void setup()
    {

    radio.begin();
    printf_begin();
    Serial.begin(115200);
    radio.setDataRate(RF24_250KBPS);
    radio.enableDynamicPayloads();
    radio.openWritingPipe(ADDRESS0);
    radio.openReadingPipe(0,ADDRESS0);
    radio.openReadingPipe(1,ADDRESS1);
    radio.openReadingPipe(2,ADDRESS2);
    radio.openReadingPipe(3,ADDRESS3);
    radio.openReadingPipe(4,ADDRESS4);
    radio.openReadingPipe(5,ADDRESS5);


    radio.startListening();
    radio.printDetails();
    delay(1000);
    }

    void loop()
    {
    if ( radio.available(&pip) )
    {

    // Fetch the payload, and see if this was the last one.
    pload_width_now = radio.getDynamicPayloadSize();

    // If a corrupt dynamic payload is received, it will be flushed
    if(!pload_width_now){

    }
    else
    {

    radio.read( rx_buf, pload_width_now );

    newdata=1;

    // Spew it
    Serial.print(F("Data on pip= "));
    Serial.print(pip);
    Serial.print(F(" Got data size="));
    Serial.print(pload_width_now);
    Serial.print(F(" data="));
    for(byte i=0; i {
    Serial.print(" ");
    Serial.print(rx_buf[i]); // print rx_buf
    }
    Serial.print(" ");
    }
    }
    if(newdata==1)
    {
    newdata=0;

    if(pip==1&&pload_width_now==sizeof(transmitter1_data))
    {
    memcpy(&transmitter1_data, rx_buf, sizeof(transmitter1_data));



    Serial.print(" Pressure//temp//status ");
    Serial.print(transmitter1_data.p1);
    Serial.print(" // ");
    Serial.print(transmitter1_data.t1);
    Serial.print(" // ");
    Serial.print(transmitter1_data.s1);

    }

    if(pip==2&&pload_width_now==sizeof(transmitter2_data))
    {
    memcpy(&transmitter2_data, rx_buf, sizeof(transmitter2_data));




    Serial.print(" Pressure//temp//status ");
    Serial.print(transmitter2_data.p1);
    Serial.print(" // ");
    Serial.print(transmitter2_data.t1);
    Serial.print(" // ");
    Serial.print(transmitter2_data.s1);

    }

    if(pip==3&&pload_width_now==sizeof(transmitter3_data))
    {
    memcpy(&transmitter3_data, rx_buf, sizeof(transmitter3_data));




    Serial.print(" Pressure//temp//status ");
    Serial.print(transmitter3_data.p1);
    Serial.print(" // ");
    Serial.print(transmitter3_data.t1);
    Serial.print(" // ");
    Serial.print(transmitter3_data.s1);

    }



    Serial.println("");
    }

    delay(100);

    }
    --------------------------------Transmitter-------------------------------------------------


    /*
    * this is a working transmitting program that will send digital data out
    */

    #include < SPI.h>
    #include < nRF24L01.h>
    #include < RF24.h>
    #include "printf.h"

    #include

    int address = 0x28; // 28 is the address
    byte byte1, byte2, byte3, byte4;

    RF24 radio (8, 10); //yours
    //RF24 radio(7,8); //mine


    struct dataStruct{
    float p1;
    float t1;
    float s1;
    }transmitter1_data;

    unsigned char ADDRESS0[5] =
    {
    0xb3,0x43,0x88,0x99,0x45//change by me from b1
    }; // Define a static TX address
    //just change b1 to b2 or b3 to send to other pip on resciever

    void setup()
    {
    // Wire.begin();
    radio.begin();
    Serial.begin(9600);
    printf_begin();
    radio.setRetries(15,15);
    radio.enableDynamicPayloads();
    radio.setDataRate(RF24_250KBPS);
    radio.openWritingPipe(ADDRESS0);
    radio.openReadingPipe(0,ADDRESS0);
    radio.stopListening();
    radio.printDetails();
    }

    void loop()
    {

    transmitter1_data.p1=55;//1002.36//
    transmitter1_data.t1=44;//27.33//
    transmitter1_data.s1=11;//15.9//

    bool ok=radio.write(&transmitter1_data, sizeof(transmitter1_data));


    if(ok)//if there is connection under row write
    {

    Serial.println("Pipe 1");
    Serial.println(transmitter1_data.p1);
    Serial.println(transmitter1_data.t1);
    Serial.println(transmitter1_data.s1);

    }
    else
    {
    Serial.println("it failed to send");
    }
    delay(1000);





    }
  • 24L01 ile baska orneklerı denedınızmı genel calısan bır kutuphane pek yok hepsi duzgun calısmıyor

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Login with Facebook
Açık kaynak kültürü gereği, çözdüğünüz problemlerin çözümlerini paylaşmayı lütfen unutmayın.