AcuRite 00606TX Sensor

AcuRite 00606TX Sensor - I have 2 of these sending reports to an arduino for processing. In order to separate the values, I came up with this to pull out first 7 bits, which are a rolling code. Apparently this rolling code only changes when a major battery changes occurs. Think of this rolling code as a serial number. This is the code used to pull rolling number. It looks awful but it works. can anyone make it look nicer? Next thing to do is pull the battery bit, which is supposed to be bit 8. Now me thinks my rolling code is grabbing it and not what I think. Hopefully this make sense and someone straightens me out.

// loop over buffer data
for(unsigned int i=syncIndex1; i!=syncIndex2; i=(i+2)%RING_BUFFER_SIZE) {
// for(unsigned int i=syncIndex1; syncIndex1+16; i=(i+2)%RING_BUFFER_SIZE) {
unsigned long t0 = timings*, t1 = timings[(i+1)%RING_BUFFER_SIZE];*

  • if (t0>(SEP_LENGTH-100) && t0<(SEP_LENGTH+100)) {*
  • if (t1>(BIT1_LENGTH-1000) && t1<(BIT1_LENGTH+1000)) {*
  • if (xx<7) { rolling = (rolling << 1) + 1; }*
    // Serial.print(“1”);
  • } else if (t1>(BIT0_LENGTH-1000) && t1<(BIT0_LENGTH+1000)) {*
  • if (xx<7) { rolling = (rolling << 1) + 0; }*
    // Serial.print(“0”);
  • } else {*
    // Serial.print(“SYNC”); // sync signal
  • }*
  • } else {*
    // Serial.print("?"); // undefined timing
  • }*
  • ++xx;*
  • }*
    // Serial.println("");
    //Serial.println (rolling);
    If you need more info, let me know. The overall code is quite long as I am also monitoring some other arduino sending in their reports via RF24 radios. All recvd code is sent via UDP packets to the server for storage and processing to web display pages.

Please read "How to use this forum" and post your code properly, using code tags.

Code snippets are usually unwelcome.