Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
30 views89 pages

COMPILATIONNR

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1/ 89

A NODE RED SEMINAR

RED GENERATE
Click icon to add picture

INTRODUCTION TO RASPBERRY PI: DISCOVERING RASPBERRY PI


PREPARED BY: KIM ROBERT ARADO
WHAT IS RASPBERRY
PI?
• A credit card sized PC

• Plugs into a TV or
monitor

• Inexpensive

• Capability:

• Programming

• Electronic Projects

• Office

• Play HD Videos

• Etc.
ANATOMY OF RASPBERRY PI
MODEL B/B+
FUNCTION SPECIFICATION
1 DSI The Display Interface (DSI) is used to connect the display
directly to the Raspberry Pi board.
1. DSI 2 GPIO PINS
2. GPIO PINS 3 ARM It's the heart of the Raspberry Pi, the Broadcom
PROCESSOR BCM2835 900MHz quad-core ARM Cortex-A7 CPU with
3. ARM PROCESSOR 1GB RAM.
4. USB PORTS 4 USB PORTS
5. ETHERNET PORTS 5 ETHERNET
PORTS
6. 3.5mm A/V 6 A/V
CONNECTION CONNECTION
7. CSI 7 CSI
8. HDMI 8 HDMI

9. POWER SUPPLY 9 POWER SUPPLY


10 SD CARD SLOT
10. SD CARD SLOT
ALWAYS INVEST FOR THE BEST!
Click icon to add picture

USES OF RASPBERRY PI
USES OF RASPBERRY PI

OFFICE PROGRAMMING
USES OF RASPBERRY PI

GAME CONSOLES
WEB SERVER TOR ROUTER
USES OF RASPBERRY PI

SUPER COMPUTER
BIRD HOUSE HTPC
USES OF RASPBERRY PI

DIGITAL CLOCK PI BOT G.U.I.


IS A RASPBERRY PI A MICROCONTROLLER
OR A MICROPROCESSOR?
NEITHER
Click icon to add picture

INTRODUCTION TO RASPBERRY PI: DISCOVERING RASPBERRY PI


THE GPIO
RASPBERRY PI GPIO
PINS PURPOSE

1,17 3.3V

SOURCE 2,4 Click5V


icon to add picture

6,9,14,20,25,30,34,39 GROUND

2,3 FOR SDIC(2)


FOR SLIC(3)

8,10 FOR UART


GPIO
19,21 FOR MOSI(19)
FOR MISO(21)

23 FOR SCLK

24,26 FOR SPCE 0 & 1

7,11,13,15,16,18,22,31,32, FOR EXPERIMENT AND


33,35,36,37,38,39 OTHER PURPOSE

OTHERS 27,28 SPECIAL FOR EEPROM


THERE ARE MANY WAYS
TO LEARN RASPBERRY PI
JOIN ANY FORUMS
RASPBERRY-PI.ORG FACEBOOK
GMYG
YOUTUBE ACADEMY
THANK YOU!
Click icon to add picture

NODE RED: USING BUTTONS


PREPARED BY: Carlo V. Mariano & Jose Mabini A. Malinao
NODE RED
NODE PALLETE

FLOW CANVAS

OUTPUT PANE
NODE RED
Double click the tab to rename it.

FLOW CANVAS TO DRAG AND DROP


NODES
NODE RED
NODE RED
NODE RED

DRAG AND DROP THE NODES


FROM THE NODE PALLETE
NODE RED

CONNECT THEM
NODE RED
NODE RED
LED ON/OFF USING INJECT NODE BUTTON
NODE RED
LED ON/OFF USING INJECT NODE BUTTON

1. INPUT PALLETE
2. INJECT NODE

STRING RENAME
ON = 1 THE
OFF = 0 NODE
NODE RED
LED ON/OFF USING INJECT NODE BUTTON
1. RASPI PALETE
2. RPI-GPIO OUT

EDIT RPI-GPIO
NODE
NODE RED
LED ON/OFF USING INJECT NODE BUTTON
CONNECT THE NODES
THEN CLICK DEPLOY

CLICK BUTTONS TO
TURN LED ON/OFF.
NODE RED
ADDING A BUTTON TO YOUR FLOW

Add a Raspberry Pi
GPIO input/output node.
*INPUT
*OUTPUT
NODE RED
ADDING A BUTTON TO YOUR FLOW
CONFIGURE THE INPUT NODE THEN CLICK DONE.
NODE RED
ADDING A BUTTON TO YOUR FLOW
• CONNECT NODES THEN CLICK DEPLOY.
• TEST IF YOUR FLOW IS WORKING.
NODE RED
ADDING A BUTTON TO YOUR FLOW
• MODIFY THE FLOW.
NODE RED
ADDING A BUTTON TO YOUR FLOW
• MODIFY THE FLOW.
• EDIT THE NODE PROPERTIES.
• SWITCH NODE – DOUBLE CLICK SWITCH NODE.

CLICK TO ADD
CONDITION
NODE RED
• MODIFY THE FLOW.
• EDIT THE NODE PROPERTIES.
• CHANGE NODE – DOUBLE CLICK CHANGE NODE.

CLICK DONE.

CLICK DONE.
NODE RED
ADDING A BUTTON TO YOUR FLOW
• CONNECT THEM THEN CLICK DEPLOY.
• TEST YOUR MODIFIED FLOW.
NODE RED
CHALLENGE!!!!
• MODIFY THE FLOW SO THAT WHEN THE BUTTON IS PRESSED, LED WILL LIGHT UP
AFTER 10 SECONDS THEN WILL TURN OFF AFTER 5 SECONDS.
Click icon to add picture

NODE RED: USING THE DASHBOARD


PREPARED BY: Darren Michael Aguada
FIRST OF ALL, WHAT IS A
DASHBOARD?
Click icon to add picture

DASHBOARD
often provide at-a-glance views of KPIs (
key performance indicators) relevant to a particular
objective or business process.
-In the other, "dashboard" has another name for
"progress report" or "report."
-It can be use as a monitoring device.
(Temperature, Water level etc.)
PRE-REQUISITES
• You need a Raspberry Pi board
• You should already be familiar with Raspberry Pi
• You should have the Raspbian or Raspbian Lite
operating system installed in your Raspberry Pi.
• You should have Node-RED installed on your Pi
• Optional: Sense HAT
LET’S GET STARTED
NODE RED: USING THE DASHBOARD

Let’s start by looking at the node-


red-dashboard nodes and getting a
simple dashboard setup.

• To start, let’s wire up a simple flow that sends a random number between 0 and 99 to a simple chart.
• For that you’ll need an inject node to repeatedly fire every few seconds, a function node to generate
the random number and one of the  node-red-dashboard nodes – in this case the chart node.
NODE RED: USING THE DASHBOARD
NODE RED: USING THE DASHBOARD

• Before we look a how the chart node works,


let’s configure the inject node to send a
timestamp every 5 seconds by setting the
payload to timestamp and the repeat field
to an interval of 5 seconds.
• This will act as our repeating trigger.
NODE RED: USING THE DASHBOARD

Now we need to set up the function node to


generate a random number – we’ll use a simple JS
math function to do this:

Note: input this JS code into the function node


msg.payload = Math.round(Math.random()*100);
return msg;
NODE RED: USING THE DASHBOARD

• Now let’s take a look at the chart node.


• When you double click it, you’ll see it’s
configuration options.
NODE RED: USING THE DASHBOARD
CHART NODE OPTIONS:
• The Tab option allows you to specify which tab of the UI page you will
see the UI element on – in this case our chart. The default tab is Home
which we are using here.
• The Name field is the standard Node-RED node name, By default this
is chart but you can set it to anything you like.
• The Group field allows you to group UI elements.
• The X-axis field allows you to tell the chart how much data it should
store and display – the longer the ‘last‘ filed is set to, the more data is
stored and displayed by the chart. Let’s use a short 5 mins which will
start to throw away the data that is 5 minutes old.
• Lastly the Interpolate field defines how the chart will interpolate values
in between actual data values it receives. We’ll use the default linear.
NODE RED: USING THE DASHBOARD

Wire these nodes up, hit the deploy button.


Then head over to your default dashboard page to
see the results.

To go to the dashboard page set to node-red,


Just copy your given node red IP address, paste it on a new tab
and add “/ui/#/0” on the end of the link.
EXAMPLE:
Given node red IP address = 127.0.0.1:1880
Dashboard page = 127.0.0.1:1880/ui/#/0
LET’S SEE THE RESULT!
WHEN YOU VISIT THAT PAGE YOU’LL
SEE YOUR INITIAL CHART AS SHOWN
BELOW:

• We can see that it


generates random
number from 0 - 99
NOW IT’S YOUR TURN!
CUSTOMIZE YOUR
DASHBOARD.
 Add a Gauge, Text and Slider node to
your dashboard.
 (This activity will explore you to all
other dashboard nodes.)
 Set the range of random numbers to
0-199.
CUSTOMIZE YOUR
DASHBOARD.
Click icon to add picture

NODE RED: USING THE DASHBOARD & SENSE-HAT


PREPARED BY: Darren Michael Aguada & Joshua Cariaga
Click icon to add picture

NODE RED: LINUX INTEGRATION


PREPARED BY: Ohlin Percius Sartin & Ryzlyn Princess Rodriguez
LINUX COMMANDS


Linux commands are basically commands executed
using the Linux Shell (commonly known as terminal).

It works like Windows’ command prompt.
LINUX INTEGRATION


Having the dashboard palettes installed, we can
create programs that execute Linux commands
via Node-RED.
LINUX INTEGRATION


Having the dashboard palettes installed, we can
create programs that execute Linux commands
via Node-RED.
EXAMPLE 1: CHECKING THE CPU
TEMP
1. Create a new flow and put the following nodes on your
workspace: inject, exec, function, and gauge. (Note: The
nodes are under input; advanced; function; and dashboard,
respectively.)
2. Connect the nodes in the order they were mentioned earlier.
(Note: In order for the program to work, connect the exec
node’s stdout from its output side to the function node’s
input.)
EXAMPLE 1: CHECKING THE CPU
TEMP
3. Double-click the inject node to edit it. Click the drop-down for Repeat and
choose “interval” (Note: 1 second intervals). Click “Done”.
4. Double-click the exec node to edit it. Uncheck msg.payload and type this
command on the command section:
vcgencmd measure_temp

(This command checks the current temperature of your CPU in celsius. You can
try it on the terminal.)
EXAMPLE 1: CHECKING THE CPU
TEMP
5. Rename the node to “Temperature” and click “Done” when
you’re finished.
6. Double click the function node and rename it to “CPU
Temp”. Type the following command on the Function
section and click “Done”:
str = msg.payload
msg.payload = str.substring(5, 9);
return msg;
EXAMPLE 1: CHECKING THE CPU
TEMP
7. Double-click the gauge node and click the pencil icon to make a new dashboard group
(Note: Dashboard nodes that are on the same group will appear together.).
8. Set the units to C or celsius and the range to 0-80 (min 0, max 80). Rename it to “CPU
Temp” (label and name) and click “Done”.
9. Copy the link provided by Node-RED at the beginning and paste it on another tab. DO
NOT PRESS ENTER.
10. Replace everything from #flow with ui/#/0 and press Enter (eg.
192.168.1.11:1880/#flow/6fc8a82c.95e318 to 192.168.1.11:1880/ui/#/0). This will open your
dashboard.
EXAMPLE 2: RESTART OR SHUT DOWN
USING NODE-RED
1. On the same flow as example 1, put the following nodes: button and
exec. Connect the button node’s output to the exec node’s input.
2. Double-click the button node. Choose the group you used in
example 1.
3. Rename the button node to “Shut Down” or “Restart”, depending on
what you want to do at this point (label and name). Click “Done.”
EXAMPLE 2: RESTART OR SHUT DOWN
USING NODE-RED
4. Double-click the exec node, uncheck msg.payload, and type one of
these commands on the command section:
a) sudo shutdown -h now
b) sudo shutdown -r 0

The first command will shut down the device and the second one
will restart it.
EXAMPLE 2: RESTART OR SHUT DOWN
USING NODE-RED

5. Rename the exec node to “Shut Down” or “Restart”.


6. Open your dashboard.
EXERCISE!
EXERCISE

Create a flow that will utilize the text


input node to execute any Linux
command typed in. (Hint: use text input,
exec, and msg.payload nodes)
Click icon to add picture

NODE RED: INTERACTING WITH ARDUINO


PREPARED BY: Ghiovanni Lahara & Ramon Silvestre
ERIAL CONNECTION
FIRST, INSTALL THE ARDUINO IDE AND
ITS DRIVER
AFTER CONNECTING THE ARDUINO
TO RASPBERRY PI, TEST THE
ARDUINO IDE
• After testing the Arduino, embed the firmata program to the Arduino hardware.
note : Use the standard firmata








NOW START NODE-RED
FOR NEWLY INSTALLED NODE-RED, YOU SHOULD
INSTALL THE NODE FOR ARDUINO FIRST TO BE
ABLE TO USE IT.
FOR THE NODE-RED SETUP : (DIGITAL TYPE)
Connect a “switch” to the “Arduino out
node” and set the necessary description,
value,groupings, etc
Note : be careful when setting the serial port
and the pin assignment.
Deploy
it!
FOR THE NODE-RED SETUP : (ANALOG
TYPE)
Connect the “Arduino Input node” to a
“gauge” and set the necessary
description, value,groupings, etc
Note : be careful when setting the serial
port and the pin assignment.

You might also like