Raspberry Weather application
Android users now have the option of using a native application named My Weather Station. It can be modified to connect to your newly built weather station and display the readings. The saved data can be shown in a graph or a list, regardless of the type of sensor you are using. It is also free of charge and works on phones and tablets, regardless of the Android version.
Saving the readings in a database must already be set up.
If you have already built the basics (saving read information from the sensor) you now have to set up an XML file. It will contain the readings and the time at which they were taken. This file is read by the application and the readings are displayed. First, you have to get the code from github. Navigate to the folder that contains the getInfo.py script, type in the following command to move in the correct folder
cd /root/Raspberry-Weather. Next, you need to download the code with
wget https://raw.githubusercontent.com/peterkodermac/My-weather-station-generator/master/createXml.py. Before continuing forward, make sure that this script is executable with
chmod +x createXml.py. It is very important that createXml.py is in the very same folder as getInfo.py!
For the final touch, you need to modify the getInfo.py script a little bit, open it with
nano getInfo.py and move to the very last line. You need to add a single line, that will tell the script to run createXml.py when it is finished. Paste e
subprocess.call(os.path.dirname(os.path.realpath(__file__))+"/createXml.py %s %s %s" % (databaseUsername,databasePassword, databaseName), shell=True) in the very end of the file. When the getInfo.py script is finished, this line makes sure that the newly downloaded script is run. Now you need to check if everything is working as it should. Run the command python getInfo.py. You will see the measurements printed out and the createXml.py should be called. It will generate a file in your
/var/www/ directory. Visit your webpage and output.xml in the end, for example
raspberryweather.com/output.xml. You should get the values from the database in XML format. If you get a 404 error, then the file is not generated in the correct location. Otherwise, you are ready to modify the My Weather Station app to your needs!
Download it from Google Play to your Android device. After the initial intro navigate to the settings using the slider menu on the left. Change the output path accordingly and edit other values as you wish. Do not worry, you can change all of them anytime. Visit the first two options and you should be presented with a graph and all of the readings in a list. The graph can show you detailed information about a reading if you press on the displayed point.