So I am planning to host a discord bot on a raspberry pi zero w and I do have a spare monitor( for the programming part), but the monitor wouldn't work when I plug it in and I also don't have one of those mouse+keyboard things, so I have done a bit of research and I have seen many headless setups on youtube, but how do I program it, can I do it with a USB connected to my mac or over wifi, I am open to any suggestions thanks in advance.
2 Answers
You can easily program your Raspberry Pi Zero W
via SSH. Should be configured Wi-Fi connection and SSH to be enabled.
Follow the next steps:
choose Interfacing Options and set SSH enable. This will help to connect to Raspberry Pi via SSH.
After that, go back and go to Network Options and choose Wi-Fi. Fill name and password of the Wi-Fi.
SSID
- name of your Wi-Fi,Password
- password to it.To be sure, that all configuration work as expected - reboot your Raspberry
sudo reboot
- Next, need to understand the ip address of the Raspberry to connect to. For this, you should write:
sudo ifconfig
and you will see. In this picture ip-address is192.168.0.104
- Connect via SSH to [email protected].
If you have any questions - see full description here.
-
1Nice answer. But you may not need the IP address as
ssh [email protected]
should work out of the box on Mac and GNU/Linux. Commented Mar 24, 2019 at 7:54 -
Really? I haven't used it before. Can it be used in the case when I have more than one raspberry?– romankh3Commented Mar 24, 2019 at 8:50
-
Please don't use images for text output. Instead paste the text direct into the answer.– IngoCommented Mar 24, 2019 at 16:14
-
-
1No, but if you change the Pi's hostname the part between
@
and.local
will change to match so you can just rename your Pi's. It can be persuaded to work on Windows as well but you need to make it aware of mDNS/Bonjour/ZeroConf stuff first. Commented Mar 25, 2019 at 8:43
You can easily program a Raspberry Pi over SSH. I guess you've already seen in headless setups how to configure your RPi to connect to your WiFi network and enable SSH. If not, here is a quick how-to:
Setup headless RPi
Add an empty ssh
file in /boot/
directory
Inside the rootfs
partition, edit the /etc/wpa_supplicant/wpa_supplicant.conf
file so that it looks like this
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YourWiFiSSID"
psk="yourSecretWiFipassword"
}
Here's the official documentation on how to setup WiFi.
You can connect to your RPi from your mac over an SSH session. Once inside, in the terminal you can use a text editor (nano is the default one but you could download something else. I like vim.) to write your programs. Then you can run them in your SSH terminal.
Here's a quick overview of SSH.