Updating major and minor values BLE Beacon using SGP30 senor

Viewed 24

I have a SGP30 sensor and I want to update major and minor values but I get 0 and not the sensor values. The code is like below, I also tried

beacon.setMajor(sgp.TVOC);
beacon.setMinor(sgp.eCO2); 

Into void loop but still I get 0 for both of them.
Arduino code is like below:

#include "BLEDevice.h"
#include "BLEBeacon.h"
#include <Wire.h>
#include "Adafruit_SGP30.h"


Adafruit_SGP30 sgp;
iBeacon beacon;

#define UUID "00112233-4455-6677-8899-AABBCCDDEEFF"

void setup() {

    beacon.setManufacturerId(0x004C); // MfgId (0x004C: Apple Inc)
    beacon.setRSSI(0xBF);             // rssi: (0xBF: -65 dBm)
    beacon.setMajor (sgp.TVOC);          
    beacon.setMinor(sgp.eCO2);          
    beacon.setUUID(UUID);

    BLE.init();
    BLE.configAdvert()->setAdvType(GAP_ADTYPE_ADV_NONCONN_IND);
    BLE.configAdvert()->setAdvData(beacon.getAdvData(), beacon.advDataSize);
    BLE.configAdvert()->setScanRspData(beacon.getScanRsp(), beacon.scanRspSize);
    BLE.beginPeripheral();

Serial.begin(115200);
  while (!Serial) { delay(10); } 

int counter = 0;
void loop() {
  if (! sgp.IAQmeasure()) {
    Serial.println("Measurement failed");
    return;
  }
  Serial.print("TVOC "); Serial.print(sgp.TVOC); Serial.print(" ppb\t");
  Serial.print("eCO2 "); Serial.print(sgp.eCO2); Serial.println(" ppm");
       
}

So I want the sgp.TVOC on major and sgp.eCO2 in minor. I'm new to this so maybe the syntax is not correct. I tried to assign two different variables to minor and major and it works but not with senso data.

0 Answers
Related