library "Gas (CCS811)" / problem a Joy-IT device

Issue #542 resolved
connochaetes created an issue

Hi, I attempted to use the library "Gas (CCS811)" with a “Joy-IT” sensor. In the notes of Victor Casado I read that it’s intended to work with an Adafruit sensor. (Thank your for the work.) It would be nice, if I would be able to use the library nonetheless.

  • If I connect the sensor’s wake pin with the micro:bit’s pin 1, the block “initialize…” returns a “… please check wiring”. The block “check and update data” returns “false”.
  • If I connect the sensor’s wake pin with the micro:bit’s ground pin, the block “initialize…” returns “Baseline: 65279”. The block “check and update data” returns “true”. But this doesn’t seem right, since (in my understanding) it’s intended to work with a wake pin other than ground.

I don’t get proper results using the blocks “CO2” or “TVOC”. Feel free to ask for further details. Any suggestions are welcome.

Comments (12)

  1. John Maloney repo owner

    Do you mean this sensor:

    https://joy-it.net/en/products/SEN-MQ8

    If so, that sensor is not an I2C sensor like the CCS811. Instead. You don't need a library at all; just read an analog value using the read analog pin block. An easy way to test it is to graph the value from the analog pin, then expose the sensor to alcohol vapor. You should see a change. Check the datasheet to some of the other gases it can detect.

  2. connochaetes reporter

    @John Maloney: Thanks for your response. Excuse me for not submitting the exact type of my device. It's this one: https://joy-it.net/de/products/SEN-CCS811V1 (an I2C device). So I guess, the next step would be to look closer on the used I2C address. Again: Any further suggestions on how to achieve success are welcome.

  3. John Maloney repo owner

    Yep! Check the I2C address and whether it returns the expected value for the "whoami" register. That is:

    scriptImage605390.png

    should return 129 (0x81).

    MicroBlocks libraries are written in MicroBlocks. In "advanced blocks" mode you can right click on the "Gas (CCS811)" library and select "show all block definitions" to see all the code for the library.

    The _ccs811_wakeup function shows that the wake pin should to be held LOW to enable the chip. You can also see where "whoami" register is checked in the _ccs811_configure function.

    With luck, you'll be able to make this library work for your CCS811 sensor board.

  4. connochaetes reporter

    Obviously, there’s still much to learn for me. So, thanks for your patience and the insight.

    OK, I see a “whoami” register that differs from 129 (0x81).

    Since, the block reports a -2, I am a little irritated, if this could be right. What could be a next step?

  5. John Maloney repo owner

    You've made good progress in debugging the problem.

    A negative result indicates that an I2C error has occurred. -2 means that it did not get a response at the I2C address 5A. That might indicate several problems: bad wiring, wrong I2C address, a defective sensor board, or the chip is asleep. You can check each of those things.

    The datasheet for the chip (https://cdn.sparkfun.com/assets/learn_tutorials/1/4/3/CCS811_Datasheet-DS000459.pdf) says the I2C address can be either 0x5A or 0x5B so try 0x5B. Also, make sure to connect the "wake" pin to ground or, if it is connected to a GPIO pin, set that pin to LOW.

  6. John Maloney repo owner

    The datasheet for the chip is key to working with any I2C device. The JOY-IT data sheet has hardly any useful information, not even a good diagram or photo of the pin connections. I googled for "CCS811 datasheet" and up popped the link I posted above.

  7. connochaetes reporter

    Thanks. OK, there’s development. I guess, I made indeed a wiring error. (That’s embarassing…) At least, I get a proper result:

    I connected the sensor’s wake pin with the micro:bit’s pin 8. This is the next result:

    It’s meaning is unclear to me. Here are some additional results:

    The values for CO2 and TVOC don’t change.

    Reminder: In order to outline hardware issues, I used MakeCode. There, the values change if I breathe against the sensor.

    What could be a next step in order to debug?

    I am aware, the MakeCode is a completely different approach. But perhaps, I can acquire data there that would be helpful for MicroBlocks.

  8. John Maloney repo owner

    I think this may be working! You just need to to call "check and update data" every time you want to take a new reading. The CO2 and TVOC blocks will return the most recent reading until you take another one.

    Note that it takes time to take a reading and the readings do not change very fast. I would not try to sample more frequently than once per second.

  9. connochaetes reporter

    I was successful. Again, thanks for your patience and insights. Eventually, both MicroBlocks and the library were ready to go right from the start. It was a user-based problem. I had to figure out, how to use both hardware and software. (Physical computing can be tricky, but in the end rewarding.)

    Since everything is up and running now, the optimization can begin.

    (This issue can be closed.)

  10. John Maloney repo owner

    Hooray! Glad you got it working.

    That sensor seems to be quite sensitive -- it shoots up but 3000-4000 when you breath on it. If you have some sort of alcohol, nail polish, paint thinner, or other Volatile Organic Compound (VOC), it should respond to that, too.

  11. Log in to comment