   // **************** FOR SHARP SENSOR ****************
   // nothing
 
+
   // **************** FOR GROVE SENSOR ****************
-  // continuous reading
-  grove_duration = pulseIn(GROVE_READ_PIN, LOW);
-  lowpulseoccupancy += grove_duration;
-  grove_stop_time=millis();  
+  // spend grove_sample_time ms (1000) reading grove sensor
+  // low pulse is 10 to 90 ms in length.
+  for( grove_start=millis(); millis() - grove_start < grove_sample_time;) {
+    lowpulseoccupancy +=  pulseIn(GROVE_READ_PIN, LOW); //  1s timeout
+  }
   
   // **************** FOR MQ7 SENSOR ****************
   // nothing


// **************** RTC ****************
RTC_DS1307 rtc;
bool haveRTC=false; // if we have time info from gps
DateTime now;

// **************** timer for sensor data collection ****************
unsigned long sensors_read_time_start;
unsigned num_records = 0;
#define SENSORS_READ_TIME  2000    // ms 


void setup()


// **************** FOR GROVE SENSOR ****************
#define GROVE_READ_PIN 3 // Digital PIN 3 ATMEGA 5
unsigned long grove_start;
const unsigned grove_sample_time=1000;   // 1s
unsigned long lowpulseoccupancy = 0;
float ratio = 0;
float concentration = 0;


// **************** FOR SHARP SENSOR ****************
#define SHARP_READ_PIN 3     // Analog PIN 3 ATMEGA 26
#define SHARP_LED_PIN 4      // Digital PIN 4 ATMEGA 6
int sharp_dust_val = 0;
float sharp_voltage=0;



// **************** FOR MQ7 SENSOR ****************
#define CO_PWR_SEL_PIN 2    // Digital PIN 2 ATMEGA PIN 4
#define CO_READ_PIN 0       // Analong PIN 0 ATMEGA PIN 23
#define CO_HEAT_TIME 60000  // 60 seconds heat time
#define CO_READ_TIME 90000  // 90 seconds read time

unsigned long CO_timer_start;
unsigned long CO_switch_time;
