6 years, 9 months ago.  This question has been closed. Reason: Unclear question

LoRa data transmission

I'm attempting to set up a communication between a MTCAP-LEU1-868-001L (Multiconnect Conduit AP) and a MultiConnect xDot via LoRa. To achieve this I've imported the dot_example library and adapted it to suit my needs, now both units connect to eachother yet the data makes no sense.

To me the issue seems to have 2 parts, the first is the transmit data vector not changing when I add the data to it. It seems to have a fixed value no matter what I do to it.

The second part is the data received by the gateway, it looks in no way related to what has been sent and changes when the transmitted data has not.

https://ibb.co/b7iSfQ

Get ADC data and transmit

        uint16_t t, temp;
        int x;
        std::vector<uint8_t> tx_data;
        
        // join network if not joined
        if (!dot->getNetworkJoinStatus()) {
            join_network();
        }
    
        //Get ADC data and average it
        x = 0;
        for(int i = 0; i < 10; i++) {
            temp = ain0.read_u16();
            if(temp != 0) {
                t += temp;
                x++;
            }
        }
        t /= x;
        
        //Add data to transmit data
        tx_data.push_back((t >> 8) & 0xFF);
        tx_data.push_back(t & 0xFF);
        logInfo("ADC0 temp: %lu [0x%04X]", t, t);
        logInfo("Data vector: %lu [0x%04X]", tx_data, tx_data);
        
        send_data(tx_data);

1 Answer

6 years, 8 months ago.

t is undefined, so you'll get undefined behavior on this variable.

Change your declaration to:

uint16_t t = 0;

Also, this is not going to work: logInfo("Data vector: %lu [0x%04X]", tx_data, tx_data); as you're printing the object there. If you want to read the data in the tx buffer, do:

        logInfo("Data vector: %02x %02x", tx_data[0], tx_data[1]);