element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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 PDU log #5 - jdubdate 15117.58 [Upcycle It Challenge]
  • 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: 27 Apr 2017 10:52 AM Date Created
  • Views 747 views
  • Likes 5 likes
  • Comments 7 comments
  • upcycle_it
  • i2c lcd
  • node-red
  • upcycled_pdu
  • pdu
  • node
Related
Recommended

PDU log #5 - jdubdate 15117.58 [Upcycle It Challenge]

jasonwier92
jasonwier92
27 Apr 2017

Goals for my 5th BLOG entry of the Upcycle It Challenge: Due April 27th.

  • LCD - DONE
  • Web interface to turn on/off relay and LED - Move to BLOG #6 (due date 4/30)
  • Inputs to select what is displayed on the LCD with regular updates (once a minute) - Move to #8
    • Via inputs in node-red
    • Via web page
  • Storage for output states in Node-Red - Moved to #7
  • Client connect get initial update - Moved to #7
  • Real status of outputs - Moved to #7
    • Feed back to WS
    • Update state database
  • Pull external data via Web page in Node-Red - DONE

 

I leave my goals here to show that I am short of where I want to be, but on the same token I think that sharing all of this would be too much to share in one BLOG that people would not fall asleep. Short and to the point is now the goal.

 

Here is a reminder of my plan:

image

 

This last week my work has been mostly on the LCD controller. Most modern PDU's have a LCD on them to show some information, but mine will show more than just some information, mine will show what ever information gets sent to it.

 

My Road This Week

 

My week start with hope for the LCD and using it in Node-Red without a module.  This hope came from gpolder #6 BLOG post in Upcycle It Challenge. He got he RGB LCD working in Node-Red and I was excited. My excitement went down the drain fast as I could not get the LCD to work at all.  Nothing! I even tried banging my head against the wall. Then I tried via two scripts that I had from testing before and nothing still worked, did I mention NOTHING?  "What is going on?", bounced around in my then sore head. Then in a moment of genius, I remembered the advice I give to everyone, "Did you reboot/reset/restart yet?".  Ah, so I halted and removed power.  Then plugged back in and it worked!!! Then I tested.  Got it working, could change the color, etc.  Then I wanted to be able to change the color externally, but it is hard coded in the node. So I made three nodes like this, each one outputs a different color, but the only color that worked was the last one.  Change the last one's color and that was the color for all three.

 

image

 

Then I tried moving the different colors to different flows, nothing. Looked at the code and the color is set outside of the message being received.  Thought about pulling the code and suggesting a change, but decided that might take too long and I know I can write the other part in node quickly, so I put that on the back burner for another day. Another reason I picked the other road, is because the node also would not let you control the two lines of the LCD.  Yes, you can pad the strings and put them on the second line, but that is just not how I wanted to operate, just to have this in Node-Red.

 

So here is what I came up with:

var mqtt = require('mqtt');
var client = mqtt.connect('mqtt://192.168.2.20');
var five = require("johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
          io: new Edison()
});


board.on("ready", function() {
        var lcd = new five.LCD({controller: "JHD1313M1" });


        client.on('connect', function() {
          client.subscribe('eddy2/lcd');
          client.publish('presence', 'Eddy LCD Gateway Online');
        });


        client.on('message', function(topic,message) {
          var sMsg = message.toString();
          var jsonMsg;
          try {
            jsonMsg = JSON.parse(sMsg);
            lcd.clear().bgColor(jsonMsg.R, jsonMsg.G,jsonMsg.B)
                .cursor(0,0).print(jsonMsg.msg1.substring(0,16))
                .cursor(1,0).print(jsonMsg.msg2.substring(0,16));
          }
          catch (err) {
            console.log('Error: ', err);
            console.log('Topic: ',topic);
            console.log('Message: ', sMsg);
          }
        });
});

 

The code can also be found at my GitHub here if you would like to use or change this code.  Simple and easy in my opinion.

 

Next task was to output data to gateway via MQTT and test.  So I wrote this flow in Node-Red.

image

 

I have started to change it to store data in MongoDB, but that is not tested yet.  Here is a sample of a message.

{ msg1: "Temp. Outside", msg2: "18.2",R: 100, G: 50, B: 50 }

 

 

That message gets it's data from an ESP8266 running ESPEasy on my porch to report temperature and humidity. So I pull the web page like this:

 

image

Then pull out the temperature from the JSON

image

 

Then that gets outputted to the Debug and MQTT.

 

Next Up?

 

  • BLOG #6: I will send information to the Edison to turn on LED and Relay (started) for testing.  Also I will work on storing data in MongoDB (started) (4/30)
  • BLOG #7: I will store and pull the data from MongoDB and also be able to monitor changes in output from external sources (just in case it happens) (5/4)
  • BLOG #8: Start of web interface and build. LCD update control. (5/11)
  • BLOG #9: Web Interface and build final (5/18)
  • BLOG #10: Wrap and demos (5/25)
  • Sign in to reply

Top Comments

  • Workshopshed
    Workshopshed over 8 years ago +1
    The first 5 weeks seem to have whizzed by, just 5 more to go
  • jasonwier92
    jasonwier92 over 8 years ago in reply to gpolder +1
    The color of the background is declared in the creation of the instance of the node and not in the reception of data. I have done too much more at this point, time is ticking away and so are clients for…
  • mcb1
    mcb1 over 8 years ago +1
    I do like that have 'mapped' out your plan, and are willing to shift it to suit. It's rather frustrating when some things take you down a certain path, then it ends without the desired expectation, but…
  • jasonwier92
    jasonwier92 over 8 years ago in reply to gpolder

    I then removed node-red-node-upm as I thought it was causing my node-red to crash.  I think it was just that I needed a reboot.

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

    I do like that have 'mapped' out your plan, and are willing to shift it to suit.

     

    It's rather frustrating when some things take you down a certain path, then it ends without the desired expectation, but that's the reality of life.

     

    You'll be surprised how the next 5 weeks will play out.

    You think these have been fast, what for the last two.

     

    Mark

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

    this is true for the seeed library, but the node-red-node-upm should be able to do this according to the documentation.

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

    The color of the background is declared in the creation of the instance of the node and not in the reception of data. I have done too much more at this point, time is ticking away and so are clients for real work to be done also. image 

     

    I think my gateway is just as good, but it is an extra process that has to run.

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

    did you try http://flows.nodered.org/node/node-red-node-upm ?

    In my case it didn't work, but who nows, it will in your case.

    I opened an issue on gitlab for this: https://github.com/intel-iot-devkit/node-red-contrib-upm/issues/8

    Anyway this node supports setting of background color and cursor position so would help us a lot when we get it running.

    • 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