So, you want to run the Weather Station automatically when your Pi boots up? There are two options here -if you want to use your Pi at the same time, go to Step 1. If you only want your Pi to function as a weather station, then skip Step 1 and go straight to Step 2.
1. Make your Pi boot straight to the desktop
In LXTerminal, run:
The screen should change to this:
Use the keyboard keys to scroll down and press enter when “
Enable Boot to Desktop/Scratch” is selected. Navigate to “
Desktop Login” and press enter to select it.
You should be back on the original raspi-config screen now. Use the keyboard keys to go right to “
finish” and press enter to go back to the normal LXTerminal screen. Now you can reboot the Pi – it may ask you if you want to do this, but if not you can use
sudo reboot – and check that it boots to the desktop screen properly
2. Check that your details are available
Like Thermo_Station.py, Autorun_Station.py (the run-at-start weather station script) automatically accesses your saved user data (such as AWS Key, Plot.ly username, and WOW Site ID. Unlike Thermo_Station.py, though, it will not check and prompt for input if user details are missing. You will need to check if they are there and correct, either by going to the details.ini file in the Sheffield-Pi-Weather-Station folder in your file manager (as shown in the picture below), or by running:
If you have run Thermo_Station.py already there is no need to do this step, as your details should already be saved.
3. Copy the Autorun_Station daemon to init.d
A “daemon” is just a background process that handles requests for services and then is dormant when not needed. In this case the file
Autorun_Station.sh is the daemon that will start up the weather station in the background. The following code should be on one line:
sudo lets the Pi know that it should run this with root privileges, the
cp is telling the Pi to copy the file, the next part is the place where the file is (called the “path”), and the last part is the place where the file is to be copied to.
4. Make the Weather Station auto-run file and daemon file executable
This is done by running this code:
5. Make the script run at boot.
This can be done by running this code, which puts the Autorun_Station daemon into folders which the Pi checks at boot and shut down to see if jobs need to be done.
6. Start and Stopping the process
As we’re running it at boot via a daemon, it should automatically start when power is plugged in, without needing to plug the Pi into a monitor. However, if you need to stop or start it while the Pi is on, you can use the relevant line of code below:
These result in the following outcomes:
7. Check if your station runs automatically
sudo reboot to check if your weather station will run. You can look at the Plot.ly site or Weather Observations Website to see if your data uploads. Alternatively (and this method only checks to see if the script is running, not if your data is being uploaded.:
This code checks to see Python processes that are running. If your weather station is working then it should be shown, like this:
As you can see, the Autorun_Station script is running and, hopefully, uploading your data!