Page 1 of 1

Wio GPS tracker failed to work with Grove Multichannel Gas Sensor

Posted: Fri Apr 12, 2019 12:58 am
by luqman
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: Select all

#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);
}

Re: Wio GPS tracker failed to work with Grove Multichannel Gas Sensor

Posted: Thu Apr 18, 2019 5:27 pm
by bill.yu
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: Select all

#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("...");
}
https://github.com/SeeedDocument/forum_ ... %20(3).zip

Re: Wio GPS tracker failed to work with Grove Multichannel Gas Sensor

Posted: Tue May 07, 2019 6:22 pm
by bill.yu
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: Select all

// 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);
}
WIO LTE code:

Code: Select all

#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);
}

Re: Wio GPS tracker failed to work with Grove Multichannel Gas Sensor

Posted: Wed May 08, 2019 10:46 pm
by luqman
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.
  • Install library in Arduino IDE by using zip file
  • Use the source code below to get the gas reading.

Code: Select all

#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("...");
}