RPi Node-Red: BME280

Parts List:

BME280

Getting Started:

Setting up the Hardware

Setting up Node-Red

1) Start Node-Red and navigate to 127.0.0.1:1880.

If your Raspberry Pi does not have the node-red-contrib-bme280 palette, follow the instructions located here.

2) After installing the BME280 palette, place the Bme280 node onto the workflow.

3) What the Bme280 node does is read sensor data from the Bme280, and delivers that data as a payload.

msg = {
  _msgid: <node-red msg_id>,
  topic: <defined topic>,
  payload: {
    model: "BME280"  or  "BMP280",
    temperature_C: <float in celsius>,
    humidity: <float in %>, // Only present if model == "BME280"
    pressure_hPa: <float in hPa>
  }
}

 

As you can see, the payload contains attributes we will graph, including temperature, humidity, etc.

4) After seeing what the BME280 sensor sends to the Raspberry Pi, we are going to format it as a graph using Node-Red and Dashboard. Start by placing a change node from the functions section onto the workflow. The change node specifies the data field from the Bme280 node, in this case it is the temperature field.

5) Double-click on the change node to open the node configuration menu. Under Rules, you will see a field for payload and under that, another blank field. Click on the drop down button and select msg.

6) Now that we have specified the type to msg., we want to type in “payload.temperature_C”. If you look at the BME280 payload again, you can see that the field we typed in refers to that payload. Click Done once completed.

7) Drag and drop the chart node from the dashboard section onto the workflow.

8) Double click the chart node to edit the node. On the group field, click on the pencil button.

8.1) On the Tab field, click on the pencil button again.

8.2) From there, click on the Update button to return to the previous menu, then again to return to the original menu. This is to confirm the dashboard view settings. On the original menu, we can adjust the graph’s design, color, label, etc. Let’s proceed with labeling our chart “Temperature in C”. Click Done once completed.

9) To have the BME280 send data at an interval, place an inject node from the input tab onto the workflow.

9.1) Set the payload to number and enter 1 (means ‘on’ for the computer) in the field. Set Repeat to interval and set the interval time to any desired time (good to start at 5 seconds). Click Done once completed.

10) With all the nodes configured, connect all the nodes and hit Deploy.

11) Navigate to the Dashboard page to view your graph(s): 127.0.0.1:1880/ui/#/0

Node-RED Palette Installation (node-red-contrib-bme280)

1) Click on the menu icon in the top-right corner of the window and select Manage palette.

2) Navigate to the Install tab.

3) In the search modules bar, type in node-red-contrib-bme280 and click install.

4) An installation window will pop-up. Click install.

 

Next Steps:

 

Raspi Weather Display with Icons

 

Resources:
Raspberry air-quality kit with LED panels setup.
Some icons, these were prepared earlier:

 

Building the flow:

If you ever get stuck along the way, feel free to copy the entire flow from here and import it into your node-red:

[{"id":"ed465cb7.d4944","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"411f7586.434bcc","type":"inject","z":"ed465cb7.d4944","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":true,"onceDelay":0.1,"x":190,"y":260,"wires":[["8a3f6b9e.de4138"]]},{"id":"8a3f6b9e.de4138","type":"Bme280","z":"ed465cb7.d4944","name":"","bus":"1","address":"0x76","topic":"bme280","extra":false,"x":380,"y":260,"wires":[["6a071f4.48389e"]]},{"id":"6a071f4.48389e","type":"BME280-Parse","z":"ed465cb7.d4944","name":"","x":570,"y":260,"wires":[["bc3d596d.2a3848","29830fae.65e84"],[],[]]},{"id":"bc3d596d.2a3848","type":"text-to-matrix","z":"ed465cb7.d4944","name":"","xOffset":0,"yOffset":0,"rgb":"0,255,41","font":"6x9.bdf","prefix":"Temperature C: ","source":"msg.payload","matrix":"892e8063.2e0c3","zLevel":"","x":820,"y":160,"wires":[]},{"id":"11d60dbb.385ee2","type":"image-to-matrix","z":"ed465cb7.d4944","name":"","file":"","xOffset":"96","yOffset":"32","matrix":"892e8063.2e0c3","zLevel":"","x":850,"y":300,"wires":[]},{"id":"29830fae.65e84","type":"function","z":"ed465cb7.d4944","name":"get current icon","func":"//setup some definitions\ncurrentTemperature = msg.payload\ncold = -3\nhot  = 39\n\noutputImage = \"https://t3alliance.org/wp-content/uploads/2018/11/sunny.jpg\"\n\n//check the temperature, and switch the image\nif (currentTemperature > hot)\n{\n    outputImage = \"https://t3alliance.org/wp-content/uploads/2018/11/fire.gif\"\n}\n\nif (currentTemperature < cold)\n{\n    outputImage = \"https://t3alliance.org/wp-content/uploads/2018/11/snow.gif\"\n\n}\n\n//replace the input with an image\nmsg.payload = outputImage\n\n//send to the next node \nreturn msg","outputs":1,"noerr":0,"x":830,"y":240,"wires":[["11d60dbb.385ee2"]]},{"id":"892e8063.2e0c3","type":"led-matrix","z":"","height":"64","width":"64","chained":"2","parallel":"1","brightness":"60","refreshDelay":"50","mapping":"adafruit-hat-pwm","autoRefresh":true}]

 

The first thing we need before we can start displaying any data, is the data itself. The air-quality kit comes with a variety of sensors, but here we will be focusing on the Bme280 which provides Temperature, Humidity, and Pressure.

First things first is to start reading the sensor, for this you’ll need these 3 nodes.

the ‘Bme280’ node retrieves data from the sensor, in a strange json format, the ‘BME280 parser’ node splits up the data into more user friendly streams, and the inject node on the far left is used to prod the ‘Bme280’ node into sending data to the Parser node.

The config looks like this (click to expand) :

If you deploy now you can already tell if the ‘Bme’ node is working, it’ll display some status text below the node showing the data it’s  reading. I’ve also hooked up a debug mode to my flow so I can see the temperature in real-time on the ‘debug’ tab.  You can also hook up a text node and put the results onto the display like this:
When using a led-matrix node, make sure to setup the ‘Display’ option, usually you can leave all the config for the display itself on default.

 

The ‘image’ node takes a url as a payload, and uses a few other parameters to decide where on the display to draw the image. All the icons at the top of this article are the same size (32×32); so we can always use the same location, the only data we need to parametrize is the url itself. But before we do that it’s nice to test out the image without any added complications.

 

Above I setup an inject node to inject one of the icons, I get the URL from this very article by using ‘copy Image location’.
You could leave the image node in its defaults, but I think its prettier with the icon in the bottom corner so I setup some X and Y offsets like this.

If you deploy this flow, you should see the icon you chose in the bottom right, and the temperature written across the top of the LED matrix. If you didn’t setup the inject nodes to auto-inject you might have to manually press the buttons that appear on the nodes to activate them.

 

 

 

 

 

 

 

Switching the image based on the temperature:

Next we will setup the flow to switch the image displayed based on the current temperature, using a function node to inject different URLs.
The function node receives a msg object, in this case from the BME Parse node which contains some properties like payload, and topic.

//setup some definitions
currentTemperature = msg.payload
cold = -3
hot  = 27

outputImage = "https://t3alliance.org/wp-content/uploads/2018/11/average.png"

//check the temperature, and switch the image
if (currentTemperature > hot)
{
    outputImage = "https://t3alliance.org/wp-content/uploads/2018/11/sunny.jpg"
}

if (currentTemperature < cold)
{
    outputImage = "https://t3alliance.org/wp-content/uploads/2018/11/cold.png"

}

//replace the input with an image
msg.payload = outputImage

//send to the next node 
return msg

Here we are just interested in the payload property, which is the temperature in Celsius.  We also setup three other variables, the temperatures we consider hot or cold, and the default icon to display if it isn’t really hot or really cold.

Then we use some if statements to check if the temperature is hot or cold, if it is we swap the outputImage for another.
Finally we swap the msg payload with our image and return it; in this case returning sends the msg to the output of this node and into the image node.

Here is what it looks like setup in our flow:
Feel free to copy and paste some or all of the code in if you feel confused, and remember the complete flow is available at the top of this article.

If you chose to use the animated gif icons, the frame-rate they play at is determined by the inject rate, the BME node tends to upde the weather about once or twice a second, so the gif will only play at about 1 or 2fps. This could be improved by injecting the temperature faster using some kind of function or repeat node, which would be a good personal project.

 

 

Setting up a raspberry shake NOOBS image

Resources:
SD card, SD card reader, Raspberry Shake NOOBS zip: https://gitlab.com/raspberryShake-public/raspShake-SD-img/raw/master/raspishake-release.zip?inline=false

Preparing the SD card:
The raspberry shake installer needs the SD card to be formatted with a specific type of file system called FAT32, usually if you buy a blank SD card it comes pre-formated like this; but if you’ve already used it for something its not a sure thing.

We’ll use a piece of software called gparted to format the SD card, so the first step is to install gparted with the following command:

sudo apt-get install gparted

next, from the same terminal run gparted as root:

sudo gparted


When gparted is open go to the top right, and select your SD card from the drop down; a good hint is to look at the size in GiB. I know my SD card is 8GIb so its probably the one labeled ‘7.4Gib’ not the 16 Gib one.
Make sure to never edit /dev/mmblk0/ because this is probably the card your raspbian is running on.

One you have the sd card open, right click on all the partitions listed below, and select ‘delete’. Gparted only applies operations in a separate step, so even though we deleted the partitions here it won’t actually do anything until we hit apply later.

 

 

 

After deleting the old partitions its time to make a new one, right click in the area we deleted the old partitions from, and select new. All the settings can be left at their defaults except for changing the file system to ‘FAT32’ as pictured.

Next the last step is to hit ‘Apply’ which is the green trick button in the bar next to where we selected the SD card. When it asks you if you’re sure click ‘Apply’.

Formatting the SD card will take a few seconds, after its done you can close gparted and remove and insert your SD card so rasbpian can re-detect it.

 

 

 

 

Setting up NOOBS:

For this step you need to download this zipfile: https://gitlab.com/raspberryShake-public/raspShake-SD-img/raw/master/raspishake-release.zip?inline=false

When your SD card is re-detected, open it in the file manager from the pop-up window.
Here I have the SD card open in the right window, and the raspberryshake zip open in the left

Open Action -> Extract, and copy the path for the SD card into the field here:
This extract step might take a while, after its done you can eject the SD card and you have a finished raspberry shake install image!

RPi Node-Red: Minimal Selfie Station Tutorial

Parts List:

 

What is a Minimal Selfie Station?
We will create a node-red flow to take selfies and display them right on the raspberry-pi desktop, using the LED-ring as a flash. To achieve this we will need to go through several steps: activate the LED-ring, take a picture, and open it on the desktop. But first we need to wire up the hardware.

Wiring:
Use jumper wires to hook up the LED ring to ground, 5v, and pin #18.
And the button hooks up to ground, 3v, and pin #12.

Setting up Node-Red:
if you get stuck in this tutorial, feel free to import the entire flow from here:

[{"id":"549d128c.d1e48c","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"7a6088da.6f3e38","type":"camerapi-takephoto","z":"549d128c.d1e48c","filemode":"2","filename":"","filedefpath":"1","filepath":"","fileformat":"jpeg","resolution":"9","rotation":"0","fliph":"0","flipv":"0","brightness":"50","contrast":"0","sharpness":"0","quality":"80","imageeffect":"none","exposuremode":"auto","iso":"0","agcwait":"1.0","led":"0","awb":"auto","name":"","x":670,"y":520,"wires":[["226fa57f.d594ca","65312393.72d7ec"]]},{"id":"65312393.72d7ec","type":"exec","z":"549d128c.d1e48c","command":"DISPLAY=:0.0 gpicview","addpay":true,"append":"&","useSpawn":"false","timer":"","oldrc":false,"name":"Open image file","x":910,"y":600,"wires":[[],[],[]]},{"id":"226fa57f.d594ca","type":"change","z":"549d128c.d1e48c","name":"turn off LED ring","rules":[{"t":"set","p":"payload","pt":"msg","to":"0,12,0,0,0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":520,"wires":[["e70bf46d.3df5b8"]]},{"id":"e01059e8.526678","type":"delay","z":"549d128c.d1e48c","name":"","pauseType":"delay","timeout":".5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":720,"y":340,"wires":[["2b05a1af.2d162e","4a634559.5bed0c"]]},{"id":"1c398bbd.6ff2c4","type":"change","z":"549d128c.d1e48c","name":"Set LED ring = Red","rules":[{"t":"set","p":"payload","pt":"msg","to":"1,12,0,255,0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":280,"wires":[["e70bf46d.3df5b8"]]},{"id":"2b05a1af.2d162e","type":"change","z":"549d128c.d1e48c","name":"Set LED ring = Green","rules":[{"t":"set","p":"payload","pt":"msg","to":"0,12,255,0,0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":340,"wires":[["e70bf46d.3df5b8"]]},{"id":"cd35bff4.45e72","type":"change","z":"549d128c.d1e48c","name":"Set LED ring = Blue","rules":[{"t":"set","p":"payload","pt":"msg","to":"0,12,0,0,255","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":920,"y":400,"wires":[["e70bf46d.3df5b8"]]},{"id":"4a634559.5bed0c","type":"delay","z":"549d128c.d1e48c","name":"","pauseType":"delay","timeout":".5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":720,"y":400,"wires":[["cd35bff4.45e72","d6b433a.088ced"]]},{"id":"db82b2b9.cc94a","type":"change","z":"549d128c.d1e48c","name":"Set LED ring = White","rules":[{"t":"set","p":"payload","pt":"msg","to":"0,12,255,255,255","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":930,"y":460,"wires":[["e70bf46d.3df5b8"]]},{"id":"d6b433a.088ced","type":"delay","z":"549d128c.d1e48c","name":"","pauseType":"delay","timeout":".5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":720,"y":460,"wires":[["db82b2b9.cc94a","7a6088da.6f3e38"]]},{"id":"8c366b7d.3c3f18","type":"rpi-gpio in","z":"549d128c.d1e48c","name":"","pin":"32","intype":"down","debounce":"25","read":false,"x":400,"y":280,"wires":[["655eb18c.06cca"]]},{"id":"e70bf46d.3df5b8","type":"rpi-neopixels","z":"549d128c.d1e48c","name":"","pixels":"12","bgnd":"","fgnd":"","wipe":"40","mode":"pcent","rgb":"rgb","brightness":"100","gamma":true,"x":1180,"y":280,"wires":[]},{"id":"655eb18c.06cca","type":"delay","z":"549d128c.d1e48c","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":600,"y":280,"wires":[["e01059e8.526678","1c398bbd.6ff2c4","4c17564c.dcd4c8"]]},{"id":"4c17564c.dcd4c8","type":"debug","z":"549d128c.d1e48c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":920,"y":200,"wires":[]}]

 

start node-red, and navigate to 127.0.0.1:1880. Drag in a rpi gpio pin and hook it up to a debug node.

To configure the GPIO node, set the pin to GPIO: 12, resistor to pulldown.
You can also name the node ‘button’ to remind you later.


Now that we have the button configured, we can test it out. If you deploy the current flow you should be able to see output in the debug tab whenever you press the button.
Next we want to setup the flash ring, the led-ring is controlled by a neopixels node, so drag one of those in.
The only Setting that needs to set for this is the number of led in string, usually this should be 12.
You can rename this node to led-ring in the same menu.

Reading the led-ring help dialog, we find that it doesn’t  just take a generic ‘injection’ to turn it on; but a more complicated command that it reads.
For example: ‘1,12,0,255,0’ sets the entire ring red.
Broken down, this command means: ‘set leds #1 to #12 to the color ‘0,255,0’.  This color can further be broken down into ‘Green: 0, Red: 255, Blue: 0′

So if you use a generic ‘inject’ node into the led-ring node, you can light it up red with this string.

For the actual flash a flashing, multicolored timer, followed by a white flash is ideal, to do this we use timing nodes combined with change nodes.
The change nodes we will use look like this, they take an input; change the payload and then send it out.

For the flashing effect the nodes will have to be chained like this, with a delay node.

You can copy and paste the change node from earlier, and then go in and change the color code it sends.
This chain can be continued down the line; don’t forget that the color code for white is: 255,255,255.

One annoying quirk of the GPIO node, is that it sends a message when you press the button down and when released; so you could trigger this entire flow twice if you held the button down for a noticeable amount of time. The easiest way to solve this is to stick a rate-limit node after the GPIO node, like this.
A good default is 1 message per 5 seconds.
To do this, setup a ‘delay’ node with these settings, hooked just after the GPIO node.
Make sure to select ‘drop intermediate messages’

 

Next we need to setup the camera node, make sure the camera is plugged into the camera port on the raspi.
[image here]

You can setup the camera node like this:
The input wire activates the camera, and the output wire sends the filename when its done taking a picture.
Seeing as the camera sends a message when its finished taking a picture, we can use this to turn off the flash at exactly the right time.
When you copy and paste another change-node, set the color to ‘0,0,0’ to turn the led-ring off.

You can use a debug node to check the filename the camera is outputting too.

The final, and most arcane step is to open the image in a image-viewer. This is done with an ‘exec’ node you can drag in.
You can copy all these settings in, and hook it up to the ‘take photo node’

 

Leaving you with a hopefully functional flow that looks like this.

If you are a teacher and need a working demo of this project, you can download the image here: https://t3alliance.org/wp-content/uploads/2018/11/selfieImage.zip

RPi – Test Flow – Selfie Station

To use copy and paste the below code into your Node-Red import window.

[{"id":"a55ecedd.0645c","type":"rpi-neopixels","z":"37a556b3.c240ba","name":"led ring","pixels":"12","bgnd":"","fgnd":"","wipe":"0","mode":"pixels","rgb":"rgb","brightness":"80","gamma":true,"x":700,"y":60,"wires":[]},{"id":"87ed0744.98f828","type":"camerapi-takephoto","z":"37a556b3.c240ba","filemode":"2","filename":"","filedefpath":"1","filepath":"","fileformat":"jpeg","resolution":"9","rotation":"0","fliph":"0","flipv":"0","brightness":"50","contrast":"0","sharpness":"0","quality":"80","imageeffect":"none","exposuremode":"auto","iso":"0","agcwait":"1.0","led":"0","awb":"auto","name":"","x":220,"y":340,"wires":[["ff1b217a.3a134","1b3e1abe.0e8145"]]},{"id":"7658355c.89396c","type":"rpi-gpio in","z":"37a556b3.c240ba","name":"","pin":"32","intype":"down","debounce":"25","read":false,"x":80,"y":60,"wires":[["6872ffde.e33c9"]]},{"id":"eb0fc181.49dd7","type":"exec","z":"37a556b3.c240ba","command":"DISPLAY=:0.0 gpicview","addpay":true,"append":"&","useSpawn":"false","timer":"","oldrc":false,"name":"Open image file","x":500,"y":460,"wires":[[],[],[]]},{"id":"ff1b217a.3a134","type":"function","z":"37a556b3.c240ba","name":"Check if filename payload","func":"if(msg.payload.length > 5)\n    return msg;","outputs":1,"noerr":0,"x":270,"y":460,"wires":[["eb0fc181.49dd7"]]},{"id":"6872ffde.e33c9","type":"delay","z":"37a556b3.c240ba","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"5","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":260,"y":60,"wires":[["d88eb221.18aaa","2f031fd.94cf5e"]]},{"id":"1b3e1abe.0e8145","type":"change","z":"37a556b3.c240ba","name":"turn off LED ring","rules":[{"t":"set","p":"payload","pt":"msg","to":"0,12,0,0,0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":340,"wires":[["a55ecedd.0645c"]]},{"id":"d88eb221.18aaa","type":"delay","z":"37a556b3.c240ba","name":"","pauseType":"delay","timeout":".5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":280,"y":120,"wires":[["3bf98e22.205622","95e7c6b7.584908"]]},{"id":"2f031fd.94cf5e","type":"change","z":"37a556b3.c240ba","name":"Set LED ring = Red","rules":[{"t":"set","p":"payload","pt":"msg","to":"1,12,0,255,0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":60,"wires":[["a55ecedd.0645c"]]},{"id":"3bf98e22.205622","type":"change","z":"37a556b3.c240ba","name":"Set LED ring = Green","rules":[{"t":"set","p":"payload","pt":"msg","to":"0,12,255,0,0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":120,"wires":[["a55ecedd.0645c"]]},{"id":"2fae3801.80ef68","type":"change","z":"37a556b3.c240ba","name":"Set LED ring = Blue","rules":[{"t":"set","p":"payload","pt":"msg","to":"0,12,0,0,255","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":180,"wires":[["a55ecedd.0645c"]]},{"id":"95e7c6b7.584908","type":"delay","z":"37a556b3.c240ba","name":"","pauseType":"delay","timeout":".5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":280,"y":180,"wires":[["2fae3801.80ef68","ce6b30a5.01a5f"]]},{"id":"d8514317.e48f7","type":"change","z":"37a556b3.c240ba","name":"Set LED ring = White","rules":[{"t":"set","p":"payload","pt":"msg","to":"0,12,255,255,255","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":240,"wires":[["a55ecedd.0645c"]]},{"id":"ce6b30a5.01a5f","type":"delay","z":"37a556b3.c240ba","name":"","pauseType":"delay","timeout":".5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":280,"y":240,"wires":[["d8514317.e48f7","87ed0744.98f828"]]}]

 

RPi-NodeRed OLED IP Address Display

Please copy and paste the entire code block below into the node-red clipboard import window.

[{"id":"a1ae5e26.b300a","type":"String","z":"e0e44734.95d078","name":"OLED","display":"4fe1da30.5141a4","x":690,"y":220,"wires":[]},{"id":"60037f1d.3914b","type":"function","z":"e0e44734.95d078","name":"Format Message","func":"msg.payload={\nx:1,  \ny:50,\ntext:\"IP \"+msg.payload+\":1880\"\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":520,"y":220,"wires":[["a1ae5e26.b300a"]]},{"id":"8971c892.2fa0f8","type":"change","z":"e0e44734.95d078","name":"IP","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0].address","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":220,"wires":[["60037f1d.3914b"]]},{"id":"974cfafc.e526d8","type":"inject","z":"e0e44734.95d078","name":"","topic":"","payload":"10","payloadType":"num","repeat":"60","crontab":"","once":true,"onceDelay":0.1,"x":90,"y":220,"wires":[["8c7a8725.02fa58"]]},{"id":"8c7a8725.02fa58","type":"hostip","z":"e0e44734.95d078","name":"Host IP","x":220,"y":220,"wires":[["8971c892.2fa0f8"]]},{"id":"8f95bb29.b800d8","type":"comment","z":"e0e44734.95d078","name":"Display IP address on the mini OLED display","info":"","x":300,"y":180,"wires":[]},{"id":"4fe1da30.5141a4","type":"oled-config","z":"","name":"","width":"128","height":"64","address":"3c"}]

RPi Node-Red: Buzzer

Parts List:

Piezoelectric Buzzer

What is a Piezoelectric Buzzer?

A piezoelectric buzzer is a buzzer that is activated with an oscillating electric signal.  This means to produce a tone the buzzer must be turned on and off many times per second. The faster the the buzzer is turned on and off the higher the pitch is produced.  We can achieve this using a pulse width modulated signal (PWM). With a PWM signal we can specify the frequency in hertz (cycles per second).

Getting Started:

Setting up the Hardware

Using jumper wires connect the I/O pin of the buzzer to GPIO16, the GND pin to GND (ground), and the VCC pin to VCC.

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880.  Drag two inject nodes and a Raspberry Pi output node into the flow area.

Double click on the Raspberry Pi output node to open its configuration menu.  Set the Pin to GPIO16.  Set Type to PWM output.  Set Frequency to 100 Hz.  You can Name the node anything, I chose “buzzer”.

Double click one of the inject nodes.  Use the dropdown menu to change the Payload data type number, type a 1 in the textbox.  Name the inject node “on”.

Double click the unmodified inject node.  Use the drop down menu to change the Payload data type to number, type a 0 in the text box.  Name this node “off”.

1 and 0 correspond for to values of a binary digit(bit) true and false, high and low, on and off respectively.  These are called Boolean values and are a fundamental data type in Computer Science.

Connect the inject nodes to the output node and then deploy the flow.

If everything has worked correctly pressing the “on” button should cause a sound to come from the buzzer and the “off” button should stop that sound.

Leveling The Nozzle

 

If you find one of your nozzles is at a different level than the other the easiest way to fix this problem is to either file or sand down the nozzle to the same level as the other

The best way to do this is to use sandpaper and level the build plate like normal except using sandpaper as the leveling paper but if you don’t have any sandpaper around then you can use a file

Engineering the Community Engagement Process

The community engagement process can be a daunting task to start.

 

Student preparation means that you have created a safe learning environment and helped students maintain a growth mindset.  This means primarily that you constantly celebrate speech patterns that support a growth mindset.  It also means that they have “played” with enough technology to feel that they have the ability to creatively apply it in a variety of situations.  Activities in the kits will help with this, but so do icebreakers that involve working together and connecting with others.  Make sure to include time to play and try stuff – don’t rush tech skills training.  Teach the design thinking process, and guide them along every step of the way. The process is pregnant with opportunities to practice communication and teamwork skills.

 

 

We will have guides to help with the communication skills. The most important one that students should practice is the skill of listening. Below is a graphic showing other skills that should be taught as needed.   We work with communication experts to get tips and tricks for the best ways to help guide students as they go through this.   It is important that you introduce topics when there is a context for learning about it.

Introduce the Design Thinking process developed at Stanford and presented well in this crash course PDF.  I have modified the design they use here to reflect a general T3 alliance project.  We introduce the mini-grant proposal as a step right before a prototype phase.  This is only necessary when the cost of building the prototype exceeds what you have on hand and consider consumable.

Program preparation:

The most important thing a program can do to support the community engagement process is cutting through the red tape that exists in any institution.  Things that a program needs to do to prep, finding an appropriate learning space, preparing for local field trips, managing the finances for small-scale projects, helping with background checks for community members, managing equipment, and hiring capable staff with some sort of computer science background.  Perhaps the most important aspect of a program is being ready to support student ideas for projects with immediate financial backing.  The mini grant / deliverables process is very important.

 

Community preparation:

The community has always been key for societies to raise their youth.  In many native cultures, there are stories of youth getting their first fish, or game animal, bringing it back to the village and being celebrated for the contribution they made to the survival of the community.

Learn your elevator pitch and be ready to tell anyone you meet about the what T3 alliance is about in under a minute.  An “elevator pitch” is a term used to describe what you would say if you were in an elevator with an important job prospect or grant manager.  They don’t know of you, so you have 60 seconds to sell your idea.   You are leaving them with an opening to ask more, and possibly get involved.   The image below shows an idea for redesigning our website – but it can be broken down into the pitch – the three big bubbles showing what we do and how it turns into studnet involvement in STEM career fields.

Once they are interested, outline what a specific commitment might look like and develop the relationship with attunement to safety, communication, and set up at least 3 opportunities for interaction.   The first interaction does not need to be done in person, but it’s better if it can be.  Here is an example of an interview we filmed for a possible client partnership with the Upward Bound Programs at UH Hilo and an astronomy project.

The second interaction should be somewhere around the testing phase.  Once a project is developed. they should work together to analyze results to see if it fits the client’s needs.  The last interaction should be a celebration of some sort.  Presenting a completed project to an appreciative community member is an incredible experience for a group of students.   If a potential client understands and can support this, then move forward, if not, gently separate yourself from the relationship.

GO Time:

Here are a few tips:

1: Remember why you are doing this – details can pop up that will frustrate you.

  1. Start small – Upward bound office, someone at the university, STEM friends, Non-Profits, Government organizations are all potential sites where you could find projects.  Small and safe is a good first step.  Over time, it will get more complicated.  Every small success for a group of students builds confidence.  We used selfie stations to get kids feeling the process.
  1. Teach when they need to know.  Don’t teach writing skills until they need to write a proposal.  As soon as you want them to use a video camera – teach what they need to know to produce the video you want them to have for a deliverable.  Context is everything!

4.  Trust the PROCESS.  The design thinking process is a step by step guide.  If you always come back to that you will be able to help every student redirect their actions.

 

 

Makerbot Desktop – Outdated Software Method

Slicing Software Installation and Setup

To use the QIDI Tech 1 Dual Extruder  you will need some software installed locally on a laptop/desktop computer.

The software we are using right now is this version of Makerbot Desktop  It will not work with “Makerbot Print” so please use Makerbot Desktop.

Once you have installed “Makerbot Desktop” open it and click on the “Prepare” tab at the top, you do not need to create a Makerbot account.

You need to to also go to “Devices” at the top and set your “Type of Device” to “Replicator (Dual)”

Now you can import a STL file

Now click on “Export Print File” and save the print file to a SD card connected to your computer.

Once the file is on the SD card you should eject it and plug it into the 3D printer.  Then proceed to print the file through the menu system on the printer.

3D Printing: Design – Nametags

Overview

In this lesson, you will learn how to create a personal 3D nametag using TinkerCAD

Before you start

  • Have an internet connected laptop/desktop
  • Has already created a TinkerCAD account
  • Has familiarity with TinkerCAD controls
  • Mouse (optional)

Procedure

  1. Starting with an empty workplace, find and place the ‘Box’ object from the right panel to act as the primary base of the nametag.
    • Decrease the height of the box by dragging one of the ‘white’ boxes located on the top surface of the box.

    • To change the length of the box, drag one of the ‘black’ boxes located on each side of the box.

  1. Find and place the object ‘Text’ from the right panel to act as your name.
    • You can change the height of the ‘text’ object by dragging the top ‘white’ box (Similar to the previous step).

    • You can change the text from the shapes options window located in the top right. For demonstration purposes, we will leave it at ‘TEXT’.

  1. Finally, find and place the object ‘Tube’ from the right panel to act as your nametag’s hook.
    • Similar to the previous steps, you can adjust the position and size of the object by dragging the small white/black boxes.

  1. Once you have finished placing and resizing your objects, select all objects by hitting the command ‘Ctrl+A’
    • You should see all of the objects highlighted. From there, click on the ‘Group’ tool at the top toolbar, and it will group all individual objects into a single one.

Complete!

You have successfully created a personal nametag! Try out different creations by adding more shapes, resizing objects, and more.

RPi Node-Red: Push Button+ RGB LED or Buzzer

Parts List:

1x RGB LED

1x Push Button

1x Piezoelectric Buzzer

Getting Started:

Setting up the Hardware

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880.  Drag one Raspberry Pi input node and five Raspberry Pi output nodes into the flow area.

Double click on the Raspberry Pi input node to open its configuration menu.  Set the Pin to GPIO25.  Name the node “Button”. Set the Resistor to “pulldown”.

Button Input Node

 

Double click on the unmodified Raspberry Pi output node.  Set Pin to GPIO16.  Set Type to PWM output.  Set Frequency to 100.  Name the node “buzzer”.

Buzzer Out Node

For this step, we are going to setup the output nodes for each RGB node. Double click on one of the Raspberry Pi output nodes.  Set the Red Pin to GPIO13Green Pin to GPIO19, and Blue Pin to GPIO26. Check the box to Initialise pin state?  select low (0) from the drop down menu.  Name each node with its respective “Red, Green, Blue”.

Red Out Node

Green Out Node

Blue Out Node

Wire each output node to the single input node and deploy the flow.

If everything is working properly the LED should illuminate and the buzzer should activate for a short period of time after the button has been pressed.  To deactivate either the buzzer or LED simply delete the wire in Node-Red connecting the associated node with the Button node.

Whats Next?

  • What other combinations can you make with items in your kit?

RPi Node-Red: PIR + RGB LED or Buzzer

Parts List:

1x RGB LED

1x PIR

1x Piezoelectric Buzzer

Getting Started:

Setting up the Hardware

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880.  Drag one Raspberry Pi input node and five Raspberry Pi output nodes into the flow area.

Double click on the Raspberry Pi input node to open its configuration menu.  Set the Pin to GPIO20.  Name the node “PIR”.

Double click on the unmodified Raspberry Pi output node.  Set Pin to GPIO16.  Set Type to PWM output.  Set Frequency to 100.  Name the node “buzzer”.

Buzzer Out Node

For this step, we are going to setup the output nodes for each RGB node. Double click on one of the Raspberry Pi output nodes.  Set the Red Pin to GPIO13Green Pin to GPIO19, and Blue Pin to GPIO26. Check the box to Initialise pin state?  select low (0) from the drop down menu.  Name each node with its respective “Red, Green, Blue”.

Red Out Node

Green Out Node

Blue Out Node

Wire each output node to the single input node and deploy the flow.

If everything is working properly the LED should illuminate and the buzzer should activate for a short period of time after the PIR has detected movement.  To deactivate either the buzzer or LED simply delete the wire in Node-Red connecting the associated node with the PIR node.

Whats Next?

  • What other combinations can you make with items in your kit?

RPi Node-Red: RGB LED

Parts List:

1x RGB LED Board

4x Female-Female Jumper Wires

Getting Started:

Setting up the hardware:

Connecting the RGB LED Module

Setting up on Node-Red:

Have three out nodes, each representing one of the three outputs. For each out node, have two inject nodes (on and off)

Setting up Out Nodes

Configure Red output to GPIO13 (pin 33)

 

Configure Green output to GPIO19 (pin 35)

Configure Blue output to GPIO26 (pin 37)

 

Setting up Inject Nodes:

Configure ‘off’ switch for inject node – Set payload to 0

Configure ‘on’ switch for inject node – Set payload to 1

Deploy the flow

RPi Node-Red: Push Button

Parts List:

Push Button

3x Female-Female Jumper Wires

What is a Push Button?

A push button is a momentarily activated button.  When the button mechanism is fully depressed an internal electrical connection is made and this newly made connection can be read as the activation of the button.

Getting Started:

 

Setting up Node-Red

Start Node-Red and navigate to 127.0.0.1:1880.  Drag a Raspberry Pi input node and a Debug node into the flow area.

Double click on the Raspberry Pi input node to open its configuration menu.  Set the Pin to GPIO25.  Set Resistor? to pulldown.  You can Name the node anything, I chose “button”.

The debug node can be left with it’s default settings, wire the button node to the debug node and deploy the flow.

If everything has been put together correctly you should see the number under the button node in the Node-Red flow change from a 0 to a 1 when the button is activated and from 1 to 0 when the button is deactivated.  You should also be able to see a record of the button activation in the debug tab of Node-Red.

Whats Next?

automatically running node-red, as root

This tutorial shows you how to have node-red start and run as root instead of a normal user.

This is necessary for the RGB Matrix node: node-red-contrib-easybotics-led-matrix

Open a terminal and paste in the following lines:

sudo systemctl enable nodered.service
sudo npm config set unsafe-perm true

Now Node-Red will start automatically when the Raspberry Pi boots up.
The second line tells npm that we intended to run it as root; and that its okay to install nodes in protected directories.

The systemd service that we enabled is really just a type of script that lives in a file somewhere.

So if we want to change the user that runs node-red, we need to edit the file, this can be done with this fancy one liner:

d=/lib/systemd/system/nodered.service && sudo sed "s/User=pi/User=root/;s/Group=pi/Group=root/" $d > tmp && sudo mv -f tmp $d

When pasted into the terminal and ran, this bash expression will edit the nodered.service file and change the user to ‘root’.

If you have flows and nodes that you wish to keep, you can use this command to edit your node-red settings to keep using your old home-directory:
But be warned, this one line will only work after node-red has run atleast once as root; seeing as this is when the settings file it is editing is created.
An easy way to ensure this is to reboot after doing the one liner above, and then run the one liner below; and then finally reboot again.

d=/root/.node-red/settings.js && sudo sed "/.*userDir:*./c\userDir: '\/home\/pi\/.node-red\/'," $d > tmp && sudo mv -f tmp $d

Some nodes, such as the led-matrix require the soundcard to be disaabled
there’s a command for that too:

d=/boot/config.txt && sudo sed "/.*dtparam=audio=on*./c\dtparam=audio=off" $d > tmp && sudo cp -f tmp $d

 

Selfie station example project

Here is an example of an applied design thinking project done with a class of 17 students at the University of Hawaii Hilo Upward Bound T3 alliance program during the summer of 2018.  Node Red and physical Raspberry Pi setup instructions can be found on this post.

Students had mastered the skills associated with basic physical computing and Node Red.  They were capable of setting up a button, an LED Ring, using a sonic sensor, a PIR sensor, and a small camera.  They had been able to combine all these components using Node Red and were capable of generating emails that sent a photo.

I asked around for a person or group at the university that might be interested in a device that could take photos and have them emailed instantly.    Eventually I found the perfect potential client in Shara Mahoe, the director of new student services.    She was planning a scavenger hunt for the new student orientation day later in the summer when 600 freshmen appear and nervously try to find their way around the large UH Hilo campus.  She listened to my description of what the students in our T3alliance program were able to do and how design thinking process worked.   Once she understood what was involved, she signed up to be a client.

Shara and a colleague showed up in my classroom the next day and I interviewed her in front of the class.  She described her day and what she hoped it would feel like to new students.  She listed out 5 locations around the University that could use a selfie station and asked my students if they could find a solution that would work.  I had previously broken the students up with an ice breaker activity and they now found themselves choosing one of the sites around campus to design a selfie station.  As a team, they discussed what they had heard Shara speak about and filled out the first section of the guide questions associated with the “empathy” stage of the design thinking process.

We took a quick walking field trip to each location and the students finished the “define” phase, where they articulated exactly what was needed and what the constraints were, and moved into a brainstorming “ideation” phase.  Students were tempted to think there was just one type of solution to the selfie station problem, but they sketched out three different ideas. When this was finished they chose a “prototype” design they wanted to build and they wrote out a mini grant proposal.  

When the proposal is complete, we submitted it to the Upward Bound director for approval.  We prepared ahead for this type of project with wires, and buttons and extra raspberry pi devices with cameras and power supplies.  After the proposal was approved we handed out and checked off the items that had been requested on each proposal. The students got right to work building the prototype selfie stations.

We instructors restrained ourselves from helping too much and let the teams figure out how to build their designs.  When students would ask for help, we would respond with a question.  Eventually, the students learned to frame their questions in such a way as to be able to google the answer.  We helped in the areas where a skill had not been introduced, such as soldering, or learning to “remote” into the pi.  The teams were responsible for building the prototype, writing the code that controlled it, and recording and editing a short video.

Several days later, Shara met with us to see the results. The students walked around the campus with her demonstrating the way their selfie stations worked and noting what things could be improved. One team had an opportunity to radically modify their design because it didn’t take into account the safety considerations necessary when a crowd of students would moving past a certain area.

The students were beaming when Shara thanked the group.  She appreciated their efforts and asked them to sign their work so that new students at the school knew who had built these stations.  Each group modified and perfected the design and the instructions.

As part of the initial mini grant application, The teams had been responsible for writing user instructions, making a video about the project and writing a short report about the progress of the project. 

Setting up Node Red for a Selfie Station

Here is the Node Red setup for a Selfie Station where a button is pushed, a LED light ring turns on, a photo is taken, which is then emailed to a dedicated email.  Its very similar to this project that was done by teams of students at UH Hilo.

Step 1.  Set up the light ring so that it turns on and off after a message is sent:

In this case – we wanted the light ring to turn on with the color red, and then turn to a different color white and then turn off.  To achieve this we used a trigger node.  The first one was set to 8 seconds.

The second trigger node was almost identical, except that the “send” command was white, and the “then send” command was black.

Step 2.  Connect the camera node with a delay:  In this case we chose 9 seconds because it was in the middle of the time when the light ring is white.  When the signal is sent – the light rings should go off and then the camera light should come on.

You will want double click on the camera node and change the file mode from generate to buffermode. You can also change the properties of the photo here.

Step 3.  Check that you ended up getting your photo by looking in the pictures photo on your pi.  Grab the send email node from the sidebar.

Move the email node after the photo node.

You will want to have a special gmail that you have set up to receive emails from node red.  We set up one that was named especially for the project.  Once you are logged in to the account you will need to follow the link for getting emails from “less secure sources.”  The screen you will get to after being logged into the gmail account looks like this: You will want to toggle the button to allow less secure apps.

Open the properties tab for the email node – enter the new email you just created and made less secure into the who “To” field.  Enter the email that you want the data to be sent from into the “Userid” field.   This does not need to be a “less secure” email.  It could even be an email with the specific name of the pi where it will be placed.

Test it out and check your email to see that it worked.  

Step 4: Switch the input to a button (or any other trigger device).  We used a button and connected one side to 5v power, and the other side to GPIO12. Set the resistor to “pulldown” and check the box for read initial state of pin on deploy.

When its working a push of the button should change the “0” to a “1” right below the pin node.  When the button is released it should change back.  Connect up the nodes and push a button to take a photo and send it!

 

The button can be swapped out for a different type of sensor such as the PIR or sonic motion sensor, just be careful that the sensitivity isn’t set too high, or else you could find yourself with a lot of emails!

If you actually want to set this pi up somewhere (like we did in this project) you will want to configure it to auto start Node Red when the pi is powered on.  As long as the pi is in an environment where it has permission to log into the wifi, it should work.

 

RPi Node-Red Auto Start

When deploying a Raspberry Pi as a permanent/semi permanent installation is will be useful to have Node-Red start persistently, in the case of power failure, etc.

Open a terminal and paste the following command

sudo systemctl enable nodered.service

Now Node-Red will start automatically when the Raspberry Pi boots up.