Setup a simple weather station with eGeoffrey
-
Let's assume your eGeoffrey is installed and ready to rock. A first, simple use case to start with is for sure making up something around the weather.
But we don't want to start from scratch so let's see which packages from the eGeoffrey marketplace can help us with this use case:
$ sudo egeoffrey-cli search weather egeoffrey-service-dht: Retrieve temperature/humidity from a DHT11/DHT22 sensor egeoffrey-service-ds18b20: Retrieve temperature from a ds18b20 sensor egeoffrey-service-fcc_weather: Retrieve weather information from Free Code Camp Weather API egeoffrey-service-openweathermap: Retrieve weather information from OpenWeatherMap egeoffrey-service-weatherchannel: Retrieve weather information from weatherchannel
Ok, some of those require physical sensors attached to our raspberry but let's start from something simple. The
egeoffrey-service-fcc_weather
gives us basic weather information for a specific location (by providing latitude and longitude) without the need to deploy any physical device or requesting third-party API tokens. Let's install the service:$ sudo egeoffrey-cli install egeoffrey-service-fcc_weather egeoffrey-service-fcc_weather:master installed successfully
Let's start it with:
$ sudo egeoffrey-cli start
And ensure it is running fine, looking for "Up" nearby the service name:
$ egeoffrey-cli status Name Command State Ports ---------------------------------------------------------------------------------------------------------------------------------------------------- demo_egeoffrey-controller_1 sh docker-entrypoint.sh eg ... Up demo_egeoffrey-database_1 docker-entrypoint.sh redis ... Up 0.0.0.0:6379->6379/tcp demo_egeoffrey-gateway_1 sh docker-entrypoint.sh mo ... Up 0.0.0.0:1883->1883/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:8883->8883/tcp demo_egeoffrey-gui_1 sh docker-entrypoint.sh eg ... Up 0.0.0.0:80->80/tcp demo_egeoffrey-service-fcc_weather_1 sh docker-entrypoint.sh eg ... Up
If we connect to eGeoffrey web interface we can now see under the section "Examples" a menu item called "FCC Weather Service". Let's click on it. This example will show up weather information for New York City. The way this page is formatted is pretty simple and you can reuse the same approach for visualizing other sensors' information which are timeseries-based:
- You have on top the latest value for each measure and its timestamp
- A summary widget showing the current measure, minimum/maximum measures from today and yesterday
- A timechart with the latest measures (last few hours)
- A timechart with hourly aggregations with average, minimum and maximum value for each hour
- A timechart with daily aggregations with average, minimum and maximum value for each hour
What is there under the hood? The package just installed includes examples of sensors, pages and rules we can review, customize and take inspiration from to build our own weather station.
Let's go to "House" / "Sensors". Here we can see 5 sensors created for us, each one storing a specific information (temperature, humidity, weather condition, pressure, etc.).
If you click on "Actions" / "Edit Sensor" you can see that each one has:
- a format for the data depending of the value the sensor is supposed to store ("float" for temperature, "int" for pressure, "string" for weather condition", etc.)
- Since all of those measures are timeseries, there is an automatic aggregation configured to calculate every hour average, minimum and maximum values from the collected measures; every day average, minimum and maximum from the hourly averages. In this way we will be able to plot in a chart both latest measures, hourly and daily averages/min/max without further effort
- For the same reason explained above, there is a retention policy set to retain values for 5 days, hourly averages for 5 days and daily averages forever. In this way our database will not grow up too much since we will only keep aggregated averages/min/max values for historical data
- All of the sensors are associated to the fcc_weather service which is pulling, every 10 minutes, new measures. Which measure is pulled, is configured in the "Configuration" tab and is different sensor by sensor. Latitude and Longitude are of course instead always the same across the sensors to make it consistent
If we now go to "House" / "Rules", we can see a bunch of sample rules have been automatically added by the package:
- The first one is alerting us whenever the humidity is too high (the threshold in the example is set to 80). If you click on "Actions" / "Edit Rule", you will notice this is running every 60 minutes, retrieve the latest value from the humidity sensor and check if above the threshold
- The second rule will just summarize the current status with today's minimum maximum and average temperature (as you can see it is referencing the temperature sensor and adding the notation /day/avg, /da/min /da/max respectively - this is what the automatic aggregation mentioned earlier is doing automatically for us).
The latter rule is configured not to be scheduled but to run on demand. What does it mean? It means it will trigger only if one of the interaction modules or the embedded eGeoffrey chatbot believes your question or request is related to that rule. For example if you go to the "Welcome" page, down below you can see the chatbot ready to serve you. Try asking something like "what is the temperature today?" (it doesn't need to be spelled correctly) and you will get straight away an answer. This answer is coming to that rule but can come from any sensor as you can see below:
From now on we can customize whatever we like. For testing purposes, feel free to modify the sensors, rules and page we have seen above. Of course keep in mind that whenever the package will get upgraded, you may lose your changes. Take instead inspiration from those to create you own sensors and pages.
What if one day you will decide that e.g.you what to get the temperature from a DHT11 sensors instead of the Internet-based service? Simple, just install the eGeoffrey module you need (in this case
egeoffrey-service-dht
), edit your existing temperature/humidity sensor and associate them to the newly installed service. In this way your presentation layer will stay the same, your historical data will be kept but the new service will start pushing new measures in.Enjoy!
-
I just installed it. Looks very good. I will be using this as a template for my own local station.
Maybe it would be good to adapt the terminal orders by preceding them with "sudo".
-
@eporocrail said in Setup a simple weather station with eGeoffrey:
Maybe it would be good to adapt the terminal orders by preceding them with "sudo".
Good advice, done!