element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Upcycle It
  • Challenges & Projects
  • Design Challenges
  • Upcycle It
  • More
  • Cancel
Upcycle It
Blog [Upcycle It] Nixie Display #6 - Edison software, XDK, Node.js and Node-RED
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: gpolder
  • Date Created: 22 Apr 2017 5:20 PM Date Created
  • Views 2349 views
  • Likes 7 likes
  • Comments 15 comments
  • visual programming
  • upcycle_it
  • seeed studios
  • node-red
  • intel xdk
  • node.js
  • node
  • localtime
  • grove
  • lcd rgb backlight
  • upcycled_nixie
  • intel edison
Related
Recommended

[Upcycle It] Nixie Display #6 - Edison software, XDK, Node.js and Node-RED

gpolder
gpolder
22 Apr 2017
<< Previous Blog IndexNext >>

This week I played a lot with the Edison software tools. In my fourth blog I described my first steps using the Arduino SDK. As I was not completely happy with that, I switched to XDK, Node.js and Node-RED. I also detected that my firmware wasn't updated by then. This is also fixed now.

Node-RED is a visual programming environment. To be honest normally my preference does not ly with visual programming, I rather prefer Matlab for instance above LabView. Nevertheless for this application Node-RED works very well, so I would give it a try. Please read on for all the details.

 

Setting up the Edison (update)

In blog post [Upcycle It] Nixie Display #4 - Got Started with the IntelRegistered Edison Development Board on macOS I explained how the operating system was installed and setup using macOS. Unfortunately I detected that there wasn't a new system installed. The Edison just ran from its preinstalled image. After some experimenting I discovered that the problem was caused by the USB connection to my laptop by means of a USB hub. After connecting the Edison directly to the laptop USB port I could install the latest Edison image:

 

root@edison_arduino:~# cat /etc/version

201606081705

root@edison_arduino:~#

 

Then I configured the device name, password and wifi from the command line:

 

root@edison_arduino:~# configure_edison --setup

 

Next I found an addressing conflict with the Edison's USB Gadget driver network with my own home network. They both operate at 192.168.2.* and due to the conflicting address space I couldn't use the WiFi connection. This could easily be solved by editing /etc/systemd/network/usb0.network and changing  the default usb0 ip address (192.168.2.x). When I turn usb0 down or keep it up using a different ip (example: 192.168.5.15) everything works fine. More info here: https://communities.intel.com/thread/101731.

 

root@edison_arduino:~# cat /etc/systemd/network/usb0.network

[Match]

Name=usb0

 

[Network]

Address=192.168.5.15/24

 

root@edison_arduino:~#

Intel XDK

Next I installed the Intel XDK and tried the blinking LED demo as described on the intel getting start page https://software.intel.com/en-us/xdk/docs/getting-started-intel-xdk-nodejs-iot. After the first connect to the board it took quite some time for updating all the necessary software components on the Edison. After a reboot of the board I could upload and run the blinking  LED application without any problem.

Here is the console log:

Intel XDK - IoT App Daemon v0.1.6 - Node: 4.4.3, Arch: ia32

Upload on board is not from current project - uploading complete project

transferring /tmp/xdk-1173ZPBm6hm0KAE4.tar from project to board

x LICENSE.md

x README.md

x main.js

x icon.png

x package.json

x utl/cfg-app-platform.js

x utl/version-compare.js

x xdk/project-info.json

 

IMPORTANT: Executing NPM on IoT target. Wait for "Upload Complete" message before you start your app.

install complete

Upload Complete

Not auto starting by request

 

Initializing IoT LED Blink

node version: 4.4.3

mraa version: v1.0.0

mraa platform type: 2

mraa platform name: Intel Edison

os type: Linux

os platform: linux

os architecture: ia32

os release: 3.10.98-poky-edison+

os hostname: edison_arduino

Using LED pin number: 13

Remember the problems I had starting the arduino sketch on boot time ([Upcycle It] Nixie Display #4 - Got Started with the IntelRegistered Edison Development Board on macOS).

With Node.js and XDK this works flawlessly. Just select 'Board Configuration' from the manage button,

image

and check the 'Run previously loaded application at startup' checkbox.

image

 

Then I tried the I2C LCD demo from the available templates. I modified the code a bit:

 

/*
 * Drive the Grove RGB LCD (a JHD1313m1).
 *
 * This can be done using one of two methods:
 *
 * Use the UPM library, which contains direct support for the LCD device.
 *
 * Alternatively, in this app, we will drive the LCD directly from JavaScript
 * using the I2C interface directly. This approach is useful for learning
 * about using the I2C bus. The LCD file is an implementation in JavaScript
 * for some common LCD functions.
 *
 * Supported Intel IoT development boards are identified in the code.
 *
 * See LICENSE.md for license terms and conditions.
 *
 * https://software.intel.com/en-us/xdk/docs/using-templates-nodejs-iot
 */


/* spec jslint and jshint lines for desired JavaScript linting */
/* see http://www.jslint.com/help.html and http://jshint.com/docs */
/* jslint node:true */
/* jshint unused:true */


"use strict" ;


// we want mraa to be at least version 0.6.1
var mraa = require('mraa');
var version = mraa.getVersion();


if (version >= 'v0.6.1') {
    console.log('mraa version (' + version + ') ok');
}
else {
    console.log('meaa version(' + version + ') is old - this code may not work');
}


useLcd();


/**
 * Rotate through a color pallette and display the
 * color of the background as text
 */
function rotateColors(display) {
    var red = 0;
    var green = 0;
    var blue = 0;
    display.setColor(red, green, blue);
    setInterval(function() {
        blue += 64;
        if (blue > 255) {
            blue = 0;
            green += 64;
            if (green > 255) {
                green = 0;
                red += 64;
                if (red > 255) {
                    red = 0;
                }
            }
        }
        display.setColor(red, green, blue);
        display.setCursor(0,0);
        display.write('Upcycled NIXIE');
        display.setCursor(1,0);
        display.write('RGB=' + red + ' ' + green + ' ' + blue + '   ');
    }, 1000);
}


/**
 * Use the hand rolled i2c.js code to do the
 * same thing as the previous code without the
 * upm library
 */
function useLcd() {
    var i2c = require('./i2c');
    var display = new i2c.LCD(0);


    display.setColor(0, 60, 255);
    display.setCursor(1, 1);
    display.write('hi there');
    display.setCursor(0,0);
    display.write('more text');
    display.waitForQuiescent()
    .then(function() {
        rotateColors(display);
    })
    .fail(function(err) {
        console.log(err);
        display.clearError();
        rotateColors(display);
    });
}

 

And here is the result:

image

So far my experience with Node.js is positive and for the Edison I prefer this above the Arduino SDK.

 

Node-RED

Nice aspect of Node.js is that you can run nice stuff on top of it, such as Node-RED (https://nodered.org/ ) jasonwier92 already described some experiments with Node-RED (Getting To Know the Sensors with Node-Red [Upcycle It #3]). As you might remember from my [Upcycle It] Nixie Display #1 - Introduction I want to display weather, or other data from the internet on the Nixie display. Node-RED should make that perfectly possible using the node-red-node-openweathermap (http://flows.nodered.org/node/node-red-node-openweathermap).

Lets give it a try: (my procedure is slightly different from jasonwier92's)

 

root@edison_arduino:~# npm install --unsafe-perm node-red

root@edison_arduino:~# cd /usr/bin

root@edison_arduino:~# ln -s /home/root/node_modules/.bin/node-red node-red

root@edison_arduino:~# ln -s /home/root/node_modules/node-red/bin/node-red-pi node-red-pi

root@edison_arduino:~# cd

root@edison_arduino:~# npm install -g pm2

root@edison_arduino:~# pm2 start node-red --node-args="--max-old-space-size=128"

root@edison_arduino:~# pm2 save

root@edison_arduino:~# pm2 startup

root@edison_arduino:~# reboot

I skipped all the informational commands in the listing above, as they are not necessary, although very informative.

A video of the complete proces can be found here: (https://youtu.be/28fknvDEAwc )  at 18:50 the installation of Node-RED starts.

 

In order to control the grove starter kit sensors I need to install a node library for that. First one I found (http://flows.nodered.org/node/node-red-node-upm ) looks promising:

root@edison_arduino:~# npm install node-red-contrib-upm

root@edison_arduino:~# reboot

I tried die LCD module, but unfortunately that didn't work, I got a "TypeError: LCD.Jhd1313m1 is not a function" error when deployed.

Next I found a library with nodes from seed studio (http://flows.nodered.org/node/node-red-contrib-smartnode-seeed ):

root@edison_arduino:~# npm install node-red-contrib-smartnode

root@edison_arduino:~# npm install node-red-contrib-smartnode-seeed

root@edison_arduino:~# reboot

That one worked, with three simple blocks I got a clock up and running, here is a picture of the flow:

image

The timestamp injects the number of milliseconds since January 1st, 1970 into the flow. The 'numdate' is a function node in which I put code to convert the time number to a readable time string:

 

// Create a Date object from the payload
var date = new Date(msg.payload);
// Change the payload to be a formatted Date string
msg.payload = date.toString();
// Return the message so it can be sent on
return msg;

 

And the screen node is the LCD screen from the node-red-contrib-smartnode-seed node. As you can see the info field has the Chinese locale. That doesn't influence its functionality, but would be nice if there also is a english translation available. I will have a look at that later.

So using this three simple blocks I built a clock. What also is very convenient is that it automatically starts when powering up the edison.

image

As you can see it is displaying GMT time, which is not my timezone. This could easily be fixed by changing the local time file:

root@edison_arduino:~# rm /etc/localtime
root@edison_arduino:~# ln -s /usr/share/zoneinfo/Europe/Paris /etc/localtime
root@edison_arduino:~# reboot
...................................
root@edison_arduino:~# date
Sat Apr 22 17:20:44 CEST 2017

 

Thats it for this week, Node-RED looks like the ideal candidate to continue my project image.

Next steps will be to test the node-red-node-openweathermap (http://flows.nodered.org/node/node-red-node-openweathermap) node and make a Node-RED node for connecting to the PCF8574 I/O extenders in order to control the Nixie tubes.

But first I need to work on the hardware. Last week my PCB's arrived, I will blog about that next week.

 

Stay tuned.

  • Sign in to reply

Top Comments

  • gpolder
    gpolder over 8 years ago in reply to jasonwier92 +1
    Jason Wier wrote: The node-red install was the same as mine. I'm missing the ln -s /home/root/node_modules/node-red/bin/node-red-pi node-red-pi in your description, don't know how important that is. Great…
  • jasonwier92
    jasonwier92 over 8 years ago in reply to jasonwier92 +1
    Working now. I had to power off the Edison.
Parents
  • jasonwier92
    jasonwier92 over 8 years ago

    My install went slow and I have been fighting problems from trying to get the smartnode-seeed working.  Now I am getting this error in my logs

     

    0|node-red | 24 Apr 12:19:20 - [error] [Seeed-Screen:84650ddf.e5d688] Error: Illegal arguments for construction of _exports_Jhd1313m1

     

    Have you seen that??

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • gpolder
    gpolder over 8 years ago in reply to jasonwier92

    Hi jasonwier92 no didn't see that, did you install node-red-contrib-smartnode?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jasonwier92
    jasonwier92 over 8 years ago in reply to gpolder

    Yes, I also installed the UPM (node-red-contrib-upm). Right now I removing the UPM.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • gpolder
    gpolder over 8 years ago in reply to jasonwier92

    didn't the UPM also work for you?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jasonwier92
    jasonwier92 over 8 years ago in reply to gpolder

    Thought that might be what is breaking things, but I was not 100% correct (aka wrong).  So I edited the flow.json file and remove the LCD and it was then fine. 

     

    Then I added it back and it started crashing again.  It rebooted my Edison last night it was so bad.

     

    Back to my other plan.  I do not see where you can control the RGB values anyways via the Screen Node.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • jasonwier92
    jasonwier92 over 8 years ago in reply to gpolder

    Thought that might be what is breaking things, but I was not 100% correct (aka wrong).  So I edited the flow.json file and remove the LCD and it was then fine. 

     

    Then I added it back and it started crashing again.  It rebooted my Edison last night it was so bad.

     

    Back to my other plan.  I do not see where you can control the RGB values anyways via the Screen Node.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
  • jasonwier92
    jasonwier92 over 8 years ago in reply to jasonwier92

    Working now.  I had to power off the Edison.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jasonwier92
    jasonwier92 over 8 years ago in reply to jasonwier92

    I am really thinking about this today.  The output works great, but not the color set.  Where you able to set the color?

     

    image

     

    This is my flow and it is mostly like yours.  But by function switch the output to one of the three screens and the time gets displayed, but the color does not change.

    image

     

    Here is the Red Screen.  Debug works find, the msg is going to the correct place, but no color change.

     

    image

     

     

    Anyone else changing color of the LCD from the Node-Red?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • gpolder
    gpolder over 8 years ago in reply to jasonwier92

    Great that it works now.

    Color doesn't change on msg, we need to write another node I think.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jasonwier92
    jasonwier92 over 8 years ago in reply to gpolder

    I think you are correct, but I think it is out of the scope to set the color.  The color is setup by the last screen defined.

     

    image

     

    That is the code and the color is set on the instance of the module and not on msg.  I am thinking of making some changes to the module.

     

    I will try it and let you know how it works.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jasonwier92
    jasonwier92 over 8 years ago in reply to jasonwier92

    Never mind, I looked at it and it is already compiled.  Guess I will keep my LCD control outside of Node-red still.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube