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
      •  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 PDU #7: More Mongo - The LCD [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: 8 May 2017 5:31 PM Date Created
  • Views 492 views
  • Likes 4 likes
  • Comments 1 comment
  • node-red
  • upcycle it
  • upcycled_pdu
  • mongodb
Related
Recommended

PDU #7: More Mongo - The LCD [Upcycle It Challenge]

jasonwier92
jasonwier92
8 May 2017

I have been busy with family matter, but when I get a chance and nothing pressing for work to do, I have been working on this monster below. Now there is not too much going on, but there has been much learning. Lets look at what is happening.

image

 

Set LCD Function

 

image

 

First lets look at the top flow:

  1. If we get a WS mesage to /ws/lcd, it should be a message to update what is shown on the LCD.
  2. The second node is the function node and this takes the message and creates an update query for the mongo.  Looks like this:
    image
  3. The third node updates the mongo collection
  4. There is a 2 second delay to make sure mongo is updated and then send out a MQTT message to update the LCD, which we will cover below

 

Regular Updates

 

Next up is simple: Every 20 seconds ask the LCD to update.

image

 

 

Show Me the Message:

 

 

image

 

Last set of Nodes in this flow take the MQTT message, query mongo for what should be show and then display that.  I covered much of this in my last BLOG post #6 for the Upcycle It Challenge. Here what the query looks like:

 

image

 

And my function

var state = msg.payload[0].state;
if (state == "outside temperature") {
    return [null,msg];    
}


if (state == "custom") {
    var newMsg = {payload: msg.payload[0].custom };
    return [newMsg,null];
}


if (state == "time") {
    var now = new Date();
    var mins = now.getMinutes();
    if (parseInt(mins) < 10) {
        mins = "0" + mins;
    }
    var nowDate = now.getMonth() + "/" + now.getDate() + "/" + now.getFullYear();
    var nowTime = now.getHours() + ":" + mins;
    var newMsg = { 
        payload: {
            msg1: nowDate,
            msg2: nowTime,
            R:50,
            G:100,
            B:50
            
        } };
    return [newMsg,null];
}

 

 

That is really it for now.  I have tested this with a Button on my web page that sends a Socket.io message back to the server that then sends a WS message into this flow.  I have not finished the custom message, but I have tested it with some editing of the mongo document.

Updates On The Design

I have gone back and forth about using the 74H595 shift registers or not, but I have decided, since I am going to use the Miniboard in my project, to not use the shift register.  I will have plenty of GPIO and only thing I will miss is the analog for the temperature sensor, so I will change to an I2C sensor that I already have.  I will use pull up resistors and BC337 transistors to pull the relay high to keep the relays off and turn on the GPIO to take signal low.  I will have a drawing and test results in the next BLOG post by the end of the week.

  • Sign in to reply
  • DAB
    DAB over 8 years ago

    Nice update.

     

    DAB

    • 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