Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library only works if I -first- upload an Arduino program, and -then- transfer my MakeCode program #3

Open
kristianpedersen opened this issue May 9, 2019 · 3 comments

Comments

@kristianpedersen
Copy link

At first when using your library, I only got one static reading showing unrealistically high eCO2 values. Often at around 65000.

I then discovered the sensor works great with Arduino IDE and Sparkfun's CCS811 library. The eCO2 values stay at around 400, and increase significantly when I breathe on the sensor.

Finally, I discovered that your library does work! If I first transfer an Arduino sketch and then transfer my code with your MakeCode library, I get expected readings. If I pull the USB plug and put it back in, the readings go back to being static again.

Here are the respective error and status codes MakeCode gives me:
Successful readings: Error 0, status alternates between 144 and 152.
Unsuccessful readings: Error 3, status 16

Here's an example of a log, where you can see where the USB was pulled out and put back in. As you can see, the bottom line has been repeated 741 times:

Error: 0, status: 144, ppm: 415
Error: 0, status: 152, ppm: 415
4Error: 0, status: 144, ppm: 415
Error: 0, status: 152, ppm: 410
3Error: 0, status: 144, ppm: 410
Error: 0, status: 152, ppm: 410
2Error: 0, status: 144, ppm: 410
741Error: 3, status: 16, ppm: 4349

My Arduino program:

#include <Wire.h>
#include "SparkFunCCS811.h"
CCS811 mySensor(0x5B);

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  CCS811Core::status returnCode = mySensor.begin();
}

void loop()
{
  if (mySensor.dataAvailable())
  {
    mySensor.readAlgorithmResults();
    Serial.println(mySensor.getCO2());
  }
  delay(10);
}

My MakeCode program:

airQuality.setAddress(CCS811_I2C_ADDRESS.ADDR_0x5B)

basic.forever(function () {
    serial.writeLine(`Error: ${airQuality.readError()}, status: ${airQuality.readStatus()}, ppm: ${airQuality.readCo2()}`)
})

The sensor has been connected using 3.3V, GND, SDA and SCL.

@kristianpedersen
Copy link
Author

Here's how I set up my micro:bit with the Arduino IDE for those who are interested: https://learn.adafruit.com/use-micro-bit-with-arduino?view=all

@compie67
Copy link

compie67 commented Sep 17, 2020

great and for my students step forward. Do you have some images of how you set this up with the wirers

The sensor we got is this
https://nl.aliexpress.com/item/32820864503.html?aff_platform=product&sk=b0kN9BLE&aff_trace_key=dbfc44fbef034f3e9914720a3f8477ea-1600332411778-03544-b0kN9BLE&terminal_id=572a9b244f20404bb6b192346a9d9ad7

thanks @kristianpedersen

@kristianpedersen
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants