I’ve had no trouble with most of the Electron examples and my own variation on the publish example works fine with various bits of data, but as soon as I tried to add CellularData I get “‘CellularData’ does not name a type” errors. Seems like the lib for this is not loaded but I can see no extra #includes required. What am I missing?
(Bonus question: is #including Particle.h actually necessary. I see it in a lot of examples but everything seems to work alright without it.)
#include "Particle.h"
const int voltOut = A5;
const int ldrPin = A0;
const int ledPin = 7; // This is your internal LED
const int led = D0; // This is where your external LED is plugged in. The other side goes to a resistor connected to GND.
CellularData data;
void setup() {
pinMode(voltOut, OUTPUT); //supply 3.3v at pin A5
pinMode(ldrPin, INPUT); //assign A0 as an input
pinMode(ledPin, OUTPUT);
digitalWrite(voltOut, HIGH); //initialize A5 at 3.3v
pinMode(led,OUTPUT); // Our LED pin is output (lighting up the LED)
void loop() {
if (!Particle.connected()) {
return;
}
digitalWrite(ledPin,HIGH);
int value = (analogRead(A0) / 10);
FuelGauge fuel;
float voltage = fuel.getVCell();
int SoC = fuel.getSoC();
CellularSignal sig = Cellular.RSSI();
if (Cellular.getDataUsage(data)) {
//Particle.publish("CID", String(data.cid), 60, PRIVATE);
Particle.publish("TXS", String(data.tx_session) + "," + String(data.rx_session) + ", " + String(data.tx_total) + ", " + String(data.rx_total), 60, PRIVATE);
//Particle.publish("RXS", String(data.rx_session), 60, PRIVATE);
//Particle.publish("TXT", String(data.tx_total), 60, PRIVATE);
//Particle.publish("RXT", String(data.rx_total), 60, PRIVATE);
}
//Particle.publish("ID", String(System.deviceID()), 60, PRIVATE);
Particle.publish("Sig", String(sig), 60, PRIVATE);
Particle.publish("V", String(voltage) + "," + String(SoC), 60, PRIVATE); // Actual battery voltage and derived State of Charge
Particle.publish("LDR", String(value), 60, PRIVATE);
//delay(1000); //makes sure there is enough time to complete sending before turning cell off.
digitalWrite(ledPin,LOW);
//Cellular.off();
System.sleep(SLEEP_MODE_DEEP, 6000); //sleep for 10 minutes
}