Guest User

Untitled

a guest
Jul 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. buf_1[cnt_1] = byte_rcvd;
  2.  
  3. cnt_1++;
  4.  
  5.  
  6. if (byte_rcvd == 0xA) //Sensor has sent 0xA (/r)
  7.  
  8. { unsigned char *ptr = buf_1;
  9.  
  10. //debug_buf(ptr, sizeof(buf_1));
  11.  
  12. eval_SensorCO2(ptr, cnt_1); // sizeof(buf_1));
  13.  
  14. //Reset Buffer
  15.  
  16. memset(buf_2, 0, sizeof(buf_1));
  17.  
  18. cnt_1 = 0;
  19.  
  20. continue;
  21.  
  22. }
  23.  
  24. buf_2[cnt_2] = byte_rcvd;
  25.  
  26. cnt_2++;
  27.  
  28.  
  29.  
  30.  
  31. if (byte_rcvd == 0xAB) //Sensor has sent AB (EoM)
  32.  
  33. { unsigned char *ptr = buf_2;
  34.  
  35. //debug_buf(ptr, sizeof(buf_2));
  36.  
  37. eval_SensorNOVA(ptr, sizeof(buf_2));
  38.  
  39. //Reset Buffer
  40.  
  41. memset(buf_2, 0, sizeof(buf_2));
  42.  
  43. cnt_2 = 0;
  44.  
  45. snd_cmd("Z"); //Trigger the CO2 sensor to send latest measurement
  46.  
  47. continue;
  48. }
  49.  
  50. return;
  51.  
  52. return;
  53.  
  54. 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) )
  55.  
  56. Wire.beginTransmission(10);
  57.  
  58. Wire.write(ppm);
  59.  
  60. Wire.endTransmission();
  61.  
  62. return;
  63.  
  64. unsigned char = Wire.read(); // receive byte as a character
  65.  
  66. // Serial.print(c);
  67.  
  68. {
  69.  
  70. uint16_t ppm = Wire.read();
  71.  
  72. Serial.print("Last CO2 Reading:");
  73.  
  74. Serial.print(ppm);
  75.  
  76. Serial.print(" ppm");
  77.  
  78. Serial.print("nn");
  79.  
  80.  
  81. uint16_t PM25 = Wire.read();
  82.  
  83. Serial.print("PM2.5: ");
  84.  
  85. Serial.print(PM25);
  86.  
  87. Serial.print(" ug/m3n");
  88.  
  89. uint16_t PM100 = Wire.read();
  90.  
  91. Serial.print("PM10: ");
  92.  
  93. Serial.print(PM100);
  94.  
  95. Serial.print(" ug/m3n");
  96.  
  97.  
  98.  
  99.  
  100. }
Add Comment
Please, Sign In to add comment