If my electron was to just sit there online not publishing any information, would i be right in saying it would only use 4400 bytes of data until some data is published.
i am trying to work out data usage for my program but don’t fully understand it. how much data would each publish within my code use.
Thanks…Ben
// This #include statement was automatically added by the Particle IDE.
#include <Ubidots.h>
// This #include statement was automatically added by the Particle IDE.
#include <SegmentDriver.h>
// This #include statement was automatically added by the Particle IDE.
#include <NCD2Relay.h>
#define TOKEN "" // Put here your Ubidots TOKEN
Ubidots ubidots(TOKEN);
// This #include statement was automatically added by the Particle IDE.
//#include "NCD2Relay/NCD2Relay.h"
SegmentLEDDriver display;
// next task seperate low flow and run signals and put in timer for low flow
NCD2Relay relayController; // create an instance of the board
int state = 1;
float onsetpoint = 10.0;
float level = 0.0;
float prevlevel = 0.0;
int status1 = 0;
int prevstatus1 = 0;
int runsignal = 0;
//int prevrunsignal = 0;
int lowflow = 0;
int faulttrip = 0;
int prevfaulttrip = 0;
int prevpumprunning = FALSE;
int pumprunning = FALSE;
int testvar = 0;
void setup()
{
Serial.begin(115200);
relayController.setAddress(0,0,0);
relayController.turnOffRelay(1);
display.init();
}
void loop() {
int status1 = relayController.readInputStatus(1);
faulttrip = relayController.readInputStatus(2);
// lowflow = relayController.readInputStatus(3);
float level = analogRead(A0);
level = map(level, 0, 4095, 0, 20);
display.displayWriteInt(testvar);// display on lcd readout
//---------------------------------------Check if anything is diffrent then update web
if (pumprunning != prevpumprunning)
{
prevpumprunning = pumprunning;
ubidots.add("PumpStatus", pumprunning);
ubidots.sendAll();
testvar ++;
delay(1000);
}
if (faulttrip != prevfaulttrip)
{
prevfaulttrip = faulttrip;
ubidots.add("Overload", faulttrip);
ubidots.sendAll();
testvar ++;
delay(1000);
}
if (status1 != prevstatus1)
{
prevstatus1 = status1;
ubidots.add("Operation Mode", status1);
ubidots.sendAll();
testvar ++;
delay(1000);
}
/*
if (level != prevlevel)
{
prevlevel = level;
ubidots.add("Level", level);
ubidots.sendAll();
testvar ++;
delay(1000);
}
*/
//------------------------------------------------------------------------------------
// display.displayWriteInt(faulttrip);
switch(state)
//float level = 0.0;
{
case 1:
// State 1 wait for user to select switch to automatic
display.displayWriteInt(testvar);
// ubidots.add("Vtusariable_Name_Three", value3);
// ubidots.sendAll();
relayController.turnOffRelay(2);
pumprunning = FALSE;
if(status1 == 1)
{
state = 2;
}
break;
case 2:
display.displayWriteInt(testvar);
if((level > onsetpoint)&&(status1 == 1)&&(faulttrip != 0)){
relayController.turnOnRelay(2);
pumprunning = TRUE;
delay(2000);
state = 3;
// ubidots.add("Vtusariable_Name_Three", value3);
// delay(5000);
}
else
{
state =1;
// delay(5000);
}
case 3: // pump is running at this point waiting for user to turn off the pump or the level to drop below setpoint
display.displayWriteInt(testvar);
if((level < onsetpoint)||(status1 != 1)||(faulttrip !=1))
{
relayController.turnOffRelay(2);
pumprunning = FALSE;
// ubidots.add("Vtusariable_Name_Three", value3);
//ubidots.sendAll();
state = 1;
}
break;
}
}