Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- buf_1[cnt_1] = byte_rcvd;
- cnt_1++;
- if (byte_rcvd == 0xA) //Sensor has sent 0xA (/r)
- { unsigned char *ptr = buf_1;
- //debug_buf(ptr, sizeof(buf_1));
- eval_SensorCO2(ptr, cnt_1); // sizeof(buf_1));
- //Reset Buffer
- memset(buf_2, 0, sizeof(buf_1));
- cnt_1 = 0;
- continue;
- }
- buf_2[cnt_2] = byte_rcvd;
- cnt_2++;
- if (byte_rcvd == 0xAB) //Sensor has sent AB (EoM)
- { unsigned char *ptr = buf_2;
- //debug_buf(ptr, sizeof(buf_2));
- eval_SensorNOVA(ptr, sizeof(buf_2));
- //Reset Buffer
- memset(buf_2, 0, sizeof(buf_2));
- cnt_2 = 0;
- snd_cmd("Z"); //Trigger the CO2 sensor to send latest measurement
- continue;
- }
- return;
- return;
- uint16_t ppm = (buf[7] - 0x30) + 10 * (buf[6] - 0x30) + 100 * (buf[5] - 0x30) + 1000 * (buf[4] - 0x30) + 10000 * (buf[3] - 0x30); //0x30 is the offset for the ASCII code (i.e. "0" = ASCII (48) = ASCII (0x30) )
- Wire.beginTransmission(10);
- Wire.write(ppm);
- Wire.endTransmission();
- return;
- unsigned char = Wire.read(); // receive byte as a character
- // Serial.print(c);
- {
- uint16_t ppm = Wire.read();
- Serial.print("Last CO2 Reading:");
- Serial.print(ppm);
- Serial.print(" ppm");
- Serial.print("nn");
- uint16_t PM25 = Wire.read();
- Serial.print("PM2.5: ");
- Serial.print(PM25);
- Serial.print(" ug/m3n");
- uint16_t PM100 = Wire.read();
- Serial.print("PM10: ");
- Serial.print(PM100);
- Serial.print(" ug/m3n");
- }
Add Comment
Please, Sign In to add comment