pip install Flask pyserial threading jsonify
Python version 3.11
After flashing the Raspberry Pi OS onto an SD card using tools like Etcher, follow these steps to set up your Pi for headless access (without a monitor).
To enable SSH access:
- Create an empty file named
ssh
(with no file extension) and place it in the root directory of the boot partition.
Note:Make sure the wifi you are using is 2.4 GHz since the pi only supports 2.4 GHz
If you want your Raspberry Pi to connect to your WiFi network on boot:
- Create a file named
wpa_supplicant.conf
in the root directory of the boot partition. - Add the following content, replacing with your actual WiFi details:
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOUR_WIFI_SSID"
psk="YOUR_WIFI_PASSWORD"
key_mgmt=WPA-PSK
}
Ensure to replace YOUR_WIFI_SSID
and YOUR_WIFI_PASSWORD
with your WiFi credentials. If you're not in the US, adjust the country
field accordingly.
- Ensure you safely eject the SD card from your computer.
- Insert the SD card into the Raspberry Pi and power it on.
- After it's booted up, you can access your Raspberry Pi via SSH from another computer on the same network using:
The default password is raspberry
.
For enhanced security, it's recommended to change the default password to something unique. You can generate a secure password hash using:
echo 'your_password' | openssl passwd -6 -stdin
This command will provide you with a hashed version of your password. Use this hash when setting up password authentication in relevant configuration files.
This README guides you on how to manage and monitor the Humidity Control Arduino service running on a Raspberry Pi. You can both use the screen
method to run it interactively and the systemd service to run it as a background process.
sudo apt-get update
sudo apt-get install screen
-
SSH into your Raspberry Pi:
ssh raspberrypi@raspberrypi.local
-
Start a new
screen
session named "arduino":screen -S arduino
-
Run the script:
sudo python3 web_server.py
-
Detach from the
screen
session withCTRL
+A
followed byCTRL
+D
.
If you want to see the live output or interact with the running script:
screen -r arduino
humidity-control.service
should already be in the directory
sudo systemctl start humidity-control.service
sudo systemctl stop humidity-control.service
sudo systemctl restart humidity-control.service
sudo systemctl status humidity-control.service
Follow these steps to install, set up, and use the arduino-cli
on the Raspberry Pi to compile and upload sketches to your Arduino board. The use of this is to be able to change or upload new arduino sketches from ssh. Make sure you are ssh'd into the Pi.
Download and install the arduino-cli
:
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
Append the installation directory of arduino-cli
to your ~/.bashrc
:
echo 'export PATH="$PATH:/home/krypgrund/krypgrund/bin"' >> ~/.bashrc
Reload your ~/.bashrc
:
source ~/.bashrc
Initialize a new configuration file:
arduino-cli config init
Fetch the latest list of available platforms:
arduino-cli core update-index
(Note: Additional instructions to be added based on the specific core or other requirements.)
- Start with a fresh install of Raspberry Pi OS (formerly Raspbian) on your Raspberry Pi.
-
Once you've booted up, connect to your Raspberry Pi either directly (using a monitor, keyboard, etc.) or SSH into it using its default hostname:
ssh pi@raspberrypi.local
Default password is usually
raspberry
.
-
Once connected, edit the
hostname
file:sudo nano /etc/hostname
- Replace the default name
raspberrypi
with your desired name. For this guide, we'll usekrypgrund
which means "crawlspace" in Swedish, you can use any name you like.
- Replace the default name
-
Next, update the
hosts
file:sudo nano /etc/hosts
- Find the line that reads
127.0.1.1 raspberrypi
and changeraspberrypi
tokrypgrund
.
- Find the line that reads
-
For the changes to take effect, reboot the Raspberry Pi:
sudo reboot
-
After the reboot, you can now SSH into your Raspberry Pi using the new hostname:
ssh pi@krypgrund.local
Remember to use the password you've set previously.
- Your Raspberry Pi is now accessible via the new hostname
krypgrund.local
.
-
Start by SSHing into your Raspberry Pi using the default credentials:
ssh pi@krypgrund.local
Default password is usually
raspberry
.
-
Once logged in, add a new user called
krypgrund
:sudo adduser krypgrund
- Follow the prompts to set a password and provide any additional information (or just press enter for defaults).
-
To ensure the new user can perform administrative tasks, add them to the
sudo
group:sudo usermod -aG sudo krypgrund
-
Before making any further changes, SSH into the Raspberry Pi using the new user to ensure everything is working:
ssh krypgrund@krypgrund.local
Enter the password you set for
krypgrund
when prompted.
-
For security reasons, it's a good idea to disable the default
pi
user once you're certain your new user works:sudo passwd -l pi
This locks the
pi
account.
-
You've successfully changed the default SSH user. Now you can log in with:
ssh krypgrund@krypgrund.local
Follow these steps to set up Dynamic DNS on your Raspberry Pi, which will keep your network accessible through a fixed hostname despite a changing public IP address.
- A Raspberry Pi running Raspberry Pi OS
- An internet connection
- A DDNS account (e.g., No-IP)
Ensure your Raspberry Pi is up to date:
sudo apt update
sudo apt upgrade
Install the ddclient
package:
sudo apt install ddclient
Install the ddclient
package:
sudo nano /etc/ddclient.conf
Add your DDNS service configuration:
protocol=dyndns2
use=web, web=checkip.dyndns.com/, web-skip=/"IP Address"/
server=dynupdate.no-ip.com
login=your_noip_login
password=/your_noip_password/
your_noip_hostname
Make sure to replace your_noip_login, /your_noip_password/, and your_noip_hostname with your actual No-IP credentials and hostname.
Enable ddclient
to start on boot:
sudo systemctl enable ddclient
Start the ddclient
service:
sudo systemctl start ddclient
Force an immediate update with:
sudo ddclient -force
Start the ddclient
service:
Review the ddclient
logs if needed:
grep ddclient /var/log/syslog