Wio GPS tracker failed to work with Grove Multichannel Gas Sensor

Hi,



I try to interface multichannel gas sensor using Wio GPS/GSM Tracker (based on ATSAM21D). I setup a very basic source code copied from example

and make some modification on serial channel (from Serial to SerialUSB). However, it looks like the Wio GPS Tracker failed to operate. No output from serial monitor. Here is my source code.

[code]
#include <Wire.h>
#include “MutichannelGasSensor.h”

#define SENSOR_ADDR 0X04

void setup() {
// put your setup code here, to run once:
SerialUSB.begin(115200);
SerialUSB.println(“Setup”);
gas.begin(SENSOR_ADDR);
}

void loop() {
// put your main code here, to run repeatedly:
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]

HI there,



It is related with wire library compatibility issue. I did several changes, but it still does not work. I just post it here and if any other people can help solve the issue. My sensor is version 1, i modify the code and library. the com port can display the message, but the reading is invalid. I did not get the wire working. thanks.


  1. please comment out the version checking in gas.begin() and the whole library.
  2. please make sure the cpp file also changes the serial. to serialusb.
  3. I just take a quick look that the code missed the gas.powerOn.
  4. If you want to use the on-board Grove connector, please use digitalWrite(12, HIGH) to open 3V3_B. Otherwise you can’t provide power to Grove modules.

[code]#include <Wire.h>
#include “MutichannelGasSensor.h”

void setup()
{
digitalWrite(12, OUTPUT);
digitalWrite(12, HIGH);
SerialUSB.begin(115200); // start serial for output
SerialUSB.println(“power on!”);
delay(5000);
gas.begin(0x04);//the default I2C address of the slave is 0x04
gas.powerOn();
delay(5000);
SerialUSB.print("Firmware Version = ");
SerialUSB.println(gas.getVersion());
}

void loop()
{
float c;

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

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

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

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

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

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

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

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

delay(1000);
SerialUSB.println("...");

}[/code]

<LINK_TEXT text=“https://github.com/SeeedDocument/forum_ … %20(3).zip”>https://github.com/SeeedDocument/forum_doc/raw/master/reg/Mutichannel_Gas_Sensor-master%20(3).zip</LINK_TEXT>

Hi there,



We updated the mulitchannel gas sensor library and make it work with wio gps and wio lte. please download the latest library and use below code. thanks.

https://github.com/Seeed-Studio/Mutichannel_Gas_Sensor



WIO GPS Code:

[code]// get RAW data from the sensor
// Loovee
// 2016-11-10

#include <Wire.h>
#include “MutichannelGasSensor.h”

#define WIOLTE_GROVE_PIN (12)
#define SENSOR_ADDR 0X04 // default to 0x04

void setup()
{
SerialUSB.begin(115200);
pinMode(WIOLTE_GROVE_PIN, OUTPUT);
digitalWrite(WIOLTE_GROVE_PIN, HIGH);
delay(2000);
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]

WIO LTE code:

[code]#include <Wire.h>
#include “MutichannelGasSensor.h”

#define WIOLTE_GROVE_PIN (26)
#define SENSOR_ADDR 0X04 // default to 0x04

void setup()
{
// SerialUSB.begin(115200);
pinMode(WIOLTE_GROVE_PIN, OUTPUT);
digitalWrite(WIOLTE_GROVE_PIN, HIGH);
delay(2000);
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]

Thank you Bill. I have tested the new library (as 7th May 2019) and It is now working.



Here is the steps for others to follow.

[list=]

  • Install Seeed SAMD Board through Arduino IDE board manager. Board definition must be set at Additional Board Manager URL under Preferrence. Here is the URL <LINK_TEXT text=“https://raw.githubusercontent.com/Seeed … index.json”>https://raw.githubusercontent.com/Seeed-Studio/Seeed_Platform/master/package_seeeduino_boards_index.json</LINK_TEXT>
  • [/list]
    [list=]
  • Download new library for Grove Multichannel Sensor as zip. https://github.com/Seeed-Studio/Mutichannel_Gas_Sensor
  • [/list]
    [list=]
  • Install library in Arduino IDE by using zip file
  • [/list]
    [list=]
  • Use the source code below to get the gas reading.
  • [/list]

    [code]
    #include <Wire.h>
    #include “MutichannelGasSensor.h”

    #define WIOLTE_GROVE_PIN (12)
    #define SENSOR_ADDR 0X19 // default to 0x04

    void setup()
    {
    SerialUSB.begin(115200);
    pinMode(WIOLTE_GROVE_PIN, OUTPUT);
    digitalWrite(WIOLTE_GROVE_PIN, HIGH);
    delay(2000);
    gas.begin(SENSOR_ADDR); //
    }

    void loop()
    {
    float c;

    c = gas.measure_NH3();
    SerialUSB.print("The concentration of NH3 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");
    
    c = gas.measure_CO();
    SerialUSB.print("The concentration of CO is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");
    
    c = gas.measure_NO2();
    SerialUSB.print("The concentration of NO2 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");
    
    c = gas.measure_C3H8();
    SerialUSB.print("The concentration of C3H8 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");
    
    c = gas.measure_C4H10();
    SerialUSB.print("The concentration of C4H10 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");
    
    c = gas.measure_CH4();
    SerialUSB.print("The concentration of CH4 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");
    
    c = gas.measure_H2();
    SerialUSB.print("The concentration of H2 is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");
    
    c = gas.measure_C2H5OH();
    SerialUSB.print("The concentration of C2H5OH is ");
    if(c>=0) SerialUSB.print(c);
    else SerialUSB.print("invalid");
    SerialUSB.println(" ppm");
    
    delay(1000);
    SerialUSB.println("...");
    

    }

    [/code]