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 Getting To Know the Sensors with Node-Red [Upcycle It #3]
  • 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: jasonwier92
  • Date Created: 10 Apr 2017 11:32 AM Date Created
  • Views 1280 views
  • Likes 4 likes
  • Comments 5 comments
  • node-red
  • upcycle it
  • upcycled_pdu
  • pdu
Related
Recommended

Getting To Know the Sensors with Node-Red [Upcycle It #3]

jasonwier92
jasonwier92
10 Apr 2017

After I have two OS's installed and running on the Edison, I wanted to test. I am looking to use NodeJS and Python to complete most or all of my Upcycle It challenge, so with either OS, I need to know things are going to work before I go down the wrong path, spin my wheels in the mud and go back to get on the right path. Now I think there is not a right path in this challenge, but I know there is going to be a path that is less rocky and have fewer mud holes.

 

My Test Setup

In thing about some of the sensor I am going to be using, I started with some from the kit.  I have the touch sensor, button, LED, LCD RGB, and temperature sensor plugged in.  I picked these for the following reasons.

  • LCD RGB - an I2C device to explore with
  • Button - digital input device
  • Touch sensor - Another digital input and I have a friend whom is having trouble with his
  • LED - digital out
  • Temperature - analog input

 

 

Ubilinux Path

My first attempt was to try Ubilinux. Ubilinux sounded a bit more what I was used to, being a Debian based distribution. With this board still on the Arduino board, the SHIELD plugged in and the RGB LCD secured to a I2C port, I start experimenting.  First things first, what do I have to work with. There is no NodeJS, but there is Python 2.7, but I want to start with NodeJS for some odd reason.

 

I start with installing Node Version Manager (NVM).  This is a fast way to get NodeJS and NPM installed and working, with a big plus that you can use different versions. I thought that this would be very useful since I might need to change versions of NodeJS depending on support. NVM installation is simple, just run "" and watch it do it's thing. When it is done, you can either logout and back in or run the commands that were are shown to be added to your profile script. Post NVM setup, installing NodeJS is simple, just figure out what version you would like, I suggest one of the Long Term Support (LTS) versions, unless you need otherwise, with the command "nvm ls-remote". At the time, the LTS version is v6.10.1, so I installed it with "nvm install v6.10.1". Wait a bit for it to do it's thing and then node is ready to use. NOW WHAT???

 

My biggest problems are yet to come, as I can get MRAA to compile, but I cannot get the MRAA libraries for node to install. I also had problem with UPM.  I did have some success with Python and the LCD, but not that exciting.  I have put this on the back burner and I am pushing forward with testing with Yacto.  But I will return and get this to work and at that point I will report my success.

 

Yacto Path

Now for some success.  I used the latest Yacto as it seemed to work right out of the gate for what I wanted.  First steps were to install Johnny-Five and play with some of the example code they have supplied for the Edison and Grove. This is a very nice library to get started testing.  I did find one problem and that is with the button or touch sensor, the LED in their sample code would not turn off.  The off command is sent, but it would not turn off the LED.  This did not really bother me as I knew I was not going to use Johnny-Five to start with, but I might use it to interact with the LCD, more on that later.  Here are my steps to getting started with the Johnny-Five (as root):

 

# mkdir testing

# npm install johnny-five

# npm install edison-io

# git clone https://github.com/rwaldron/johnny-five.git

# cp johnny-five/eg/grove-lcd-rgb-temperature-display-edison.js .

# vim grove-lcd-rgb-temperature-display-edison.js

# node grove-lcd-rgb-temperature-display-edison.js

 

Change grove-lcd-rgb-temperature-display-edison.js to reference the johnny-five as the module and not the absolute path it is referenced in the example. It already uses the I2C and the temperature sensor on A0 and that is how I have it all hooked up. Worked like a charm. I then tested out a few of the other examples and trouble shot the LED for a while, but on to better stuff.

 

Node-red setup

 

I really think I want to force myself to use something new and I have played with Node-Red, but always have turned to something that I know better when it is crunch time. So for this project I want most of it to be done in Node-Red.  So first lets install Node-red and some of what we need to get started.

# npm install --unsafe-perm node-red

# cd /usr/bin/

# ln -s /home/root/node_modules/.bin/node-red node-red

 

Next install pm2 so that we can control Node-Red better and start it on system restart.

 

# npm install -g pm2

# cd

# node-red --max-old-space-size=128

# pm2 start node-red --node-args="--max-old-space-size=128"

#  pm2 info node-red

# pm2 logs node-red

# netstat -ln

# pm2 save

# pm2 startup

 

Few modules that will make our experience useful in Node-Red

 

# cd node_modules/node-red/

# npm install --save node-red-contrib-gpio

# npm install galileo-io

# pm2 restart node-red

 

Node-Red Examples

Here is my example to test.  I have GPIO inputs of Button and Touch that output to the LED.  If the button is pushed or the touch sensor touched the LED turns on, very simple. If the button is released or the touching stops the LED turns off.  But also those messages are sent out MQTT (eddy2 button).  Also I have the MQTT input, "Eddy2 LED" that I can send a 0 or 1 to to turn off or on the LED respectively.

image

Here is my "eddy2 button" setup.

 

image

 

Next on my agenda will be:

  • Block diagram of my project
  • Setup more complex MQTT topic structure in working with vlasov01 on his sensor/alarm project.
  • Experiment more with the current board in the PDU
  • LCD output via MQTT messages (if not in Node-Red)
  • More Node-Red
  • Trying to get Ubilinux to work
  • Use of the Mini-board
  • Sign in to reply

Top Comments

  • jasonwier92
    jasonwier92 over 8 years ago in reply to Workshopshed +1
    Yes, it works on Raspberry Pi, BeagleBone Black, and Edison to interact with GPIO. It was originally designed to work with a computer and Arduino running Firmata (Now "Standard Firmata Plus"). JavaScript…
  • jasonwier92
    jasonwier92 over 8 years ago in reply to jasonwier92 +1
    This would be good for your RC Car as Johnny-Five was designed to do just this. I would be interested to see if one could run Firmata on the MCU.
  • mcb1
    mcb1 over 8 years ago +1
    Lots of new information coming out of theses challenges. Nice to see there are alternatives, so when one door slams shut, another is unlocked. Mark
Parents
  • Workshopshed
    Workshopshed over 8 years ago

    What does Johnny-Five do on the Edison? I thought it was for remote control of Microcontrollers?

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

    Yes, it works on Raspberry Pi, BeagleBone Black, and Edison to interact with GPIO.  It was originally designed to work with a computer and Arduino running Firmata (Now "Standard Firmata Plus").

     

    JavaScript Robotics Platform Support (Johnny-Five)

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

    This would be good for your RC Car as Johnny-Five was designed to do just this. 

     

    I would be interested to see if one could run Firmata on the MCU.

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

    This would be good for your RC Car as Johnny-Five was designed to do just this. 

     

    I would be interested to see if one could run Firmata on the MCU.

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

    Cheers Jason, it has potential. It's definitely possible to communicate with the MCU using serial which seems to be Firmata's M.O.

    I suspect I'll stick with MRAA but I do have an idea for the MCU if I have time.

    • 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