XStore

NORVI Library (Norvi.publish) – Library Guide

The NORVI library lets your sketch send readings from a NORVI-XN to your own cloud with a single line of code. You call Norvi.publish() with a name and a value, and the OTA & Communication Manager handles the connection underneath.

This guide explains what the library does, how to use it in Neural Studio or the Arduino IDE, which kinds of values you can send, and what to check if something does not work. Version 1.0.0 contains one function, Norvi.publish(). More functions will be added in future versions.

Key Features #

  • One call sends a reading. Norvi.publish("name", value) is all your sketch needs.
  • No connection code. The OTA & Communication Manager handles the connection to your cloud.
  • Any reading you choose. Send whole numbers, decimal numbers, true/false values or text, under any field name you pick.
  • Several values at once. Send many fields in one call using a JSON object.
  • Works in Neural Studio. The library is built in, so there is nothing to install.
  • Simple result. Every call returns true when the reading was accepted and false when it was not.

How It Works #

Your sketch calls Norvi.publish() with a field name (what the reading is called) and a value. The OTA & Communication Manager sends the reading to your cloud, where it appears under that field name.

Your code → OTA & Communication Manager → your cloud

You choose the field names. A tank level, a motor current, a door state, a counter or a status message are all valid readings.

Getting the Library #

The library works with the NORVI-XN only.

Neural Studio (recommended) #

The NORVI library is already included in Neural Studio. You do not need to install anything. Add this line at the top of your sketch and start publishing:

#include <Norvi.h>

Arduino IDE #

If you use the Arduino IDE, install the library once:

  1. Open the library page on GitHub
  2. Download the repository (Code → Download ZIP) and extract it.
  3. Copy the Norvi folder from the libraries folder into your Arduino libraries folder. On Windows this is usually Documents\Arduino\libraries.
  4. Close and reopen the Arduino IDE.
  5. Open File → Examples. You should see Norvi with two examples, PublishExample and PublishJson.

Select your NORVI-XN board under Tools → Board before you compile.

Quick Start #

This short sketch sends one reading every second.

Copy
#include <Norvi.h>
void setup() { Serial.begin(115200); }
void loop() {
  Norvi.publish("tank_level", 72.5f); delay(1000);
}
LineMeaning
#include <Norvi.h>Loads the NORVI library.
Serial.begin(115200);Starts the serial port.
Norvi.publish("tank_level", 72.5f);Sends a reading called tank_level with the value 72.5.
delay(1000);Waits one second between readings.

tank_level is only an example. Use any field name that suits your project, and replace 72.5f with the value from your sensor or your program.

Sending Values #

FormValue typeExample
Norvi.publish(name, int)Whole numberNorvi.publish("count", 42);
Norvi.publish(name, float)Decimal numberNorvi.publish("flow_rate", 3.8f);
Norvi.publish(name, bool)True or falseNorvi.publish("running", true);
Norvi.publish(name, String)TextNorvi.publish("status", String("ready"));
Norvi.publish(String json)Several fields at onceSee below

Sending several values at once #

To send more than one value in one call, pass a JSON object. JSON is a simple way to write names and values inside curly braces.

Norvi.publish(String("{\"pressure\":1012,\"alarm\":false}"));

The backslashes before the quotation marks are needed because the JSON text sits inside a C++ string. This example sends two fields, pressure and alarm.

Field Names #

RuleDetails
Length1 to 64 characters
First characterA letter
Other charactersLetters, digits and the underscore _
ReservedNames must not start with ni, fw, rst, cmd, log or ota (upper or lower case)

Good names: tank_level, motor1_current, door_open

Rejected names: 1pump (starts with a digit), my-value (contains a hyphen), log_count (starts with log)

Limits and Return Value #

  • You can publish up to 10 times per second. Readings sent faster than that are dropped.
  • A single message can be up to 1024 bytes.
  • Every call returns true when the reading was accepted and false when it was not. A call returns false if the field name is invalid, the JSON is invalid, the message is too large, or you publish too fast.

Checking the result is optional, but it helps while you are testing:

if (!Norvi.publish("count", 42)) {
  Serial.println("Reading was not sent");
}

For most projects, one reading per second or slower is plenty.

Example Sketches #

The library includes two examples under File → Examples → Norvi in the Arduino IDE.

ExampleWhat it shows
PublishExampleOne reading of each type, plus a JSON batch.
PublishJsonSending several fields in one call.

Troubleshooting #

ProblemWhat to check
Norvi.h: No such file or directory in the Arduino IDEThe library is not installed. Check that the Norvi folder is inside your Arduino libraries folder, then restart the IDE.
Norvi.publish() returns falseCheck the field name against the rules above. For JSON, check the braces, quotation marks and commas. Do not publish more than 10 times per second.
Nothing arrives in your cloudMake sure Serial.begin(115200); is in setup(). Make sure your NORVI-XN is online and linked to your cloud, as described in your NORVI-XN guide. Publish one reading per second while testing.
Some readings are missingYou published faster than 10 times per second. Add a longer delay() between readings.

What Is Coming #

Version 1.0.0 contains only Norvi.publish(). More functions will be added in future versions. See the CHANGELOG.md file in the library folder for what is new.

Resources #