I want to receive multiple event reading from my sensor for example 100 readings per second what changes shall i do in my code to receive this multiple readings.
Hi @Jayant,
When you say “receive” I’m assuming you mean in the cloud and not just stored on the Notecard. This concept of a high frequency relay of data is a bit outside the design center of the Notecard, but you can certainly experiment with a variety of settings.
- Make sure the Notecard is in
continuous
mode. - Use the
"live":true
argument in yournote.add
API request. This will prevent the Note itself from being stored in flash on the Notecard, which speeds things up but also adds some risk of losing data. - Consider lumping multiple readings into one Note instead of making numerous separate requests.
- Use the web APIs to bypass saving Notes in Notehub and instead use Notehub to relay data directly to a cloud endpoint.
I’d be surprised if anything close to 100 requests/second is even possible, but it’s worth an attempt. You’re also going to go through a lot of consumption credits when sending this many events, so it would be worth reaching out to our sales team to come up with a more palatable pricing plan.
Rob
Actually i am working on a project where i want temperature reading in every 100ms. there was an inbuilt temperature sensor in this device so i just want to try the get reading from notecard in every 100ms. is their any specific request command where i can set the reading frequency. the system is like i have a temperature sensor want its reading after every 100ms
#include <Arduino.h>
#include <Notecard.h>
#include <NotecardPseudoSensor.h>
#define usbSerial Serial
#define productUID “com.gmail.jayantgupta072:testingnew”
Notecard notecard;
using namespace blues;
NotecardPseudoSensor sensor(notecard);
void setup() {
delay(100);
usbSerial.begin(115200);
// Initialize Notecard, set debug output, and configure continuous mode
notecard.begin();
notecard.setDebugOutputStream(usbSerial);
J *req = notecard.newRequest(“hub.set”);
JAddStringToObject(req, “product”, productUID);
JAddStringToObject(req, “mode”, “continuous”);
notecard.sendRequest(req);
}
void loop() {
float temperature = sensor.temp();
usbSerial.print(“Temperature = “);
usbSerial.print(temperature);
usbSerial.println(” *C”);
delay(10);
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)
{
JAddNumberToObject(body, “fuel”, temperature);
}
notecard.sendRequest(req);
}
delay(10);
}
this was the code i was using to receive data but even after delays of 10ms notecard is sending data every second. what modification in code is needed please let me know.
100reading was just an example
Again just to be clear - even if you send 10 events/second, that will eat through your monthly free events in less than 9 minutes.
That being said, see what I wrote earlier about what you can try. For example you can add this to your note.add request to bypass storing Notes on the Notecard (otherwise you will fill up flash storage before it’s even able to send everything to Notehub):
JAddBoolToObject(req, "live", true);