Note Red Sample Application

I have multiple Node Red flows that we use to connect Raspberry Pi applications to the cloud. Now we are interested in trying out blues wireless. Do you have any sample applications we can copy for this? That is, how do I connect a Node-Red flow to your Raspberry Pi Notecarrier / Notecard combo?

thanks!

2 Likes

Hi @leehouse!

Thanks very much for your question. I’m pretty excited about it actually because I’ve been working on a Node Red custom node for communicating with the Notecard.

We are planning on releasing the initial version in the Node Red repositories shortly.

I do have a couple of questions:

  1. How do you envision connecting the Notecard with the Raspberry Pi?
  1. Which Raspberry Pi hardware are you planning on using?

Thanks very much!
Cheers,
-Greg

2 Likes

How cool is that!? As for how we will connect, we are new to blues wireless, so wanted to make it easy … thinking that the Notecarrier-Pi would be the most streamlined path. What would that use? USB? I2C? Serial? Also “Shortly” is great, but I am in a pretty big hurry to demo this connectivity. If it works, we would be happy to beta.

Thanks,

Lee

The Notecarrier Pi uses the I2C

it also works on serial

@leehouse

Initial release of Notecard Node Red package available!

Let us know if you get a chance to try it out!

2 Likes

Updated to release 1.0.0.

Please check the README.md for info about compatibility.

2 Likes

Greg,

I am trying to use the node-red-contrib-notecard v1.0, but I can’t seem to configure it … I am seeing this screen with now “pull down” to configure the notecard (image attached).

Am I missing something?

Thanks,

Lee

If you want to give a quick ring I will pick up if I can (BTW I am on Pacific time - phone number below). :slightly_smiling_face:

Here is the image in-line:

I can’t tell exactly what’s going on. Looking at the terminal window that is mostly hidden by the Node Red page, there is an exception being thrown.

I will try to reproduce it to figure out what is going on.

Do you have I2C enabled on the Raspberry Pi?

I know you are using the GUI interface for the RPI, so please check out the following:

I know it’s for SSH, but check out the section titled Enable SSH on Raspberry Pi using GUI Configuration Options

There’s no need to enable SSH in this case.

In the SAME GUI, you can enable I2C

Let me know if that is the issue.

When I first loaded the node, I did not! This may have been a key issue, no doubt (no warning of this!). After, I enabled it I have not been able to unwind the problems with the configuration node set in node red. I have no idea how to remove the bad configuration input this added to node red settings!

Ok let me see what I can do to put something together for you.

I Tried To Reproduce the Issue

I tried reproducing the issue by

  1. Stopping Node Red process

  2. Disabling the I2C interface

  3. Re-starting Node Red

  4. Attempting to send a message to Notecard. This did result in an error message in the Linux Terminal on the RPi. (I’ll update the doc and error handling to mitigate this issue in the future)

  5. Renabling I2C interface

At this point everything started working as expected.

I wasn’t able to reproduce any errors.

Restart Node Red

I recommend restarting Node Red.

If Restarting Node Red isn’t Enough

If that doesn’t work, try removing the config node.

To remove the node:

  1. Click the hamburger button to open the Node Red menu

  2. Click Configuration Nodes
    image

  3. Expand On all flows

  4. Double click on the notecard-config node, probably named default
    image

  5. Click the Delete button in the dialog that opens up

At this point the Notecard Request node in the flow should have an orange triangle indicating there’s a configuration error

image

To re-add the notecard-config node:

  1. Double-click on the Notecard Request node

  2. Click the edit button next to Add new notecard-config
    image

  3. Click Add button (the default configuration should be fine)

image

  1. Click Done button

  1. Redeploy the Flow and test it out.

Please let me know how that works out.

Cheers,
-Greg

1 Like

Scott,

I tried this all, but somehow the config node is not getting set up. Here is a screen shot after a re-install of the node-red-contrib-notecard:

On the right, you can see “default2” is there, and it shows the expected values in it when I double click it, yet the system still sees this has having a missing node type (BTW, I was calling it default, but changed it this time “just in case” this was some kind of issue …)

Thanks,

Lee

Resolution:
Upgraded Node Red and using NodeJS 12.20.0.

Here’s the link to install/update Node Red
https://nodered.org/docs/getting-started/raspberrypi#installing-and-upgrading-node-red

1 Like

The upgrade resolved the configuration node issues, but now I have some new issues:

Greg, I am now getting this message:

(node:17838) UnhandledPromiseRejectionWarning: Error: Bytes not available on Notecard (maybe due to transaction timeout)
at I2CTransactor.doTransaction (/home/pi/.node-red/node_modules/node-red-contrib-notecard/notecard/i2c-transactor.js:95:19)
(node:17838) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command-line options | Node.js v15.7.0 Documentation). (rejection id: 205)

… it seems that my messages (JSON Objects) are only sometimes being transmitted to the notecard - not sure why … I even made the object smaller (2 values) to see if this had anything to do with it …

What seems to be happening is that the node-red is sending the data to the notecard, but the notecard does not “see” it … when I do a {“req”: “hub.sync”} (nothing was pending) (even though the data seems to be there) … then if I issue a {“req”: “card.restart”}, and then a “w on” then the card actually sends the data that was pushed to it from node-red before … so the data was there, but for some reason was not seen … it seems likely that this I2C error message would have something to do with this …

Another odd thing is that I don’t see the expected “ack” from the notecard node, such as { total : 1 }.

What am I doing wrong here?

Do you have a complete flow that handles not only pushing data to the notecard, but also triggering the sync as well as any “housekeeping” that may be required? Thanks!

I just put together some example flows. I think this could help as it will sync data with the cloud and offload the data enqueued on the Notecard.

There’s more to get into regarding note.template but lets start with this.

Here’s Notecard Config:

[{"id":"24aa7f87.d1569","type":"tab","label":"Notecard Connectivity","disabled":false,"info":"# Configure Notecard for Connectivity\nTo communicate with the cloud, Notecard requires\n * A Product UID\n * A cloud synchronization policy\n\nFor more information about configuring these elements, view the links below.\n\n## Documentation Links\n\n### Setting Product UID:\nhttps://dev.blues.io/reference/notecard-walkthrough/essential-requests/#notehub-configuration\n\n### Cloud Synchronization Policy\nhttps://dev.blues.io/reference/notecard-walkthrough/essential-requests/#configuring-synchronization-modes\n "},{"id":"4454225f.a1e59c","type":"inject","z":"24aa7f87.d1569","name":"Product UID","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"req\":\"hub.set\",\"product\":\"<my-product-uid>\"}","payloadType":"json","x":170,"y":140,"wires":[["b449c4bb.506e78"]],"info":"# Product UID\nUnique identifier that is required for Notecard to connect to the cloud.\n\nUsually of the form\n\n`com.company.user.xxxxx`\n\n\nIdentifies which notehub.io project will own the data synced with this Notecard.\n\n\n## THIS IS REQUIRED FOR NOTECARD TO FUNCTION\nMany features of Notecard require the Product UID to be configured for them to function.  \n\nSee Also:\n[Setting a Product UID](https://dev.blues.io/reference/notecard-walkthrough/essential-requests/#setting-a-productuid-and-serial-number)\n"},{"id":"efaab9cf.507168","type":"inject","z":"24aa7f87.d1569","name":"Periodic Mode","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"req\":\"hub.set\",\"mode\":\"periodic\",\"outbound\":1,\"inbound\":7}","payloadType":"json","x":170,"y":260,"wires":[["b449c4bb.506e78"]],"info":"# Periodic Connectivity\nConfiguration policy to set cloud connectivity on a periodic schedule.\n\n`mode`: **Periodic**  -- turns on the modem and attempts to establish a cloud sync session on a periodic schedule.  When sync is completed, session is closed and the modem turns off.\n\n\n`outbound`: number of minutes between cloud data syncs _if_ there is new Notes stored on Notecard since the last data sync\n\n`inbound`: number of minutes between cloud data syncs regardless of new Notes being available on Notecard since the last data sync"},{"id":"b207afeb.2440c","type":"inject","z":"24aa7f87.d1569","name":"Continuous Mode","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"req\":\"hub.set\",\"mode\":\"continuous\",\"outbound\":1,\"inbound\":7}","payloadType":"json","x":160,"y":340,"wires":[["b449c4bb.506e78"]],"info":"# Periodic Connectivity\nConfiguration policy to set cloud maintain cloud connectivity continuously.\n\n`mode`: **Continuous** -- maintain connection to the cloud continuously.  Re-establish connections if it becomes disconnected.\n\n`outbound`: number of minutes between cloud data syncs _if_ there is new Notes stored on Notecard since the last data sync\n\n`inbound`: number of minutes between cloud data syncs regardless of new Notes being available on Notecard since the last data sync"},{"id":"b449c4bb.506e78","type":"notecard-request","z":"24aa7f87.d1569","notecard":"31ab40b8.fe425","name":"","payload":"payload","payloadType":"msg","outputType":"","x":440,"y":140,"wires":[["3a169bcc.1a6bc4"]]},{"id":"3a169bcc.1a6bc4","type":"debug","z":"24aa7f87.d1569","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":650,"y":140,"wires":[]},{"id":"db0bb553.b81728","type":"comment","z":"24aa7f87.d1569","name":"Configure Notecard Connectivity -- read description of each injection node in flow","info":"","x":360,"y":80,"wires":[]},{"id":"2d5bef4c.150cf","type":"comment","z":"24aa7f87.d1569","name":"must set Product UID","info":"# If you don't have a Product UID or Notehub Project\nSee this tutorial: https://dev.blues.io/build/quickstart/#create-a-notehub-project\n\n","x":140,"y":180,"wires":[]},{"id":"8ccd19aa.b99d98","type":"inject","z":"24aa7f87.d1569","name":"Force Sync Attempt","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"req\":\"hub.sync\"}","payloadType":"json","x":150,"y":400,"wires":[["b449c4bb.506e78"]],"info":"# Force Hub Sync Attempt\nRequest that forces a Notecard cloud sync attempt, as long as the `hub.set:mode` is not set to `off`\n\nSee also:\nhttps://dev.blues.io/reference/complete-api-reference/hub-requests/#hub-sync\n\n\n"},{"id":"31ab40b8.fe425","type":"notecard-config","name":"default","busno":"1","address":"0x17"}]

Adding Notes to Notecard:

[{"id":"b4be7279.4080e","type":"tab","label":"Adding Notes","disabled":false,"info":"# Add Notes to Notecard\nNotes are the primary means of storing sensor data that will be synched to the cloud.\n\nFor more information about adding Notes, see:\n\n - [Quickstart Tutorial](https://dev.blues.io/build/quickstart/#queue-notes-to-your-notecard)\n - [note.add request](https://dev.blues.io/reference/complete-api-reference/note-requests/#note-add)"},{"id":"b67112b.e0ed9f","type":"inject","z":"b4be7279.4080e","name":"Simulate New Sensor Data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"sensor_data_1\":$now()}","payloadType":"jsonata","x":150,"y":280,"wires":[["12c10004.8cb51"]],"info":"Simulate creation of sensor data by creating a JSON object where the field values change each time it is injected."},{"id":"c440d2fd.a6a1a","type":"debug","z":"b4be7279.4080e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":280,"wires":[]},{"id":"12c10004.8cb51","type":"function","z":"b4be7279.4080e","name":"note.add","func":"// Create note.add request for Notecard\nconst request = {\n    req: \"note.add\",\n    body: msg.payload\n}\n\n// Store request in message payload\nmsg.payload = request;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":360,"y":280,"wires":[["52109e38.25414"]],"info":"# Create note.add Request\nCreates a JSON object formulated to a `note.add` request for Notecard\n\n`body`: JSON object that is the user defined data of a Note that is enqueued on Notecard.\n"},{"id":"52109e38.25414","type":"notecard-request","z":"b4be7279.4080e","notecard":"31ab40b8.fe425","name":"","payload":"payload","payloadType":"msg","outputType":"","x":550,"y":280,"wires":[["c440d2fd.a6a1a"]]},{"id":"a1dee01c.1d745","type":"comment","z":"b4be7279.4080e","name":"Enqueue Data on Notecard","info":"","x":150,"y":220,"wires":[]},{"id":"31ab40b8.fe425","type":"notecard-config","name":"default","busno":"1","address":"0x17"}]

Start with this to see if this helps.