I want to use the raw data from the CCS801 data, such that I make my own calculations. However, this is a bit over my competence level.
I manage to get the raw data using this code:
#include "SparkFunCCS811.h"
//#define CCS811_ADDR 0x5B //Default I2C Address
#define CCS811_ADDR 0x5A //Alternate I2C Address
CCS811 mySensor(CCS811_ADDR);
void setup()
{
Serial.begin(9600);
CCS811Core::status returnCode = mySensor.begin();
if (returnCode != CCS811Core::SENSOR_SUCCESS)
{
Serial.println(".begin() returned with an error.");
while (1); //Hang if there was a problem.
}
mySensor.setDriveMode(4);
}
void loop()
{
//Check to see if data is ready with .dataAvailable()
if (mySensor.dataAvailable())
{
uint8_t arraySize = 10;
uint8_t tempData[arraySize];
mySensor.multiReadRegister(0x03, tempData, 3);
for ( int i = 0; i < arraySize; i++)
{
if (i % 8 == 0)
{
Serial.println();
Serial.print("RawData 0x");
Serial.print(i, HEX);
Serial.print(":");
}
Serial.print(tempData[i], HEX);
Serial.print(" ");
}
}
delay(10); //Don't spam the I2C bus
}
which gives this results in the serial monitor
RawData 0x0:4D 9F A 0 0 0 0 0
RawData 0x8:0 0
RawData 0x0:49 91 4D 0 0 0 0 0
RawData 0x8:0 0
I do know what this data should represent, see the attachment.
How can I transfere the hex Rawdata into two decimal numbers:
The most significant 6 bits of the Byte 0 contain the value of the
current through the sensor and the lower 10 bits contain the
readings of the voltage across the sensor
Any one has any ideas of how to fix this?
