Giter Club home page Giter Club logo

ags02ma's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ags02ma's Issues

The mode is a lie?

Or at least, the datasheet and output don't seem to match up. Is this how your (v117) devices behave as well?

I've got three (v118) AGS02MA here, that I wasn't able to get into UGM3 measurements on some custom ESP IDF code. Thought I was going mad so I tried an Arduino uno with your library and see the same results, not really changing modes apparently.

Looking at the datasheet, I'd expect the status value to change.
image

  • b0000 (decimal 0) for ready + PPB mode.
  • b0010 (decimal 2) for ready + UGM3 mode.

Using an adaptation of the library example code, I set up one that alternates modes every 10 measurements. Except that it doesn't? Here's some output I'm seeing with the status being 0 throughout. And no noticeable change in measured value either (other than going down as it warms up).

/home/beanow/duino/AGS02MA_PPB/AGS02MA_PPB.ino
AGS02MA_LIB_VERSION: 0.1.3

BEGIN:	1
VERSION:	118
VERS:	118
MODE:	1	0
PPB:	85	0	0
PPB:	85	0	0
PPB:	85	0	0
PPB:	85	0	0
PPB:	85	0	0
PPB:	85	0	0
PPB:	85	0	0
PPB:	85	0	0
PPB:	85	0	0
PPB:	85	0	0
MODE:	1	1
UGM3:	85	0	0
UGM3:	85	0	0
UGM3:	85	0	0
UGM3:	85	0	0
UGM3:	85	0	0
UGM3:	85	0	0
UGM3:	84	0	0
UGM3:	84	0	0
UGM3:	84	0	0
UGM3:	84	0	0
MODE:	1	0
PPB:	84	0	0
PPB:	84	0	0
PPB:	84	0	0
PPB:	84	0	0
PPB:	84	0	0
PPB:	84	0	0
PPB:	84	0	0
PPB:	84	0	0
PPB:	84	0	0
PPB:	84	0	0
MODE:	1	1
UGM3:	83	0	0
UGM3:	83	0	0
UGM3:	83	0	0
//
//    FILE: AGS02MA_PPB.ino
//  AUTHOR: Rob Tillaart
// VERSION: 0.1.0
// PURPOSE: test application
//    DATE: 2021-08-12
//     URL: https://github.com/RobTillaart/AGS02MA
//

#include "AGS02MA.h"

AGS02MA AGS(26);

uint32_t rounds = 0;

void setup()
{
  Serial.begin(115200);
  Serial.println(__FILE__);

  Wire.begin();

  Serial.print("AGS02MA_LIB_VERSION: ");
  Serial.println(AGS02MA_LIB_VERSION);
  Serial.println();

  bool b = AGS.begin();
  Serial.print("BEGIN:\t");
  Serial.println(b);

  Serial.print("VERSION:\t");
  Serial.println(AGS.getSensorVersion());

  // pre-heating improves measurement quality
  // can be skipped
//  Serial.println("\nWarming up (120 seconds = 24 dots)");
//  while (AGS.isHeated() == false)
//  {
//    delay(5000);
//    Serial.print(".");
//  }
//  Serial.println();

  uint8_t version = AGS.getSensorVersion();
  Serial.print("VERS:\t");
  Serial.println(version);
}


void loop()
{
  delay(3000);

  uint8_t kind = rounds % 20;

  // Switch mode every 10 and 20 rounds.
  bool b;
  if (kind == 0) {
    b = AGS.setPPBMode();
    uint8_t m = AGS.getMode();
    Serial.print("MODE:\t");
    Serial.print(b);
    Serial.print("\t");
    Serial.println(m);
  } else if (kind == 10) {
    b = AGS.setUGM3Mode();
    uint8_t m = AGS.getMode();
    Serial.print("MODE:\t");
    Serial.print(b);
    Serial.print("\t");
    Serial.println(m);
  }

  // Read PPB in first half of a 20-round cycle.
  if (kind < 10) {
    uint32_t value = AGS.readPPB();
    Serial.print("PPB:\t");
    Serial.print(value);
    Serial.print("\t");
    Serial.print(AGS.lastStatus(), HEX);
    Serial.print("\t");
    Serial.print(AGS.lastError(), HEX);
    Serial.println();
  } else {
    uint32_t value = AGS.readUGM3();
    Serial.print("UGM3:\t");
    Serial.print(value);
    Serial.print("\t");
    Serial.print(AGS.lastStatus(), HEX);
    Serial.print("\t");
    Serial.print(AGS.lastError(), HEX);
    Serial.println();
  }

  rounds++;
}


// -- END OF FILE --

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.