Send struct data

Viewing 5 reply threads
  • Author
    Posts
    • #24353
      Damien
      Participant

        Good morning,

        I have a projet of connected beehive. I want to follow the weight, the temperature and the humidity.
        I use several sensors and I need to send data using 2 E220-400T30D Ebyte modules.
        I can send a single value (for example the weight). I use the different examples in the librairy.
        But I can’t send all the value with an array.

        Here is a part of my sender header :

        #define ENABLE_RSSI true
        #define RUCHER "Ruche1"
        struct Message {
          char ruche[10]; //ruche = beehive in english
          float poids; //poids= weight in english
        };

        and in sender void loop

        for (float poids=0; poids<100; poids++) //for the test, I increase manually the variable poids to simulate a weight variation. In reality the weight will come from a sensor.
        {
        
          struct Message msg = {RUCHER, poids}; // for the test I only try to send the name of my beehive "Ruche1" and the weight poids
            // Send message
          ResponseStatus rs = e220ttl.sendFixedMessage(0, 3, 23, &msg, sizeof(Message));
          // Check If there is some problem of succesfully send
          
          // Print the data send
        
            
            Serial.print("Message Array length : ");Serial.println(sizeof(msg.ruche));
            Serial.println(msg.ruche);
            Serial.print("Poids Array length : ");Serial.println(sizeof(msg.poids));   
            Serial.println(msg.poids);
            
            Serial.println(rs.getResponseDescription());
            Serial.println(sizeof(Message));
            
            delay(10000);
        }

        For the receiver, the header is the same
        In receiver void loop I have the following code :

            // Print the data received
            Serial.println(rsc.status.getResponseDescription());
            struct Message msg = *(Message*) rsc.data;
            Serial.println(msg.ruche);
            Serial.println(msg.poids);
            Serial.println(sizeof(Message));
            rsc.close();

        And the result shown in serial monitor for the sender :

        Message Array length : 10
        Ruche1
        Poids Array length : 4
        2.00
        Success
        14

        but in serial monitor for the receiver I have :

        Message received! <——– my message is received
        Success <——– success in transmission
        <——– nothing but should be Ruche1
        0.00 <——– 0.00 but should be 2.00
        14

        I don’t understand why the value are not correctly received…
        Is someone could help me please ?

        Thank you very much

        Damien

      • #24355
        Damien
        Participant

          Good morning,

          maybe an idea. It seems to work properly when RSSI is disabled.
          Is there a specfic wiring when RSSI is enabled ?

          Regards

          Damien

          • #24358
            Renzo Mischianti
            Keymaster

              Hi,
              for this first problem, I think It’s a wrong initialization of structure.
              Use a string with 10 characters and retry.
              Bye RM

          • #24356
            Damien
            Participant

              Good morning,

              other point, when I try to set configuration, I have the following message :

              No response from device! (Check wiring)
              12

              What I don’t understand is I can send and receive structured data when I disabled RSSI in my program. But I think the problem could come from configuration settings.
              My wiring is normal (M0 and M1 to GND, Aux Pullup with 4,7kohm, TX to Pin 2 of arduino uno with a 4,7kohm between 3,3V and the pin, RX connected to pin 3 of arduino uno with the 1kohm resistance (voltage divider).

              I strictly respect the Standard configuration (Transparent) wiring.
              When I use the examples (02_SendTransparentTransmission and 07_receiveMessages) i can send and receive structured data, it works fine, I can modify the program to adjust what I want to send. Everything is OK.
              So I think the problem comes from the configuration settings that I can’t modify.

              How is it possible to have a message “No response from device! (Check wiring)” when I try to set configuration whereas I can communicate between my 2 arduinos with E220 which confirms my wiring is correct ?

              Regards

              Damien

            • #24357
              Damien
              Participant

                Good morning,

                I tried with the fully connected shema to be able to set up configuration options.
                There is stil the message “No response from device! (Check wiring)”.

                It prints a configuration even if there is no response from the device.

                What is completely strange is when I send different programs in my arduino and between each transfer I use the GetConfiguration program I have different results whereas I don’t change the configuration. Example :

                No response from device! (Check wiring)
                12
                —————————————-
                HEAD : AE 2 76
                
                AddH : D2
                AddL : 81
                
                Chan : 205 -> 615MHz
                
                SpeedParityBit : 0 -> 8N1 (Default)
                SpeedUARTDatte : 0 -> 1200bps
                SpeedAirDataRate : 0 -> 2.4kbps
                
                OptionSubPacketSett: 0 -> 200bytes (default)
                OptionTranPower : 0 -> 22dBm (Default)
                OptionRSSIAmbientNo: 0 -> Disabled (default)
                
                TransModeWORPeriod : 10 -> 1500ms
                TransModeEnableLBT : 0 -> Disabled (default)
                TransModeEnableRSSI: 0 -> Disabled (default)
                TransModeFixedTrans: 0 -> Transparent transmission (default)
                —————————————-
                No response from device! (Check wiring)
                12
                —————————————-
                HEAD: 0 0 97
                Model no.: 6E
                Version : 73
                Features : 70
                —————————————-
                
                Then
                —————————————-
                HEAD : 28 43 68
                
                AddH : 65
                AddL : 63
                
                Chan : 119 -> 529MHz
                
                SpeedParityBit : 1 -> 8O1
                SpeedUARTDatte : 11 -> 9600bps (default)
                SpeedAirDataRate : 11 -> 4.8kbps
                
                OptionSubPacketSett: 0 -> 200bytes (default)
                OptionTranPower : 0 -> 30dBm (Default)
                OptionRSSIAmbientNo: 1 -> Enabled
                
                TransModeWORPeriod : 1 -> 1000ms
                TransModeEnableLBT : 0 -> Disabled (default)
                TransModeEnableRSSI: 0 -> Disabled (default)
                TransModeFixedTrans: 1 -> Fixed transmission (first three bytes can be used as high/low address and channel)
                —————————————-
                No response from device! (Check wiring)
                
                and after
                
                No response from device! (Check wiring)
                12
                —————————————-
                HEAD : 0 0 74
                
                AddH : 7C
                AddL : DC
                
                Chan : 205 -> 615MHz
                
                SpeedParityBit : 0 -> 8N1 (Default)
                SpeedUARTDatte : 0 -> 1200bps
                SpeedAirDataRate : 0 -> 2.4kbps
                
                OptionSubPacketSett: 0 -> 200bytes (default)
                OptionTranPower : 0 -> 22dBm (Default)
                OptionRSSIAmbientNo: 0 -> Disabled (default)
                
                TransModeWORPeriod : 10 -> 1500ms
                TransModeEnableLBT : 0 -> Disabled (default)
                TransModeEnableRSSI: 0 -> Disabled (default)
                TransModeFixedTrans: 0 -> Transparent transmission (default)
                —————————————-
                No response from device! (Check wiring)
                12
                —————————————-
                HEAD: 0 0 97
                Model no.: 6E
                Version : 73
                Features : 70
                —————————————-
                
                

                How this can be possible ????

                Regards

                Damien

              • #24359
                Renzo Mischianti
                Keymaster

                  For the last problem, I think It can be a power supply problem or wrong wiring, or a fired LoRa device.
                  But you must try to change something to find the correct solution.
                  Bye Renzo

                  • #24862
                    george_santiago
                    Participant

                      Hi Renzo

                      I had a similar problem and I think I found the source of the bug.
                      The bug occurs when using a String type variable for the message. The Sender does not send the last character of the String.
                      Ex: When sending “101”, the Sender sends “10”, that is, it does not send the last character.
                      Ex:

                      static int msg = 100;
                      msg++;
                      String msg_sent = String(msg);
                      Serial.print("Sent Message: ");
                      Serial.println(msg_sent);
                      ResponseStatus rs = e220ttl.sendMessage(msg_sent);

                      I think the bug is on line 831:
                      LoRa_E220.cpp#L831

                      At the moment:
                      byte size = message.length(); // sizeof(message.c_str())+1;

                      I changed it to:
                      byte size = message.length() + 1; // sizeof(message.c_str())+1;

                      Everything worked fine.

                      There are other parts of the code that may need fixing. (I haven’t tested yet)
                      Ex:Line 850:
                      LoRa_E220.cpp#L850

                      ResponseStatus LoRa_E220::sendFixedMessage(byte ADDH, byte ADDL, byte CHAN, const String message){
                      	byte size = message.length(); // sizeof(message.c_str())+1;
                    • #24863
                      george_santiago
                      Participant

                        OBS: I am using RSSI Enabled
                        #define ENABLE_RSSI true

                      • #24877
                        Renzo Mischianti
                        Keymaster

                          Thanks George for your information, I will try to retest the specific case soon.
                          Thanks again Renzo

                        • #24892
                          Renzo Mischianti
                          Keymaster

                            Hi George,
                            I did some test, and the library work correctly, I think you don’t do the correct configuration on the booth device. To send and receive the RSSI, you must set the RSSI parameter on the boot device

                            
                            	configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
                            

                            Use the precompiled configuration for sender and receiver that you can find in the examples.

                            Bye Renzo

                        • #24497
                          Damien
                          Participant

                            Hi,

                            thank you for the responses.
                            When I wire directly M0 and M1 to the 3.3V, I’m able to set configuration and activate RSSI.
                            I will try again with the fully connected shema, but at least, I know I can set configuration.

                            I have another question to configure the power to 30dbm.
                            I put #define E220_30 in header
                            But when I try to put POWER_30 rather than POWER_22 in parameters, it doesn’t recognize POWER_30.

                            An idea ?

                        Viewing 5 reply threads
                        • You must be logged in to reply to this topic.
                        Exit mobile version