Grove Multichannel Gas Sensor不适用于Arduino MKR WiFi 1010

时间:2019-08-29 17:15:43

标签: arduino

我的Grove多通道气体传感器有问题。 当我尝试从传感器中获取气体浓度时,它将返回到串行监视器“无效的ppm”(<0)。当我使用Arduino Uno时,它可以正常工作。它只给我MKR问题。我不明白为什么。我不是专家,但我认为这不会那么困难。 这是代码:

#include <Wire.h>
#include "MutichannelGasSensor.h"

void setup()
{
  Serial.begin(115200); // start for output
  while (!SerialUSB) {

  }
  Serial.println("power on!");
  gas.begin(0x04);//the default I2C address of the slave is 0x04
  gas.powerOn();
  Serial.print("Firmware Version = ");
  Serial.println(gas.getVersion());
}

void loop()
{
  float c;

  c = -gas.measure_NH3();
  Serial.print("The concentration of NH3 is ");
  if (c >= 0) Serial.print(c);
  else Serial.print("invalid");
  Serial.println(" ppm");

  c = -gas.measure_CO();
  Serial.print("The concentration of CO is ");
  if (c >= 0) Serial.print(c);
  else Serial.print("invalid");
  Serial.println(" ppm");

  c = -gas.measure_NO2();
  Serial.print("The concentration of NO2 is ");
  if (c >= 0) Serial.print(c);
  else Serial.print("invalid");
  Serial.println(" ppm");

  c = -gas.measure_C3H8();
  Serial.print("The concentration of C3H8 is ");
  if (c >= 0) Serial.print(c);
  else Serial.print("invalid");
  Serial.println(" ppm");

  c = -gas.measure_C4H10();
  Serial.print("The concentration of C4H10 is ");
  if (c >= 0) Serial.print(c);
  else Serial.print("invalid");
  Serial.println(" ppm");

  c = -gas.measure_CH4();
  Serial.print("The concentration of CH4 is ");
  if (c >= 0) Serial.print(c);
  else Serial.print("invalid");
  Serial.println(" ppm");

  c = -gas.measure_H2();
  Serial.print("The concentration of H2 is ");
  if (c >= 0) Serial.print(c);
  else Serial.print("invalid");
  Serial.println(" ppm");

  c = -gas.measure_C2H5OH();
  Serial.print("The concentration of C2H5OH is ");
  if (c >= 0) Serial.print(c);
  else Serial.print("invalid");
  Serial.println(" ppm");

  delay(1000);
  Serial.println("...");
}

1 个答案:

答案 0 :(得分:0)

尝试更换

c = -gas.measure..

使用

c =  gas.measure..