Get Started with the Notecard and Cellular IoT on June 8th !

Blues Developers
Search
Documentation Results
End of results
Community Results
End of results
What’s New
Blues.io
Notehub.io
Shop
Sign In
What’s New
Blues.io
Notehub.io
Shop
×
HomeGuides & Tutorials
Welcome
Collecting Sensor Data
Routing Data to Cloud
Building Edge ML Applications
Twilio SMS Guide
Fleet Admin Guide
Using the Notehub API
Notecard Guides
Guide Listing
Asset Tracking
Attention Pin Guide
Connecting to a Wi-Fi Access Point
Debugging with the FTDI Debug Cable
Diagnosing Cellular Connectivity Issues
Encrypting Data With the Notecard
Minimizing Latency
Notecard Communication Without a LibraryBasic CommunicationsArduino ExampleSummary
Notecard Outboard Firmware Update
Remote Command and Control
Serial-Over-I2C Protocol
Understanding Environment Variables
Understanding Notecard Penalty Boxes
Updating ESP32 Host Firmware
Using External SIM Cards
Using JSONata to Transform JSON

Notecard Communication Without a Library

Raw serial transactions with the Notecard allow you to communicate with the Notecard in the most direct and efficient way possible. This technique can be employeed when there are memory or language constraints on the device.

These raw transactions are also the foundation of creating native language support libraries, such as those found in our firmware libraries overview

warning

When NOT using a native firmware library, you may unintentionally send requests to the Notecard so fast that you overflow the 1500 byte buffer used to receive data (whether it be I2C, Serial, or UART). The solution is to pause 250ms after every ~250 bytes sent, and to ensure the total size of each NDJSON object sent is no more than 8KB.

Basic Communications

Vocabulary

  • chunk - a string or "chunk" of data less than 256 bytes
  • polling delay - the time between consecutive Notecard requests
  • segment - a series of chunks less than or equal to 256 bytes

Timing

The Notecard serial transactions, both UART and I2C, are implemented without flow control. As such, certain timing requirements must be observed to ensure the integrity of serial communications with the Notecard.

  • Each chunk should observe a 20ms delay.
  • Each segment requires a 250ms delay.
  • A polling delay of 25ms should be respected to allow the Notecard time to process a request and generate a response.

Arduino Example

  1. First, let's alias the Serial interfaces at the top of your program in the Arduino IDE. The first, Serial will be used to log information to the Serial Monitor of the Arduino IDE. The second, Serial1 represents the connection between your Arduino and Notecard. Paste the following code at the top of your sketch:

    #define usbSerial Serial
    #define txRxPinsSerial Serial1
  2. Next, add a definition for your ProductUID using the value you specified when creating your Notehub project.

    #define NOTE_PRODUCT_UID "com.your-company:your_product"
  3. In the setup() function, initialize the usbSerial object.

    usbSerial.begin(115200);
    while (!usbSerial) {
       ; // wait for serial port to connect. Needed for native USB
    }
    usbSerial.println("Starting...");
  4. Also in setup, initialize the txRxPinsSerial object, using a baud rate of 9600, and send a newline (\n) to clear out any pending data on the device.

    txRxPinsSerial.begin(9600);
    txRxPinsSerial.println("\n");
    delay(250);
  5. Now, we'll configure the Notecard. This one-time operation also belongs in the setup() function. We will use the hub.set request to associate this Notecard with the ProductUID of your project, as well as set the Notecard to operate in continuous mode (which indicates that the device should immediately make a connection to Notehub and keep it active).

    txRxPinsSerial.println("{\"req\":\"hub.set\",\"product\":\"" NOTE_PRODUCT_UID "\",\"mode\":\"continuous\"}");
  6. Finally, we'll add a while loop to setup to read the Notecard's response, and display the result to the Arduino terminal.

    delay(250); // wait for the Notecard to respond
    while (txRxPinsSerial.available() > 0) {
        char incomingByte = txRxPinsSerial.read();
        if (incomingByte != '\r' && incomingByte != '\n') {
           usbSerial.print(incomingByte);
        }
    }
    usbSerial.println();
  7. Now, it's time to watch the logs and validate the firmware. Open the Serial Monitor, by selecting Tools > Serial Monitor from the menu. The default baud rate is 9600 baud, so be sure to select 115200 baud from the drop down menu.

  8. Click the upload button (right arrow icon) to save and flash the firmware to your device.

    If you haven't saved your file yet, you will be prompted to do so. Name your sketch (for example, nano-no-library), and click Save. Once your device is flashed and comes back online, check the serial monitor to confirm your Notecard has been properly configured.

    Starting...
    {}

Summary

As you can see, creating such a library is as simple as communicating with the Notecard itself. However, timing is an important consideration that cannot be easily reasoned about. This document aims to close that knowledge gap and enable the creation of these libraries and so much more.

Additional Resources

  • GitHub: note-c Official C SDK
  • GitHub: note-python Official Python SDK
  • GitHub: note-tutorial Arduino Nano with no library
  • GitHub: note-tutorial ESP32 with no library
Can we improve this page? Send us feedback
© 2023 Blues Inc.Terms & ConditionsPrivacy
blues.ioTwitterLinkedInGitHubHackster.io
Disconnected
Notecard Disconnected
Having trouble connecting?

Try changing your Micro USB cable as some cables do not support transferring data. If that does not solve your problem, contact us at support@blues.com and we will get you set up with another tool to communicate with the Notecard.

Advanced Usage

The help command gives more info.

Connect a Notecard
Use USB to connect and start issuing requests from the browser.
Try Notecard Simulator
Experiment with Notecard's latest firmware on a Simulator assigned to your free Notehub account.

Don't have an account? Sign up