This walkthrough covers setting up Raspbian and Node-RED from that starting point,
and ends with reading DHT11 sensor values in Node-RED and sending them to the cloud.
Parts
Amazon
Raspberry Pi 3B+ starter kit with NOOBS-preloaded SD card.
Everything hardware-wise is included, but there's a setup step before Raspbian is running.
Everything hardware-wise is included, but there's a setup step before Raspbian is running.
Amazon
Cheap mini breadboards — comes in a pack of 6.
You won't need six, but this is what's available.
You won't need six, but this is what's available.
Amazon
DHT11 temperature and humidity sensor.
Has an ADC built in, making it a good first sensor to work with.
Note: working with it in Node-RED requires installing an extra library.
Has an ADC built in, making it a good first sensor to work with.
Note: working with it in Node-RED requires installing an extra library.
Amazon
5-color LED pack — 100 pieces.
Enough to build a marquee sign, but buying small quantities isn't any cheaper, so bulk is the way to go.
Not related to DHT11 — used for GPIO sanity checks.
Enough to build a marquee sign, but buying small quantities isn't any cheaper, so bulk is the way to go.
Not related to DHT11 — used for GPIO sanity checks.
Amazon
Resistor assortment — 600 pieces.
More is better.
More is better.
What is NOOBS?
NOOBS is a set of files written to an SD card that launches the Raspbian installer on first boot.Other operating systems can also be installed via NOOBS, but Raspbian works without a network connection.
Download the original NOOBS files here and write them to an SD card from Windows or Mac in advance.
(If you bought a kit, this is already done.)
Note: installing Raspbian from NOOBS takes about an hour.
Installing Raspbian via NOOBS
Pre-writing configuration files to the SD card allows headless (no-monitor) Raspbian installation.This blog explains the process in detail:
Tom's Hobby: "Raspberry Pi NOOBS — Pre-configure WiFi, VNC, etc. before installation"
For the NOOBS installation steps themselves:
"Getting Started with Raspberry Pi NOOBS (2017 Edition)"
Configuring WiFi and Enabling SSH
Writing config files to the Raspbian SD card from Mac or Windows lets you continue setup without connecting a monitor to the Pi.● On Mac:
"Headless WiFi Setup for Raspberry Pi Zero W"
● On Windows:
Write the same two files as in the Mac guide:
(1) {SD card drive letter}\boot\wpa_supplicant.conf
Easiest approach: copy /etc/wpa_supplicant/wpa_supplicant.conf from a configured Raspberry Pi.
country=JP
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="{your WiFi SSID}"
#psk="{WiFi password}"
psk={encrypted WiFi password}
}
(2) {SD card drive letter}\boot\sshCreate an empty file with exactly this name.
● If you have a monitor connected during setup:
"Raspberry Pi 3 with LCD Monitor as an All-in-One PC"
Enable SSH by running sudo raspi-config → "5 Interfacing Options" → SSH.
Connecting to Raspberry Pi via SSH from Windows
First, find the Raspberry Pi's IP address from its terminal:$ ifconfig
For frequent SSH use on Windows, install TeraTerm.
For a one-off connection, the built-in Command Prompt works fine:
(1) Open Command Prompt (search "cmd" in the taskbar).
(2) Run:
ssh pi@{Raspberry Pi IP address}
(3) Accept the host key prompt on first connection.(4) Default password for the pi user: raspberry
Change the Password
Leaving the default password in place on a public WiFi is a quick way to get compromised.(Not that you should connect a Raspberry Pi to public WiFi in the first place.)
Change it with:
$ passwd
Setting Up Node-RED
At this point you can control Raspberry Pi from the command line.Setting up Node-RED lets you define behavior from a browser interface.
Recent Raspbian versions include Node-RED by default, but it may be outdated — updating is worth considering.
For Node-RED setup, the short version is just this one command over SSH:
$ bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
LED Blink Test with Node-RED
As a sanity check for Node-RED and GPIO, start with an LED blink.(LED blink = the "Hello World" of hardware.)
Plenty of detailed guides are out there — this one is a good reference:
oh-maker: "LED Blink with Raspberry Pi and Node-RED"
Using DHT11 in Node-RED
With GPIO confirmed working, connect the DHT11.Getting values from DHT11 requires a bit of setup via SSH (or a local terminal).
This blog explains the configuration clearly:
EPIPE: "Temperature and Humidity with Raspberry Pi + Node-RED + DHT11"
For how to wire the nodes in Node-RED:
IoT Hands-On with Raspberry Pi (NIC)
GPIO pin numbers are documented on the official Raspberry Pi site:
GPIO — Raspberry Pi Documentation
Sending Temperature Readings to the Cloud from Node-RED
The email node in Node-RED's "social" palette makes it easy to send emails.It defaults to Gmail's SMTP server, so just enter your Google account credentials.
For more ambition, you can send to Twitter — though that requires getting Twitter API keys first.
Qiita: "How to Get Twitter API Keys (Updated)"
Sending Twitter direct messages from Node-RED is covered here:
Qiita: "Notes on Sending Twitter DMs from Node-RED"
No comments:
Post a Comment