- Gather parts.
- Set up Node-RED on the main Raspberry Pi and register it with Amazon Echo Dot
- (Optional) Headless WiFi setup for Raspberry Pi Zero W (This article)
- Copy IR remote codes with Raspberry Pi
- Call IR functions from Node-RED to control the TV
- Control Arduino via HTTP API using FlashAir GPIO mode
- (Bonus) Control Roomba from Arduino via ROI serial interface
- Control Roomba from Node-RED via FlashAir/Arduino
IR control inherently requires a device close to each appliance.
For that use case, the requirements are:
- Cheap — you need one per appliance.
- Unobtrusive — bare PCBs scattered around the house look rough.
- Minimal wiring — wireless is essential; power via USB cable, no AC adapter.
Raspberry Pi Zero W hits all three criteria.
The catch: the Raspberry Pi Zero W uses micro HDMI and micro USB, making initial setup cumbersome with cables everywhere.
So let's set it up without a keyboard or monitor.
Write the OS Image to a microSD Card
Download the OS image from the official Raspberry Pi site.Choose "LITE" — not DESKTOP. If you want a GUI, headless setup defeats the purpose.
On Mac or Linux, write the image with:
$ df
$ unmountDisk /Volumes/NO\ NAME
$ dd bs=1m if=~/Downloads/2018-03-13-raspbian-stretch-lite.img of=/dev/disk2
Use df first to confirm the device name assigned to the SD card.Then specify that name as the of option in the dd command.
Getting the device name wrong will wipe the wrong drive — be careful.
On Mac, after a successful write, the boot partition is automatically mounted at /Volumes/boot.
On Windows, it will likely appear as drive F: or similar.
Adjust "/Volumes/boot" in the following steps as appropriate.
Configure WiFi
Place a WiFi config file on the boot partition:$ echo '
country=JP
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="{your-wifi-ssid}"
#psk="{your-wifi-password}"
psk={encrypted-wifi-password}
}
' > /Volumes/boot/wpa_supplicant.conf
"country" is the country code — omitting it causes WiFi configuration to fail at boot.The network block values can be generated using Raspbian's wpa_passphrase command — but only if you already have a working Raspberry Pi set up:
$ wpa_passphrase {SSID} {PASSWORD} >> wpa_supplicant.conf
Enable SSH
Recent versions of Raspbian disable SSH by default.To enable it at boot, create an empty file named "ssh" on the boot partition:
$ touch /Volumes/boot/ssh
That's all the configuration. Eject the microSD and insert it into the Raspberry Pi Zero W.Boot
Power the Raspberry Pi Zero W via the micro USB port to boot it.The LED may not light up initially.
No LED = not broken — it means no bootable OS was found on the microSD (write failed).
LED glows red = OS is present but boot failed.
Yellow-green blinking that settles into steady on = success.
If you remount the microSD on your PC after booting, you'll notice that wpa_supplicant.conf and the ssh file are gone from the boot partition.
This is normal — they get moved to /etc and deleted during a successful boot.
If they're still there, something went wrong during boot.
Connect via SSH
Once booted, connect from your PC via SSH.Raspberry Pi Zero W gets its IP from DHCP, so the easiest way to find it is to check your router's client list.
Current Raspberry Pi Zero W units have MAC addresses starting with "B8:27" — filter by that to find the newly assigned IP.
Once SSH works, setup is done. Do whatever you like from there.
Assign a static IP in your router to avoid the IP changing on you.
No comments:
Post a Comment