Hy,
Has anyone ever had a the Multichannel Gas Sensor (Grove) working on a MKR GSM1400?
When I download the “default” sketch for getting values, the sensor does not respond.
I have used it on a MKR Connector Carrier. That does not work. And also when I connect
it directly on the MKR Pins, without the carrier board, it does not work, giving no values back.
When I use the sensor on a Arduino MEGA, it works fine.
On the other hand, a SGP30 VOC Sensor board works on the MKR GSM1400.
So there is no connection problem, or using the wrong pinout.
Is there anyone who can help me?
thanks
Andy
Hi There
I succeeded by the code below.
[code]
#include <Wire.h>
#include “MutichannelGasSensor.h”
#define SENSOR_ADDR 0X04 // default to 0x04
void setup()
{
SerialUSB.begin(115200);
gas.begin(SENSOR_ADDR); //
}
void loop()
{
float R0_NH3, R0_CO, R0_NO2;
float Rs_NH3, Rs_CO, Rs_NO2;
float ratio_NH3, ratio_CO, ratio_NO2;
R0_NH3 = gas.getR0(0);
R0_CO = gas.getR0(1);
R0_NO2 = gas.getR0(2);
Rs_NH3 = gas.getRs(0);
Rs_CO = gas.getRs(1);
Rs_NO2 = gas.getRs(2);
ratio_NH3 = Rs_NH3/R0_NH3;
ratio_CO = Rs_CO/R0_CO;
ratio_NO2 = Rs_NH3/R0_NO2;
SerialUSB.println("R0:");
SerialUSB.print(R0_NH3);
SerialUSB.print('\t');
SerialUSB.print(R0_CO);
SerialUSB.print('\t');
SerialUSB.println(R0_NO2);
SerialUSB.println("Rs:");
SerialUSB.print(Rs_NH3);
SerialUSB.print('\t');
SerialUSB.print(Rs_CO);
SerialUSB.print('\t');
SerialUSB.println(Rs_NO2);
SerialUSB.println("ratio:");
SerialUSB.print(ratio_NH3);
SerialUSB.print('\t');
SerialUSB.print(ratio_CO);
SerialUSB.print('\t');
SerialUSB.println(ratio_NO2);
SerialUSB.println("------------------------");
delay(1000);
}
[/code]
mabey it can help you
Hy there,
thanks for your reply.
I tried your code and it works.
After a few try and error I found the solution:
In the default application (ReadSensorValue_Grove) of the library, there is the following setup;
</s><i>
</i>void setup()
{
Serial.begin(115200); // start serial for output
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());
}
<e>
The problem is the call of the function gas.getVersion(). This seems to cause some errors.
Don’t know what kind of, but the function gas.measure_xxx(); always returns -1.
When commenting this or when I move the call to gas.powerOn() after this, it works fine.
Here is the modfied setup:
[code]
void setup()
{
SerialUSB.begin(115200); // start SerialUSB for output
SerialUSB.println(“power on!”);
gas.begin(SENSOR_ADDR);//the default I2C address of the slave is 0x04
SerialUSB.print("Firmware Version = ");
SerialUSB.println(gas.getVersion());
gas.powerOn();
}[/code]