I can’t find what I’m doing wrong to get periodic outbound to work. The code is a modified example six. If someone could look it over and give me a hint I’d appreciate it!!
Swan - notecarrier A - Cellular card
I also don’t know how to add code the right way!!!
#include <Notecard.h>
#include <NotecardPseudoSensor.h>
#include <Notecarrier.h>
#define usbSerial Serial
// This is the unique Product Identifier for your device
#define PRODUCT_UID "com.gmail.jorgensenray53:quickstart" // "com.my-company.my-name:my-project"
#define myProductID PRODUCT_UID
#define VoltagePin A0
int readVoltage = 0;
float voltage = 0;
using namespace blues;
Notecard notecard;
NotecardPseudoSensor sensor(notecard);
// One-time Arduino initialization
void setup()
{
// Set up for debug output (if available).
#ifdef usbSerial
// If you open Arduino's serial terminal window, you'll be able to watch
// JSON objects being transferred to and from the Notecard for each request.
usbSerial.begin(115200);
const size_t usb_timeout_ms = 3000;
for (const size_t start_ms = millis(); !usbSerial && (millis() - start_ms) < usb_timeout_ms;)
;
notecard.setDebugOutputStream(usbSerial);
#endif
// Initialize the physical I/O channel to the Notecard
#ifdef txRxPinsSerial
notecard.begin(txRxPinsSerial, 9600);
#else
notecard.begin();
#endif
J *req = notecard.newRequest("hub.set");
if (myProductID[0])
{
JAddStringToObject(req, "product", myProductID);
}
//JAddStringToObject(req, "mode", "continuous");
JAddStringToObject(req, "mode", "periodic");
JAddNumberToObject(req, "outbound", 2); // 2 minutes send interval
JAddNumberToObject(req, "inbound", 60); //Check for incoming data every 48 hrs
notecard.sendRequestWithRetry(req, 5); // 5 seconds
}
// In the Arduino main loop which is called repeatedly, add outbound data every
// 15 seconds
void loop()
{
float temperature = sensor.temp();
float humidity = sensor.humidity();
float pressure = 100;
float wind = 25.3;
J *req = notecard.newRequest("note.add");
if (req != NULL)
{
//JAddStringToObject(req, "file", "sensors.qo");
//JAddBoolToObject(req, "sync", true);
J *body = JAddObjectToObject(req, "body");
if (body != NULL)
{
JAddNumberToObject(body, "temp", temperature);
JAddNumberToObject(body, "humidity", humidity);
JAddNumberToObject(body, "pressure", pressure);
JAddNumberToObject(body, "wind", wind);
JAddNumberToObject(body, "voltage", voltage);
notecard.sendRequest(req);
}
//delay(30000); //15000 9000000
}
}