 // A0-A3,B2-B3  - UUID which is randomly set once sensor is turned on
 //                and it not changed until next power off
 //
-// B0-B1  - Number of the sensor: 01 - 1, 10 - 2, 11 - 3
+// B0-B1  - Number of channel of the sensor: 01 - 1, 10 - 2, 11 - 3
 //
 // C0 - battery info: 0 - battery is ok, 1 - battery is low
 //

                //This was the last value bit

                //All is done we can return the whole message to the client
                if (checkSumMatch()) {
                    printDataArray();
                }


    Serial.println(humidity);
}

int isCheckSumMatch() {

    //Sum first 8 nibbles
    int sum = 0;
    for (byte i = 0; i < DATA_ARRAY_SIZE - 1; i++) {
        sum += data[i];
    }

    //clear higher bits
    sum &= 15;

    //returns true if calculated check sum matches received
    return sum == data[DATA_ARRAY_SIZE - 1];
}

byte getSensorChannel() {
    //Channel is bits B0, B1 in T2 nibble
    //Since we store T2 in reversed order
    //we have to get 3,4 bits ot data[1] and reverse them
    return ((data[1] & 1) << 1) | ((data[1] & 2) >> 1);
}

byte getPowerUUID() {
    //we do not reverse power uuid since value is still uniq
    return (data[0] << 2) | ((data[1] & 12) >> 2);
}

byte getPowerStatus() {
    //Power or battery status is C0 bit in T3 nibble
    //since in data array we wrote T3 in reversed order
    //it will be the first bit in data[2]
    return data[2] & 1;
}

int getTemperature() {
    int temperature = 0;

    //Temperature is stored in T4,T5,T6 nibbles
    //lowest nibble - first
    //since we already reversed bits order in these nibbles
    //all we have to do is to reverse nibbles order
    temperature = (((int)data[5] << 8) | ((int)data[4] << 4) | (int)data[3]);

    if ((data[5] & 1) == 1) {
        //negative number, use two's compliment conversion
        temperature = ~temperature + 1;

        //clear higher bits and convert to negative
        temperature = -1 * (temperature & 4095);
    }

    return temperature;
