 boolean readG3() {
   unsigned short x;
   byte data;
-  boolean start = false;
+  unsigned short start = 0;
   pm10 = -1;
   pm25 = -1;
   pm100 = -1;
   memset(buf, 0, 24);
+  g3.listen();
   for(x = 0; x < 24;) {
     if(g3.available()) {
       data = g3.read();

void loop() {
  float t;
  float h;
  Serial.println("A4 vs. G3 / DHT22 vs. SHT31");
  /*
  if(readA4()) {
    Serial.print("A4 :: ");
    Serial.print("PM 1.0 = ");
    Serial.print(pm10);
    Serial.print("   PM 2.5 = ");
    Serial.print(pm25);
    Serial.print("   PM 10 = ");
    Serial.println(pm100);
  }
  if(readG3()) {
    Serial.print("G3 :: ");
    Serial.print("PM 1.0 = ");
    Serial.print(pm10);
    Serial.print("   PM 2.5 = ");
    Serial.print(pm25);
    Serial.print("   PM 10 = ");
    Serial.println(pm100);
  }
  */
  t = sht31.readTemperature();
  h = sht31.readHumidity();
  delay(100);
  if(!isnan(t) && !isnan(h)) {
    Serial.print("SHT31 :: temp=");
    Serial.print(t);
    Serial.print("   hum=");
    Serial.println(h);
  } else {
    t = -1;
    h = -1;

  t = dht.readTemperature();
  h = dht.readHumidity();
  if(!isnan(t) && !isnan(h)) {
    Serial1.print("AM2302 ");
    Serial1.print(t);
    Serial1.print(" ");
    Serial1.print(h);
    Serial1.print("|");
#ifdef SERIAL_DEBUG
    Serial.print("AM2302 :: temp=");
    Serial.print(t);
    Serial.print("   hum=");
    Serial.println(h);
#endif
  } else {
    t = -1;
    h = -1;
  }
  delay(100);
  am2321.read();
  t = am2321.temperature / 10.0;
  h = am2321.humidity / 10.0;
  Serial1.print("AM2320 ");
  Serial1.print(t);
  Serial1.print(" ");
  Serial1.print(h);
  Serial1.print("|");
#ifdef SERIAL_DEBUG
  Serial.print("AM2320 :: temp=");
  Serial.print(t);
  Serial.print("   hum=");
  Serial.println(h);
#endif
  delay(1000);
}

