RPi Node-Red – Remote Control Car with video stream

This is a basic first draft: car kit in beta

The wiring diagram is here:

 

Wiring Diagram of Car

The default flow is below – do not import this flow if you already have a flow in your raspberry pi node-red

[{"id":"c3004570.c5fdb8","type":"tab","label":"Movement","disabled":false,"info":""},{"id":"b3ddf90e.a09218","type":"tab","label":"Video","disabled":false,"info":""},{"id":"45012f78.86c5d","type":"tab","label":"Settings","disabled":false,"info":""},{"id":"1bd47399.a5c5dc","type":"tab","label":"Extras","disabled":true,"info":""},{"id":"c892232.a6b64e","type":"ui_group","z":"","name":"Controls","tab":"f12bfb77.9e80e8","order":2,"disp":false,"width":"8","collapse":false},{"id":"408f9230.25cedc","type":"ui_group","z":"","name":"Camera","tab":"f12bfb77.9e80e8","order":1,"disp":false,"width":"11","collapse":false},{"id":"f12bfb77.9e80e8","type":"ui_tab","z":"","name":"Home","icon":"dashboard","order":1},{"id":"c22338ce.f469a8","type":"ui_base","theme":{"name":"theme-dark","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#0e777c","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#097479","value":"#0e777c","edited":true},"page-titlebar-backgroundColor":{"value":"#0e777c","edited":false},"page-backgroundColor":{"value":"#111111","edited":false},"page-sidebar-backgroundColor":{"value":"#000000","edited":false},"group-textColor":{"value":"#16b9c1","edited":false},"group-borderColor":{"value":"#555555","edited":false},"group-backgroundColor":{"value":"#333333","edited":false},"widget-textColor":{"value":"#eeeeee","edited":false},"widget-backgroundColor":{"value":"#0e777c","edited":false},"widget-borderColor":{"value":"#333333","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"5d86451c.b71dec","type":"ui_tab","z":"","name":"Settings","icon":"dashboard","order":2},{"id":"ae7bc233.3c456","type":"ui_group","z":"","name":"Settings / Shutdown","tab":"5d86451c.b71dec","order":1,"disp":true,"width":"6","collapse":false},{"id":"5665ef6d.468c7","type":"PCA9685","z":"","deviceNumber":"1","address":"64","frequency":"50"},{"id":"b4d77b75.1806f8","type":"oled-config","z":"","name":"","width":"128","height":"64","address":"60"},{"id":"15e30af6.f028d5","type":"oled-config","z":"","name":"","width":"128","height":"64","address":"3c"},{"id":"69b618c6.62b938","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/fwd.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":570,"y":60,"wires":[[],[],[]]},{"id":"5642fa90.d3aa54","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/bwd.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":580,"y":140,"wires":[[],[],[]]},{"id":"1cc3c9fb.0cd206","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/turn_r.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":580,"y":300,"wires":[[],[],[]]},{"id":"826cb173.39cc1","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/turn_l.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":580,"y":220,"wires":[[],[],[]]},{"id":"3d71630b.6baaec","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":1,"width":0,"height":0,"passthru":true,"label":"FWD","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":270,"y":60,"wires":[["69b618c6.62b938","2bd73342.45bcac"]]},{"id":"7403b905.981538","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":4,"width":0,"height":0,"passthru":true,"label":"BACK","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":270,"y":140,"wires":[["5642fa90.d3aa54","2bd73342.45bcac"]]},{"id":"670ea129.3442c","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":3,"width":"4","height":"1","passthru":true,"label":"RIGHT","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":280,"y":300,"wires":[["2bd73342.45bcac","826cb173.39cc1"]]},{"id":"df8ab935.62a7b8","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":2,"width":"4","height":"1","passthru":true,"label":"LEFT","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":270,"y":220,"wires":[["1cc3c9fb.0cd206","2bd73342.45bcac"]]},{"id":"d82c04e8.1aea98","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":60,"wires":[["3d71630b.6baaec"]]},{"id":"d586c6c3.3b7308","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":140,"wires":[["7403b905.981538"]]},{"id":"1194b926.7fb467","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":300,"wires":[["670ea129.3442c"]]},{"id":"a4917833.2d9588","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":220,"wires":[["df8ab935.62a7b8"]]},{"id":"c326f349.dc3c2","type":"exec","z":"45012f78.86c5d","command":"sudo shutdown now","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":500,"y":80,"wires":[[],[],[]]},{"id":"5508c561.de945c","type":"ui_button","z":"45012f78.86c5d","name":"","group":"ae7bc233.3c456","order":6,"width":0,"height":0,"passthru":true,"label":"Shutdown Pi","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":290,"y":80,"wires":[["c326f349.dc3c2"]]},{"id":"82bc1029.a21df","type":"inject","z":"45012f78.86c5d","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":80,"wires":[["5508c561.de945c"]]},{"id":"9b0bcd2e.6b34","type":"ui_button","z":"1bd47399.a5c5dc","name":"","group":"c892232.a6b64e","order":5,"width":0,"height":0,"passthru":true,"label":"Servo","color":"","bgcolor":"","icon":"","payload":"90","payloadType":"num","topic":"","x":270,"y":80,"wires":[["deb27663.5e02e8"]]},{"id":"f5eadb34.69d8c8","type":"inject","z":"1bd47399.a5c5dc","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":80,"wires":[["9b0bcd2e.6b34"]]},{"id":"9efa51e0.97e71","type":"ui_button","z":"1bd47399.a5c5dc","name":"","group":"c892232.a6b64e","order":6,"width":0,"height":0,"passthru":true,"label":"Servo","color":"","bgcolor":"","icon":"","payload":"180","payloadType":"num","topic":"","x":270,"y":120,"wires":[["deb27663.5e02e8"]]},{"id":"b207ac1.566af5","type":"inject","z":"1bd47399.a5c5dc","name":"","topic":"","payload":"180","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":120,"wires":[["9efa51e0.97e71"]]},{"id":"deb27663.5e02e8","type":"exec","z":"1bd47399.a5c5dc","command":"sudo python /home/pi/Downloads/Raspi_Car/servoArg.py","addpay":true,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":610,"y":100,"wires":[["959c728f.b1179"],["959c728f.b1179"],["959c728f.b1179"]]},{"id":"959c728f.b1179","type":"debug","z":"1bd47399.a5c5dc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":730,"y":160,"wires":[]},{"id":"8571640e.026f48","type":"ui_slider","z":"1bd47399.a5c5dc","name":"","label":"slider","group":"c892232.a6b64e","order":7,"width":0,"height":0,"passthru":true,"outs":"all","topic":"","min":0,"max":"180","step":1,"x":270,"y":160,"wires":[["deb27663.5e02e8"]]},{"id":"2bd73342.45bcac","type":"timeout","z":"c3004570.c5fdb8","name":"My Timeout","outtopic":"","outsafe":"","outwarning":"","outunsafe":"Unsafe","warning":"5","timer":"20","repeat":false,"again":true,"x":250,"y":460,"wires":[["b454a19d.728fc","85eaa486.d76538"]]},{"id":"b454a19d.728fc","type":"debug","z":"c3004570.c5fdb8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":430,"y":520,"wires":[]},{"id":"85eaa486.d76538","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/twitch.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":560,"y":460,"wires":[[],[],[]]},{"id":"7984811f.1205d","type":"inject","z":"45012f78.86c5d","name":"","topic":"","payload":"Hello!","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":320,"wires":[["e4dcbd0.d86264"]]},{"id":"e4dcbd0.d86264","type":"String","z":"45012f78.86c5d","name":"OLED","display":"15e30af6.f028d5","x":670,"y":280,"wires":[]},{"id":"8554d33e.6eead","type":"function","z":"45012f78.86c5d","name":"Format Message","func":"if (msg.payload.length >4) \n{\n    msg.payload={\n    x:1,  \n    y:50,\n    text:\"IP \"+msg.payload+\":1880\"\n    }\n}\nelse\n{\n    msg.payload={\n    x:1,  \n    y:50,\n    text:\"No IP Address           \"\n    }\n}\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":280,"wires":[["e4dcbd0.d86264"]]},{"id":"f731709.c52189","type":"change","z":"45012f78.86c5d","name":"IP","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0].address","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":280,"wires":[["8554d33e.6eead"]]},{"id":"c453f0d.b93711","type":"inject","z":"45012f78.86c5d","name":"","topic":"","payload":"10","payloadType":"num","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":90,"y":280,"wires":[["801f5d06.d2c9d"]]},{"id":"801f5d06.d2c9d","type":"hostip","z":"45012f78.86c5d","name":"Host IP","x":220,"y":280,"wires":[["f731709.c52189"]]},{"id":"f66984f4.70d858","type":"comment","z":"45012f78.86c5d","name":"Display IP address on the mini OLED display","info":"","x":300,"y":240,"wires":[]},{"id":"414f604.c4230a","type":"exec","z":"45012f78.86c5d","command":"sudo reboot","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":470,"y":140,"wires":[[],[],[]]},{"id":"8c2297bc.a24728","type":"ui_button","z":"45012f78.86c5d","name":"","group":"ae7bc233.3c456","order":6,"width":0,"height":0,"passthru":true,"label":"Reboot Pi","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":280,"y":140,"wires":[["414f604.c4230a"]]},{"id":"bcdafe6a.1cdcd","type":"inject","z":"45012f78.86c5d","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":140,"wires":[["8c2297bc.a24728"]]},{"id":"1949951f.c994bb","type":"change","z":"b3ddf90e.a09218","name":"IP","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0].address","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":120,"wires":[["a910f2f1.2dd32"]]},{"id":"e4ccfcbd.2f65e","type":"inject","z":"b3ddf90e.a09218","name":"","topic":"","payload":"10","payloadType":"num","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":110,"y":120,"wires":[["be99e886.7b65c8"]]},{"id":"be99e886.7b65c8","type":"hostip","z":"b3ddf90e.a09218","name":"Host IP","x":240,"y":120,"wires":[["1949951f.c994bb"]]},{"id":"a910f2f1.2dd32","type":"function","z":"b3ddf90e.a09218","name":"","func":"\n\n\nmsg.payload = \"http://\"+msg.payload+\"/html/min.php\"\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":120,"wires":[["f2f68f7d.06dcc"]]},{"id":"f2f68f7d.06dcc","type":"ui_template","z":"b3ddf90e.a09218","group":"408f9230.25cedc","name":"","order":0,"width":0,"height":0,"format":"<iframe scrolling=no marginwidth=0 marginheight=0 frameborder=0 id=\"myFrame\" width=\"540\" height=\"440\" src = \"\"></iframe>\n<script>\n(function(scope) {\n    // watch msg object from Node-RED\n    scope.$watch('msg', function(msg) {\n        // new message received\n        var x = document.getElementById('myFrame');\n        x.setAttribute('src', msg.payload); \n        });\n})(scope);\n</script>","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":620,"y":120,"wires":[[]]},{"id":"5442134b.08d54c","type":"exec","z":"1bd47399.a5c5dc","command":"sudo python /home/pi/Downloads/Raspi_Car/stop.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":560,"y":260,"wires":[[],[],[]]},{"id":"37661f0f.03b32","type":"ui_button","z":"1bd47399.a5c5dc","name":"","group":"c892232.a6b64e","order":8,"width":0,"height":0,"passthru":true,"label":"STOP","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":270,"y":260,"wires":[["5442134b.08d54c"]]},{"id":"83bf0fc1.b2a52","type":"inject","z":"1bd47399.a5c5dc","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":260,"wires":[["37661f0f.03b32"]]}]

 

 

 

 

image_pdfGenerate PDFimage_printPrint

RPi Node Red: Remotely accessing node-red and VNC

Goal:

Connect to your node-red flows and/or to your Raspbian desktop remotely using a web browser or VNC client.

Resources:

Raspberry pi and another computer on the same network, the other computer could be running Windows, OSX, or a different Raspberry Pi Computer.

Intro:

Node-red hosts itself as a webpage that can be accessed not only on the RPi it’s running on, but also by any other computer connected to the same network. The RPi’s desktop itself can also be accessed over the network using a VNC client that comes preinstalled on the Raspbian image in your T3 kit.

 

Accessing node-red:

You’ll only need two things to access your node-red flows over the network. A computer connected to the same network (WiFi or LAN) that can run google chrome, and the RPI’s IP address.

 

To find the IP address of the pi that’s running node-red, hover the mouse pointer over the applet until the IP address appears as pictured.

Here it says our IP address is 10.71.0.174
Node-red hosts itself on localhost on port 1880 by default. On the computer running node-red it can be accessed via localhost:1880 For anyone else they need to connect explicitly to the device.

Type this into a web browser on another computer on the same network: 10.71.0.174:1800 (your IP address will be different – but keep the :1880)
In google chrome it looks like this.

Any changes we make to our flow here will be reflected on the RPi running node-red. Therefore we have remotely accessed our node-red flow over the network!

 

VNC:

Connecting over VNC allows you to essentially remote-control your RPi over a network, and with the right setup even over the internet.

First go to the main-menu and go into the Configuration menu.

 

In the interfaces tab enable VNC

 

After you push okay the window will disappear, and soon the VNC icon will appear in the top bar. Click on it to open the VNC window.

 

On the other computer you’ll need to install VNC Viewer.

https://www.realvnc.com/en/connect/download/viewer/

 

The same IP address we used to connect to node-red is used to connect to VNC, the VNC Server window also shows your IP address under “connectivity”.

 

 

 

 

image_pdfGenerate PDFimage_printPrint

RPi: Building a ShakeMeter with Raspberry Shake and Node-Red

Goal:

Build a real-time “Shakemeter” in the Node-Red Dashboard! The Shakemeter will take the real-time seismic data and convert it into a live measurement of the absolute amplitude and velocity at which the ground is shaking! Set it up in your classroom and see how powerfully you can jump, put in next to the court to see how hard a home crowd cheers for your basketball team, or set it up at a school assembly to see which class has the most spirit!

 

Resources:

Introduction:

After following the first tutorial on connecting  Shake to Node-Red, now we can start to use Node-Red to process and visualize the seismic data that is being streamed through the UDP port.

Getting Started:

Before starting this tutorial, make sure you have already completed the “Streaming Raspberry Shake Data to Node-Red” tutorial. Your flow should look like this:

Make sure that there is UDP data being received by checking the debug tab. As you can see, the data coming through the Rshake Parser is still in object form, consisting of multiple types of information. In order to separate the numerical data and to quantify the shaking, another function node is needed to process the data. Below is an example of a node we made to address this.

Using the data:

[{"id":"d5d2efbb.2600e","type":"function","z":"b308f371.c9fa","name":"Absolute Amplitude","func":"acc = 0;\nnum = 0;\nfor(const p of msg.payload.packets)\n{\n    acc += Math.abs(p);\n    num++;\n}\n\nacc /= num;\n\nmsg.payload = acc;\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":360,"wires":[["c8911fad.47f72"]]},{"id":"c8911fad.47f72","type":"smooth","z":"b308f371.c9fa","name":"","property":"payload","action":"mean","count":"25","round":"0","mult":"single","x":780,"y":360,"wires":[["6270e4ac.2138fc","64858a7e.ecae14"]]}]

 

You can copy and paste this code-block to import an ‘Absolute Amplitude’ function-node, it takes the raw data from the rshake parser node and turns it into a more easily usable integer which describes the amount of absolute vibration over the past couple of seconds. After it there is a “smooth” node to take the mean of the first numbers in order for the data to be processed more easily. *Note: photos show “average magnitude” in place of “absolute amplitude”

To import code-blocks like this, use the top right menu and select ‘import -> clipboard’ then a box will pop up allowing you to paste in the flow.

 

Your flow should now look similar to the photo above. The next step is to add the Dashboard “Gauge” Node, and attach it after the smooth node. Then, we have to configure the Gauge node. Make sure to Make the range from zero to at least 50000 (remember not to put a comma in 50000). If you have not yet, you will also have to create a Dashboard group, by pressing the edit button next to the “group” field, and then pressing it again next to the “tab” field.  Then click Update, then Done!

 

Now, we are ready to deploy!

Once deployed, open your local Node-Red Dashboard.  You can access this page by entering http://”yourIPaddress:1880/ui. For example: http://10.18.102.253:1880/ui

Now, bang the table! Jump up and down! How can you apply the ShakeMeter to something relevant in your home, school, or community?

So go get Shakin!

 

image_pdfGenerate PDFimage_printPrint

RPi: Building a Raspberry Shake seismogram on the Node-Red Dashboard

Goal:

Set up a real time Seismogram on the Node-Red Dashboard.

 

Resources:

Introduction:

After following the first tutorial on connecting  Shake to Node Red, now we can start to use Node-Red to process and visualize the seismic data that is being streamed through the UDP port.

Getting Started:

Before starting this tutorial, make sure you have already completed the “Streaming Raspberry Shake Data to Node-Red” tutorial. Your flow should look like this:

 

Make sure that there is UDP data being received by checking the debug tab. As you can see, the data coming through the Rshake Parser is still in object form, consisting of multiple types of information. For building the siesmogram graph, we just want the numerical data.

First, we have to add a switch node that discriminates the the channel of the data. If we are using a Shake 1D, it will be the channel EHZ. So, we must add a switch node after the parser, and format it to be listening for the property “msg.payload.channel” and underneath we can add the rule as: == “string” EHZ. This separates the data that we want.

The data is still not in a format useable for graphing, so we have to create a custom function node to separate the numerical data. Raspberry shake has created a code just for this purpose.

Go to the menu and choose import>clipboard, and paste this code and import the node.

[{"id":"299110c.a2af7f","type":"function","z":"d328b37.176a45","name":"format plot values","func":"\nvar EVERY_N_PACKET = 20; // max = 24\nvar POINTS_PER_SECOND = 100 / EVERY_N_PACKET;\nvar KEEP_SECONDS = 60;\nvar KEY=\"f2_all_points\";\n\nvar MAX_POINTS = POINTS_PER_SECOND * KEEP_SECONDS;\n\nvar input = msg.payload;\n\nvar data = [{series:[\"P\"],\n    data:[],\n    labels:[\"Points\"]\n}];\n\nvar allPoints = flow.get(KEY);\nif(allPoints == undefined)\n    allPoints = [];\n\n\nfor(var i=0, step=EVERY_N_PACKET; i + step < input.packets.length; i += step) {\n    var o = {x: input.ts + i*10,\n             y: input.packets[i]};\n    allPoints.push(o);\n}\n\nif(allPoints.length > MAX_POINTS)\n    allPoints = allPoints.slice(\n        allPoints.length - MAX_POINTS, \n        allPoints.length\n    );\n\nflow.set(KEY, allPoints);\n\ndata[0].data.push(allPoints);\n\n\nmsg.payload = data;\n\nreturn msg;","outputs":1,"noerr":0,"x":877,"y":171,"wires":[["73bf48a9.3fc398"]]}]

Connect the ‘format plot values” node to the switch node. Now, to finish we connect a Dashboard chart. Your flow should look similar to this:

Then, configure the chart in the way that you would like, and Deploy!

Now, open your local Node-Red Dashboard! You can access this page by entering your Node-Red address /ui. For example: http://10.18.102.253:1880/ui

Now, bang the table! Jump up and down! See what happens to the graph!

 

To continue working with the Shake Data in Node-Red, go to the next Tutorial!

Making a Shakemeter: https://t3alliance.org/rpi-building-a-shakemeter-with-raspberry-shake-and-node-red/

 

 

image_pdfGenerate PDFimage_printPrint

RPi Node-Red: Advanced Multi-Button Board + RGB LED

Overview

This tutorial will utilize a multi-button board input device to control an RGB LED module. Students will learn about and utilize binary counting to program the multi-button board. This tutorial adds to prior knowledge on the Button + LED tutorial.

Requirements

  • Raspberry Pi 3 Model B
  • Multi-Button Board
  • RGB LED Module
  • F-F Jumper Cables

Getting Started

Setting up the Hardware

Multi-Button Board to Raspberry Pi

  • K1 to #6
  • K2 to #5
  • K3 to #22
  • K4 to #27
  • K5 to #17
  • K6 to #4
  • K7 to #21
  • K8 to #20
  • G to GND

RGB LED to Raspberry Pi

  • R to #13
  • G to #19
  • B to #26
  • GND to GND

Setting up Node-Red

  1. Insert RPi-GPIO-In Nodes
    1. These nodes act as inputs from the multi-button board.
    2. Place 8 nodes, representing the 8 button inputs.
    3. Assign each button (K1, K2…, K8) to their respective GPIO pin on the Raspberry Pi.
    4. Set the Resistor setting to pullup.
    5.  
  2. Insert Change Nodes
    1. These nodes translate the input nodes from the multi-button board into number values from 0 to 7 (numbering starts at 0 due to how computers start counting at 0 instead of 1).
    2. Place 8 nodes, labeling them from 0 to 7.
    3. For each node, change the data type to number and set the values to 0-7 starting with the first node.
  3. Connect an RPi-GPIO-In node to a Change node
    1. Connecting the two node types translates each binary 0 or 1 button input into a different decimal value.
  4. Insert Function Nodes
    1. These nodes act as “decoders” that translates the numbered value into a bit-string.
    2. The RGB values represent three individual switches. By having a bit-string representation, each bit can determine the color’s bit state.
    3. Function for [4] node
      1. // Value retrieved from initial input
        var value = msg.payload;
        
        // subtract_bit determined by bit location
        var subtract_bit = 4;
        
        // If value is greater than the subtract_bit, indicates that the bit state for [4] is 1
        if (value >= subtract_bit) {
            var new_value = {payload: value - subtract_bit};
            var bit_state = {payload: 1};
            return [new_value, bit_state];
        }
        
        // Otherwise, bit state for [4] is 0
        else {
            value = {payload: value};
            var bit_state = {payload: 0};
            return [value, bit_state];
        }
    4. Function for [2] node
      1. // Value retrieved from initial input
        var value = msg.payload;
        
        // subtract_bit determined by bit location
        var subtract_bit = 2;
        
        // If value is greater than the subtract_bit, indicates that the bit state for [2] is 1
        if (value >= subtract_bit) {
            var new_value = {payload: value - subtract_bit};
            var bit_state = {payload: 1};
            return [new_value, bit_state];
        }
        
        // Otherwise, bit state for [2] is 0
        else {
            value = {payload: value};
            var bit_state = {payload: 0};
            return [value, bit_state];
        }
    5. Function for [1] node
      1. var bit_state = {payload: msg.payload};
        return bit_state;
  5. Insert RPi-GPIO-Out Nodes
    1. These nodes act as output nodes for the RGB LED module.
    2. Place three nodes, each representing one of the RGB LEDs and assign to their respective GPIO pin.

Conclusion

If you have successfully followed this tutorial module, you should be able to change the RGB LED module’s color from the multi-button board.

Node-Red Solution

[{"id":"3fc0ad9f.487e12","type":"change","z":"b8b26cb8.1baef","name":"2","rules":[{"t":"set","p":"payload","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":280,"wires":[["5f4cfd28.f4a124"]]},{"id":"cbd11229.36a9","type":"rpi-gpio in","z":"b8b26cb8.1baef","name":"K2","pin":"29","intype":"up","debounce":"25","read":false,"x":290,"y":220,"wires":[["c4e5685f.e3fa88"]]},{"id":"96dd66c6.026928","type":"rpi-gpio in","z":"b8b26cb8.1baef","name":"K4","pin":"13","intype":"up","debounce":"25","read":false,"x":290,"y":340,"wires":[["75069901.3cc9b8"]]},{"id":"d710bb14.62b1f8","type":"rpi-gpio in","z":"b8b26cb8.1baef","name":"K3","pin":"15","intype":"up","debounce":"25","read":false,"x":290,"y":280,"wires":[["3fc0ad9f.487e12"]]},{"id":"2b18a8d6.7f92f8","type":"rpi-gpio in","z":"b8b26cb8.1baef","name":"K6","pin":"7","intype":"up","debounce":"25","read":false,"x":290,"y":460,"wires":[["ac5a8574.e332f8"]]},{"id":"3c93bf81.fb10d","type":"rpi-gpio in","z":"b8b26cb8.1baef","name":"K8","pin":"38","intype":"up","debounce":"25","read":false,"x":290,"y":580,"wires":[["d0ff8cfe.8f2c5"]]},{"id":"aac40b7a.f36bb8","type":"rpi-gpio in","z":"b8b26cb8.1baef","name":"K7","pin":"40","intype":"up","debounce":"25","read":false,"x":290,"y":520,"wires":[["3954b9a.a55c346"]]},{"id":"551dc587.3f572c","type":"rpi-gpio in","z":"b8b26cb8.1baef","name":"K5","pin":"11","intype":"up","debounce":"25","read":false,"x":290,"y":400,"wires":[["631bd1a6.8dd45"]]},{"id":"31bb63ee.bf082c","type":"change","z":"b8b26cb8.1baef","name":"0","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":160,"wires":[["5f4cfd28.f4a124"]]},{"id":"c4e5685f.e3fa88","type":"change","z":"b8b26cb8.1baef","name":"1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":220,"wires":[["5f4cfd28.f4a124"]]},{"id":"75069901.3cc9b8","type":"change","z":"b8b26cb8.1baef","name":"3","rules":[{"t":"set","p":"payload","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":340,"wires":[["5f4cfd28.f4a124"]]},{"id":"631bd1a6.8dd45","type":"change","z":"b8b26cb8.1baef","name":"4","rules":[{"t":"set","p":"payload","pt":"msg","to":"4","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":400,"wires":[["5f4cfd28.f4a124"]]},{"id":"ac5a8574.e332f8","type":"change","z":"b8b26cb8.1baef","name":"5","rules":[{"t":"set","p":"payload","pt":"msg","to":"5","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":460,"wires":[["5f4cfd28.f4a124"]]},{"id":"3954b9a.a55c346","type":"change","z":"b8b26cb8.1baef","name":"6","rules":[{"t":"set","p":"payload","pt":"msg","to":"6","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":520,"wires":[["5f4cfd28.f4a124"]]},{"id":"d0ff8cfe.8f2c5","type":"change","z":"b8b26cb8.1baef","name":"7","rules":[{"t":"set","p":"payload","pt":"msg","to":"7","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":410,"y":580,"wires":[["5f4cfd28.f4a124"]]},{"id":"23c6a01e.0e013","type":"rpi-gpio in","z":"b8b26cb8.1baef","name":"K1","pin":"31","intype":"up","debounce":"25","read":false,"x":290,"y":160,"wires":[["31bb63ee.bf082c"]]},{"id":"5f4cfd28.f4a124","type":"function","z":"b8b26cb8.1baef","name":"[4]","func":"// Value retrieved from initial input\nvar value = msg.payload;\n\n// subtract_bit determined by bit location\nvar subtract_bit = 4;\n\n// If value is greater than the subtract_bit, indicates that the bit state for [4] is 1\nif (value >= subtract_bit) {\n    var new_value = {payload: value - subtract_bit};\n    var bit_state = {payload: 1};\n    return [new_value, bit_state];\n}\n\n// Otherwise, bit state for [4] is 0\nelse {\n    value = {payload: value};\n    var bit_state = {payload: 0};\n    return [value, bit_state];\n}","outputs":2,"noerr":0,"x":590,"y":340,"wires":[["fb4d798f.1edc38"],["a17a86af.bfb648"]]},{"id":"fb4d798f.1edc38","type":"function","z":"b8b26cb8.1baef","name":"[2]","func":"// Value retrieved from initial input\nvar value = msg.payload;\n\n// subtract_bit determined by bit location\nvar subtract_bit = 2;\n\n// If value is greater than the subtract_bit, indicates that the bit state for [2] is 1\nif (value >= subtract_bit) {\n    var new_value = {payload: value - subtract_bit};\n    var bit_state = {payload: 1};\n    return [new_value, bit_state];\n}\n\n// Otherwise, bit state for [2] is 0\nelse {\n    value = {payload: value};\n    var bit_state = {payload: 0};\n    return [value, bit_state];\n}","outputs":2,"noerr":0,"x":730,"y":360,"wires":[["bb73fc3f.28e14"],["74e9a7d8.f4a0e8"]]},{"id":"bb73fc3f.28e14","type":"function","z":"b8b26cb8.1baef","name":"[1]","func":"var bit_state = {payload: msg.payload};\nreturn bit_state;","outputs":1,"noerr":0,"x":870,"y":380,"wires":[["9a25ca9f.d2dca8"]]},{"id":"a17a86af.bfb648","type":"rpi-gpio out","z":"b8b26cb8.1baef","name":"Red","pin":"33","set":"","level":"0","freq":"","out":"out","x":750,"y":280,"wires":[]},{"id":"74e9a7d8.f4a0e8","type":"rpi-gpio out","z":"b8b26cb8.1baef","name":"Green","pin":"35","set":"","level":"0","freq":"","out":"out","x":890,"y":300,"wires":[]},{"id":"9a25ca9f.d2dca8","type":"rpi-gpio out","z":"b8b26cb8.1baef","name":"Blue","pin":"37","set":"","level":"0","freq":"","out":"out","x":1030,"y":320,"wires":[]}]
image_pdfGenerate PDFimage_printPrint

RPi Node Red: Streaming rpi camera to dashboard

Goal:

Broadcast a live video feed from the RPi camera to a locally and network accessible webpage.

Resources:

RPi and a RPi camera.

Hardware:

Only setup here is connecting the RPi camera to the pi using a ribbon cable.

Installing Streaming Software:

We’ll be following this tutorial here: https://elinux.org/RPi-Cam-Web-Interface

The page there is extremely verbose and scary, but the actual setup is very simple and should only take a few minutes.

First open a terminal, and enter

sudo apt-get update

This will update your repository so the right links are there.

Then pase / type this into the same terminal and press enter.

git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git

This will start downloading the git repo for the web interface; this should only take a few seconds.

cd RPi_Cam_Web_Interface

Enters the directory that we just downloaded.

./install.sh

runs the script to start installing everything, it will prompt you for some settings, press enter to use the defaults.

 

In the article we’re following it mentions

The scripts are

    install.sh main installation as used in step 4 above
    update.sh check for updates and then run main installation
    start.sh starts the software. If already running it restarts.
    stop.sh stops the software
    remove.sh removes the software
    debug.sh is same as start but allows raspimjpeg output to console for debugging

    To run these scripts make sure you are in the RPi_Cam_Web_Interface folder then precede the script with a ./
    E.g. To update an existing installation ./update.sh
    E.g. To start the camera software ./start.sh
    E.g. To stop the camera software ./stop.sh

 

We just ran the ‘install.sh’, which installs everything. Now if we want to start the stream we’ll use ‘start.sh’

 

./start.sh

If we want to start the stream, say after restarting the pi we’ll have to navigate back to this directory and run the start script.

That process just looks like this:

cd RPi_Cam_Web_Interface
./start.sh

 

Viewing the stream:

Now for the fun part, actually viewing the stream.

First we’ll need our ip address; this can be found by hovering the mouse over the WiFi applet like this:

Next, on the same pi or any computer on the same local network we can open the stream via this address.

The url will look like this, except with the ip address switched out for your own.

10.71.0.174/html

Here’s what the default page looks like when we’re streaming.


You can edit all kinds of settings here, that aren’t really necessary for a basic setup.

If your image happens to be upside down you can change the rotation in the “Camera Settings” tab here:

There’s also a more minimal page that only shows the video here:
http://10.71.0.184/html/min.php

Remember that the IP address will be different for you.

 

Embedding the stream into node-red dashboard:

The T3 RPi kit comes with the node-red dashboard nodes installed already, and this is what we’ll use to view the stream in node-red. The advantage to doing that is that you can have buttons, graphs, or other data alongside the video feed.

Here is an example where we have the feed coming from a remote controlled car, with buttons alongside to drive the car around.

In this tutorial we’ll focus on getting the video itself to display.

Here is what the configuration for the template node looks like:

everything is set to default, except we’ve added some html code to the template box.
Here’s the code:

<iframe scrolling=no marginwidth=0 marginheight=0 frameborder=0 height=439 width=553 src="http://10.71.0.200/html/min.php"></iframe>

For it to work on your template node, you’ll have to replace the url here with the one for your pi. So the IP address will be different.

The other change is adding a new ui_group.

If you click the pen here, it’ll open the panel to define the new default group.
You can leave this all at default, but I think it looks better with the video if you raise the width slightly.
Here’s mine with the width raised to 9

Now if you deploy and navigate to http://your_ip:1880/ui you should be able to see your video stream embedded in the node-red dashboard.

You can fine tune the iframe settings like width and height in the template node, and the layout size in the dashboard options.

image_pdfGenerate PDFimage_printPrint

RPi Node-Red: Inject + Debug = Hello World

What Will I Learn:

How to use the inject node to send the phrase “Hello World!” to the debug terminal 🙂 This is a classic getting started example and is usually done when first learning to program in a new language.

Parts List:

None except for your raspberry pi already setup.

Getting Started:

Starting Node-Red:

  • Start Node-Red by clicking on the red Node-Red icon on the start menu under the “Programming” section.

Starting web browser Node-Red interface:

  • Start the Chromium web browser by clicking on the blue world icon on the top bar.
  • Click on the “Node-Red” link inside Chromium on the bookmarks bar.

Getting Started:

Programming Hello World! example:

Drag an inject node into your flow from the left node palette.

Double click on the inject node (named timestamp once dragged in) and change data type to “string”

Type “Hello World!” into the Payload section just after the “string” datatype selector.

Drag in a Debug node from the output node palette.

Drag a connection line between the output of the inject node and the input of the debug node – click on the dots on the sides of the nodes to do this.

Deploy your new flow

Click the button on the left of the Inject node.

Click on the “debug” tab on the right side – the icon looks like a bug 😉 You should see your “Hello World!” string displayed

Review:

Inject and debug nodes will be used extensively throughout our other lessons and are the building blocks of understanding how JSON messages are sent between nodes.

image_pdfGenerate PDFimage_printPrint

Node-Red: DRAFT Motor Driver Flow Car Prototype DRAFT

 

[{"id":"c3004570.c5fdb8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"69b618c6.62b938","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/fwd.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":630,"y":200,"wires":[[],[],[]]},{"id":"5642fa90.d3aa54","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/bwd.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":640,"y":280,"wires":[[],[],[]]},{"id":"f8d17f70.3fbf4","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/stop.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":640,"y":360,"wires":[[],[],[]]},{"id":"1cc3c9fb.0cd206","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/turn_r.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":640,"y":440,"wires":[[],[],[]]},{"id":"826cb173.39cc1","type":"exec","z":"c3004570.c5fdb8","command":"sudo python /home/pi/Downloads/Raspi_Car/turn_l.py","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":640,"y":520,"wires":[[],[],[]]},{"id":"3d71630b.6baaec","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":0,"width":0,"height":0,"passthru":true,"label":"FWD","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":350,"y":200,"wires":[["69b618c6.62b938"]]},{"id":"7403b905.981538","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":0,"width":0,"height":0,"passthru":true,"label":"BACK","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":350,"y":280,"wires":[["5642fa90.d3aa54"]]},{"id":"26b12fe1.98027","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":0,"width":0,"height":0,"passthru":true,"label":"STOP","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":350,"y":360,"wires":[["f8d17f70.3fbf4"]]},{"id":"670ea129.3442c","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":0,"width":0,"height":0,"passthru":true,"label":"RIGHT","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":360,"y":440,"wires":[["1cc3c9fb.0cd206"]]},{"id":"df8ab935.62a7b8","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":0,"width":0,"height":0,"passthru":true,"label":"LEFT","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":350,"y":520,"wires":[["826cb173.39cc1"]]},{"id":"148d913d.0df89f","type":"ui_template","z":"c3004570.c5fdb8","group":"408f9230.25cedc","name":"","order":0,"width":0,"height":0,"format":"<img name=\"main\" id=\"main\" border=\"0\" width=\"640\" height=\"480\" src=\"http://192.168.43.209:8081/videostream.cgi\">","storeOutMessages":true,"fwdInMessages":true,"templateScope":"local","x":200,"y":140,"wires":[[]]},{"id":"d82c04e8.1aea98","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":200,"wires":[["3d71630b.6baaec"]]},{"id":"d586c6c3.3b7308","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":280,"wires":[["7403b905.981538"]]},{"id":"53924a77.ccdcc4","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":360,"wires":[["26b12fe1.98027"]]},{"id":"1194b926.7fb467","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":440,"wires":[["670ea129.3442c"]]},{"id":"a4917833.2d9588","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":520,"wires":[["df8ab935.62a7b8"]]},{"id":"12245169.5658df","type":"exec","z":"c3004570.c5fdb8","command":"sudo shutdown","addpay":false,"append":"","useSpawn":"true","timer":"4","oldrc":false,"name":"","x":520,"y":680,"wires":[[],[],[]]},{"id":"89384bbd.030b48","type":"ui_button","z":"c3004570.c5fdb8","name":"","group":"c892232.a6b64e","order":0,"width":0,"height":0,"passthru":true,"label":"Shutdown Pi","color":"","bgcolor":"","icon":"","payload":"1","payloadType":"str","topic":"","x":330,"y":680,"wires":[["12245169.5658df"]]},{"id":"255b9f7d.6a346","type":"inject","z":"c3004570.c5fdb8","name":"","topic":"","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":680,"wires":[["89384bbd.030b48"]]},{"id":"c892232.a6b64e","type":"ui_group","z":"","name":"Default","tab":"f12bfb77.9e80e8","disp":true,"width":"6","collapse":false},{"id":"408f9230.25cedc","type":"ui_group","z":"","name":"Group 2","tab":"f12bfb77.9e80e8","order":2,"disp":true,"width":"12","collapse":false},{"id":"f12bfb77.9e80e8","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

original source: https://geekworm.com/blogs/raspberry-pi/faq-of-raspberry-pi-full-function-motor-hat-robot-expansion-board

  • Download this zip file on your raspberry pi
  • Unzip this folder in your downloads folder

Raspi_Car.zip

Use this tutorial to stream video on the dashboard:

https://t3alliance.org/rpi-node-red-streaming-rpi-camera-to-dashboard/

Use template node:

image_pdfGenerate PDFimage_printPrint

Growth Mindset Resources

Here’s some great resources for those who are implementing Growth Mindset with their students:

STOKE DECK:
Stanford’s d.school is one of my go-to resources for anything creative, so I was a bit surprised when I found this particular one completely by accident.  I was looking for unique team-building tools, and “Stoke Deck” popped up.  This free printable has 28 different activities that will help students to “Boost Energy, Create Focus, Get Personal, Nurture Camaraderie, and Communicate Mindsets.”  They are each short exercises that can be used before starting a lesson – or even as a quick break during instruction.  Some of them, like “Blind Disco,”  may require some an established history of trust before you try them.  Others, like “Long Lost Friends,” might be good for introductions.  Almost all of them were new to me, so I can’t wait to try them!

 

Stoke Deck printables:

https://dschool-old.stanford.edu/sandbox/groups/k12/wiki/c5441/attachments/40f83/Stoke_Deck_FINAL.pdf?sessionID=8cbdfc6129ceb041dbad2247ffc9d0112fd0ebce

 

The K-12 Kiki lab:

https://dschool-old.stanford.edu/groups/k12/wiki/d5580/Stokes_and_Warm_Ups.html

 

 

image_pdfGenerate PDFimage_printPrint

T3 Rpi WiFi Router Setup TP Link TL-WR902AC

We recommend purchasing this router pre-programmed to provide the rpi wireless network, but it must still be connected to your local school WiFi.

This router allows you to connect to any type of wireless network and re-broadcast it as a local private WiFi network – also one LAN port can be connected to a local networking device such as a Raspberry Shake.

This allows the RPi computers to talk to each other over the LAN and do other local area networking tasks.

Configuration Guide for Pre Programmed Router:

image_pdfGenerate PDFimage_printPrint

T3 Lesson 8: Project – Make a Whoopee Cushion:

INTRODUCTION

This lesson is an opportunity for students to have fun converting their understanding of the technology into something in the real world.  A whoopee cushion is a glorified button that can be made out of easily available materials.

APPLICATION

This video from the Raspberry Pi Foundation has a very good description of how to make this project work.

The detailed instructions can be found here:

https://projects.raspberrypi.org/en/projects/whoopi-cushion

Our challenge is to make the audio files play using node red.  You can follow the video and install this extra output node that is capable of playing audio files.

https://flows.nodered.org/node/node-red-contrib-play-sound

 

REVIEW

If you found success or didn’t, please post a response in the forum.

image_pdfGenerate PDFimage_printPrint

T3 Lesson 7: Advanced Node-Red and the camera

INTRODUCTION

Slides

Setting up a camera can be one of the more exciting activities for your students to complete.  It provides immediate feedback that is very gratifying and provides ample opportunity to explore what can be done.

APPLICATION

Here is the basic tutorial for turning on a camera: The default for the image on the pi is for the camera to be enabled.

RPi Node-Red: Camera

Once the camera is taking photos, it wasn’t super difficult to incorporate a button into the sequence or any sort of a trigger that is based on an “if-then” scenario.  If the sonic sensor is an example of an analog device that collects data and can be set to trigger a photo when a certain threshold is reached.

RPi Node-Red: Sonic Sensor (HC-SR04)

 

 

image_pdfGenerate PDFimage_printPrint

RPi: Streaming raspberry shake data to node-red

Goal:

Learn how to send seismology data from a raspberry shake into a separate raspberry pi with node-red. And how to use the data once it arrives.

 

Resources:

Raspberry shake, setup following this guide: https://t3alliance.org/rpi-setting-up-a-raspberry-shake/

A separate raspberry pi with node-red, running on the same network

Introduction:

Raspberry shake usually processes its own data, and publishes it to it’s own public databases. However it is possible to configure raspberry shake to send a raw data-stream from itself to any device your network can reach. Raspberry shake uses a UDP stream to send data from itself to any list of ip addresses and ports that happen to be listening. Using this raw data stream you can create your own graphs, or set up alerts and triggers in node-red.

This means that the raspberry shake could be physically located anywhere in a building, or using the proper networking setup anywhere in the world and you can still comfortably receive the data in node-red on your own computer.  Imagine an email alert being sent-out by your RPi at home, because your RPi shake at school detected some unusual vibrations.  Or you could trigger a camera to go off, and email you a picture whenever footsteps were detected in your room, the possibilities are endless!

 

What is UDP?

When stuff is sent over the internet it is sent using a protocol, which is a way of organizing data so that both parties know what’s going on. If you made an agreement with a friend to always use red envelopes when a message was urgent, that would be an example of a protocol. Most of the time when you download a file, or send an email it is sent using TCP protocol; which is rather strict. For example, if something messes up and the TCP packets (analogous to envelopes with letters inside) arrive out of order, they will be reorganized and only sent to the destination when everything is sorted out. UDP is much less strict, and is more like a raw flow of data vs an orderly sequence of letters. If UDP packets arrive out of order, or have some missing, or even if the data inside is messed up they’ll usually be sent straight along to the destination.  This is useful in projects like our seismometer because it is more lightweight with less latency, also it comes with a feature called multicast which allows a data stream to be sent to multiple destinations at the same time; which is exactly what is possible with the raspberry shake.

Getting Started:

The first thing you’ll need is the IP address of the pi that will listen for the data, this can be found just by hovering over the network applet here. The easiest way to ensure the listening pi and the shake-pi are on the same network is to plug them both into the same router using ethernet cables. Otherwise setting up a WiFi connection on the shake can be tricky and even interfere with the measurements.

Connecting to the rs.local  or raspberryshake.local or even the ip_address:80 of the shake,

From the settings page, come to the UDP streams tab

Here is where you’ll need the ip address of your listening pi, it’s also important to make sure it’s connected to the same network as the shake. If the shake is using LAN this means you’ll probably have to plug your pi into LAN to.

Here I’ve entered the IP of my listening pi, and used the default port 8888

Click the plus button and don’t forget to hit save.

 

Reading the stream on raspberry pi:

Starting with a fresh flow, we’ll drag the UDP IN node in.

 

For the configuration chose the same port as we used in the rs.local config, that would be 8888, and make sure to set output to ‘a String’ instead of ‘Buffer’.
If you hook your UDP RECIEVER up to a debug node you should already be able to see a stream of data coming in, if not something is wrong with your connection (probably raspi isn’t on the same network as raspberry shake).

Next we need the raspberry shake parser node, made by the guys who build the SHAKE.
This can be installed by going into the palette manager, as of now it’s the only result when you search ‘shake’.
The installation will take a few minutes, and then you can chain it with the UDP node like so.

All the rshake parser node does is take the raw thing outputted by the UDP node, and turn it into an object with various data sorted into properties. Using a a debug node we can examine the output. For example, the ‘channel’ property allows you to discriminate between different sensors on the shake. We are using a raspberry-shake ‘1D’  so we only get one channel ‘EHZ’.

 

Now that we have received the data through the UDP ports, we can start to use the data. The data can be used as any other variable data sensor data, and to practice using the data follow the links below.

To make a real-time, Dashboard Seismogram: https://t3alliance.org/rpi-building-a-raspberry-shake-applausemeter-in-node-red/

To make a Shakemeter: https://t3alliance.org/rpi-building-a-raspberry-shake-seismogram-in-node-red

 

image_pdfGenerate PDFimage_printPrint

T3 Lesson 6: Node-Red and programming the GPIO pins

Note:  This is divided into two section

INTRODUCTION

Slides

This lesson introduces Node-Red and how it can be used to control the GPIO pins on the Raspberry Pi.   The first part of the lesson is seeing how Node-Red is a programing language that follows the basic concepts identified earlier.  The second part is in understanding the GPIO pins and how they function with and without Node-Red. A challenge activity that students build such as push button timer or stop lights will be available soon.

APPLICATION

Here are three tutorials that you can explore with your students that all go over basic Node Red GPIO pin functions.

RPi Node-Red: RGB LED

 

RPi Node-Red: Push Button

RPi Node-Red: Buzzer

REVIEW

Post your reflection in the forum, if you are comfortable sharing.  We’d like to hear how it went and what we can do to improve this process.

 

image_pdfGenerate PDFimage_printPrint

T3 Lesson 5: Scratch and Basic Programming

INTRODUCTION

This lesson teaches about some basic programming constructs using one of the simplest programming languages.  Many students will have been exposed to it, so if it’s not for your crew, skip it. There are enough advanced options that a student can make a very complicated program.  I think of it like legos – it’s a good space to play around and get familiar with the basic programming concepts.

APPLICATION

Here are slides that can be helpful in introducing this topic.

Here is a link to my explanation of the Astronaut reaction time game.  The tutorial suggests that you use the older version of Scratch on your Pi, version 1.4.  It can be done with that or else you can use the slightly slower version 2.0.  Version 2.0 is identical to what you find when you use scratch in a basic computer browser.  It is Flash-based and it runs a little slower than version 1.4.

 

image_pdfGenerate PDFimage_printPrint

T3 Lesson 4: Computers, Raspberry Pi and the internet of things

 

INTRODUCTION

This lesson is a presentation that is meant to open students eyes to the power of the Raspberry Pi.  We focus on the basics of a computer, input, and output, and share examples of cool projects that are done in a number of industries.  Biomedical, home security, seismology, environmental science are a few that can be shared. A discussion about the Internet of things (IoT) and how computer programs function will be valuable here.

Slides

APPLICATION

In the slides, there is a link to the Code.org video – What makes a computer a computer – Its an excellent introduction to the idea of a computer and the way that it takes in and puts out information.

 

After going through the video here and sharing some of the photos of cool projects I try to get a discussion going in which the students have a chance to share what problems or issues might have been addressed with the technology.    If there is someone in your community willing to share their Raspberry Pi’s project in some capacity – this is a wonderful time.  The idea here is to build excitement for what is possible and then to get them ready for the challenging work ahead.

REVIEW

Post your reflection in the forum, if you are comfortable sharing.  We’d like to hear how it went and what we can do to improve this process.

 

image_pdfGenerate PDFimage_printPrint

T3 Lesson 15: Air Quality Sensors

INTRODUCTION

Air quality is one of those topics that connects all of us.  It’s not difficult to find someone in your community who is sensitive to variations in air quality and is willing to share their story as a seed for an air quality monitoring project.   As I describe above,  our project with air quality sensors came out of the problem that our community in Hawaii faced during the 2018 volcanic eruption.

Slides

Setting up for this day depends on the resources that you have available to you.   In the story presented about Hawaii, we had students split up into teams of 3 to build air quality sensors for various areas around our region.   If you just have one, then you will want to emphasize more about the data that is collected and what it means than the building process.   Building the kit is pretty straightforward if you follow the tutorials below.

The connection with what the data means is the exciting part.  I would find someone in your community who is interested in talking with your students about Air Quality.  Once the students know how to manipulate the LCD screen, this can turn into a way for the Air Quality information (and other info) to be displayed.

APPLICATION

Here are the building steps:
https://t3alliance.org/rpi-airquality-station-indepth-assembly/
Here are the programming steps:
Here are the steps associated with programming the LCD screen:
https://t3alliance.org/rpi-airquality-station-creating-an-animated-nyancat-wallpaper/

REVIEW

You will know this is working on the specific level if students or you can notice changes in air quality after tweaking the environment slightly.  An open or closed door, any sort of dust and you should be able to detect changes.  On the larger level, if students feel comfortable applying this technology to a community issue then you have opened a huge door.  There are 3 sensors connected, nothing is stopping a student from identifying and setting this device up with more sensors that can send information to the cloud.   This basic sensor is like the gateway project to more remote monitoring projects.

 

image_pdfGenerate PDFimage_printPrint

Rpi: Time and Timezones

Goal:

Understand how to configure time and timezone settings on the raspberryPi.

What you will learn:

How to set the timezone on boot, or later and make sure time is being updated correctly.

What you will need:

RaspberryPi and an internet connection.

 

Getting Started:

The first time you boot the raspberryPi you’ll be confronted with this setup page:

This is because WiFi requires a working timezone setup from the start, when you click through you’ll have some localization settings.

But if you need to get to these settings again, they can always be accessed through the configuration menu here:
This screenshot is after I used the WiFi applet to connect to the internet, which I’ve circled.

Here is what it looks like when you set the timezone, it’s also important to configure the WiFi country correctly or you won’t be able to connect to WiFi.

Finally, you can confirm that the time is being synchronized over the internet using the terminal.
Here I’ve opened a terminal, and used ‘timedatectl’ to confirm that network time is enabled, and that the time has been synchronized.

You can also confirm that your timezone settings worked correctly here.

image_pdfGenerate PDFimage_printPrint

T3 Lesson 3: Building the Box & Raspberry Pi Kits

INTRODUCTION

Now that students are pumped up with the sense of efficacy that comes from building a brushbot, its time to switch to building a computer in components.  This is an example of an opportunity to hold space for the students to “figure it out” and continue on their growth mindset pathway.  Building the boxes can be done without much instruction given that the culture of growth mindset has been set.  Students figure out how to assemble the boxes in about 40 minutes.   If you have an hour, expect that students will spend the final part of class exploring the Pi and getting to know its features.

APPLICATION

Preparing the space – Make sure that each student has sufficient space to assemble their kit.  If you have students that are working together, make sure they have sufficient space to spread out and that they have access to power nearby.   You can share the slideshow showing a guide and a quick video of the assembly process but try to refrain from giving too much directive.  It’s a puzzle and the pieces only fit one way.

Slides

It helps to have at least two people doing it at the same time, so they can compare and help each other with the process.  We purposely did not give step-by-step instructions because the challenge is figuring it out, using your growth mindset to not give up or get too frustrated.

Here’s a video of the process.

Once the box is together, the next step is to plug in the power, monitor and raspberry pi.  This will create a functioning computer loaded with the basics of a web browser and a few games.

I recommend checking that the box is assembled and that the screws are tight before handing the students the bag of electronic equipment.

Once the bag of equipment is handed out introduce the idea of physical inputs and outputs.

Share the short video about the anatomy of a Raspberry Pi.

 

REVIEW

Allow students to explore around on the pi and recognize that this is a fully functioning computer.  Students often become interested in Minecraft.  If there is a student that you identify as “minecrafter” you can ask them to take a moment to share their skills.

Celebrate the success that just occurred!  You’ve just assembled a working computer!!  Reflect on what you did well, and what things you could improve on for your next challenge(s).

Post your reflection in the forum, if you are comfortable sharing.  We’d like to hear how it went and what we can do to improve this process.

 

image_pdfGenerate PDFimage_printPrint