     data[dataArrayIndex] = (data[dataArrayIndex] << 1) | isOne;
 }
 
+//reverse last 4 bits and return
+//so 0101 -> 1010, 1100 -> 0011
+byte getLastFourBitsReversed(int b) {
+    byte inverted = 0;
+
+    inverted = inverted | ((b & 1) << 3); //(byte & 0001) << 3 so could be 1000
+    inverted = inverted | (b & 2) << 1; //(byte & 0010) << 1 so could be 0100
+    inverted = inverted | (b & 4) >> 1; // (byte & 0100) >> 1 so could be 0010
+    inverted = inverted | (b & 8) >> 3; // (byte & 1000) >> 3 so could be 0001
+
+    return inverted;
+}
+
 // Matcher for divider bit
 boolean matchDivider(int value) {
     return match(value, DIVIDER_PULSE_LENGTH, DIVIDER_THRESHOLD);

            fillDataArray(bitNumber, matchOne);

            if (bitNumber == DATA_BITS_AMOUNT - 1) {
                //This was the last value bit
                //All is done we can return the whole message to the client!
                printDataArray();

}

void printDataArray() {
    Serial.println("==== Sensor data captured ===");

    for (byte i = 0; i < DATA_ARRAY_SIZE; i++) {
        printByteAsBitSet(data[i]);
        Serial.print("|");
    }
    Serial.println();

    byte sensorNumber = data[1] >> 2;
    byte powerOnUUID = (data[0] << 2) | (data[1] & 3);
    byte powerState = data[2] >> 3;
    float temperature = (float)getTemperature() / 10;
    byte humidity = getHumidity();
    boolean checkSumMatches = checkSumMatch();

    Serial.print("No: ");
    Serial.println(sensorNumber);

    Serial.print("Power UUID: ");
    Serial.println(powerOnUUID);

    Serial.print("Power state: ");
    Serial.println(powerState == 0 ? "normal" : "low");

    Serial.print("Temperature: ");
    Serial.println(temperature);

    Serial.print("Humidity: ");
    Serial.println(humidity);

    Serial.print("CheckSumMatch: ");
    printByteAsBitSet(checkSumMatch());
    Serial.println();
}

void printByteAsBitSet(byte b) {
    Serial.print((b & 8) >> 3);
    Serial.print((b & 4) >> 2);
    Serial.print((b & 2) >> 1);
    Serial.print(b & 1);
}

byte checkSumMatch() {

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

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

int getTemperature() {
    int temperature = 0;

    temperature = (((int)getLastFourBitsReversed(data[5]) << 8)
                   | ((int)getLastFourBitsReversed(data[4]) << 4)
                   | (int)getLastFourBitsReversed(data[3]));

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

        //clear higher bits
        temperature = temperature & 4096;
    }

    return temperature;
}

int getHumidity() {

    //negative number, use two's compliment conversion
    int humidity = ((int)(getLastFourBitsReversed(data[7]) << 4)
            | (int)getLastFourBitsReversed(data[6]));

    humidity = ~humidity + 1;

    return 100 - humidity;
}

void fillDataArray(byte bitNumber, boolean isOne) {
