53 #define CHILD_ID_AIQ 0
54 #define AIQ_SENSOR_ANALOG_PIN 6
56 uint32_t SLEEP_TIME = 30*1000;
62 MyMessage msg2(CHILD_ID_AIQ, V_UNIT_PREFIX);
66 pinMode(AIQ_SENSOR_ANALOG_PIN, INPUT);
75 present(CHILD_ID_AIQ, S_AIR_QUALITY);
83 while(digitalRead(AIQ_SENSOR_ANALOG_PIN) ==
HIGH) {
87 uint32_t duration = pulseIn(AIQ_SENSOR_ANALOG_PIN,
HIGH);
96 long co2ppm = 2 * ((duration/1000) - 2);
98 if ((co2ppm != lastAIQ)&&(abs(co2ppm-lastAIQ)>=10)) {
99 send(msg.
set((int32_t)ceil(co2ppm)));
100 lastAIQ = ceil(co2ppm);