Weather Station Project: Lesson 9

weather station project with raspberry pi lesson 9

Line charts

Line charts are used to represent trends in data over time. That describes the information we are collecting. The sensor takes temperature and humidity information at set intervals. That interval is currently every thirty seconds.

We need to select two columns of data. The first will be the time. The second will be the temperature in celsius. We will create charts for Fahrenheit and humidity later.

We don't need to represent all the readings in our chart. For this chart, we will take the first 24 readings. Click on the time heading and drag the mouse down the column to row 25.

time column selected

Move the mouse over to the adjacent column and select the corresponding celsius data.

time and temperature information selected

Click Insert on the menu. Go down the list of options and select Chart.

select chart from the menu

Google will attempt to select a chart type for us. In my example, it chose a bar chart. 

bar chart created from data

A panel opens to the right of the spreadsheet. This panel is used to edit and configure chart settings. Click the Chart type selector. Choose the first line chart option.

chart type selector

The chart isn’t much to look at now. This will change when we modify the sensor reading interval. The temperature readings are on the left. 

temperature readings on y axis

The chart shows a blue line at the bottom. This represents the time intervals. Go to the panel. Click Use column C as labels.

use column c as labels option

The time intervals appear on the x-axis.

time intervals appearing on x-axis

Click the Customize tab in the Chart editor panel.

chart customize tab

Click the chevron next to Chart & axis titles.

chart and axis titles access

Title the chart, Daily Temperature Data.

updated chart title

The title appears at the top left on the chart.

title on chart

Click the text alignment selector and choose center-align.

title formatting with center align

Click the title selector and choose Chart subtitle.

chart subtitle option

The subtitle is Sensor Readings from Raspberry Pi DHT11 sensor. Change the text alignment to center.

chart subtitle alignment

Go to the title selector and choose the Horizontal axis title.

horizontal axis title selected

Set the title to Time. Align the text to the left.

title alignment option

Select the Vertical axis title option.

vertical axis title

Set the title to celsius.

vertical axis title set to celsius

Click the chevron again to collapse the section.

titles section collapsed

The tile labels don’t show every time reading. It would be convenient to have all the readings. Open the horizontal axis section.

horizontal axis section information

Click the option to treat the labels as text. The labels are fitted within the horizontal axis.

time labels fitted in chart

The data in the chart is from the first day when we began accepting readings. New readings are appended to the end. Today’s sensor readings are at the bottom of the sheet. We need to filter and sort the sensor data.

Today’s Temperature

To display the temperature for the current day we need to filter the data. We do this within the query function.

We are going to create a new sheet for this chart. Click the Plus button to create a new sheet.

create new sheet button

Double click the sheet name and change the name to Today’s Temp.

sheet renamed

Inside of Cell A1, we will query the data. We only need the time and temperature information. 

Type =query(‘sensor data’!B1:E,”select *”,1)

query function

The name of the sensor data sheet is in single quotes. This is necessary because there is a space in the sheet name. The data range begins on cell B1. This is where we have the date information. The data in column E contains the temperature information in Fahrenheit. Using the column notation without a number after E selects every cell in columns B,C,D and E. Replace -1 with 1. 

queried data

To get the readings from today, we need to modify the query. Click on cell A1. We are going to use the Formula Bar to edit the query. Place the cursor after the asterisk.

query in formula bar

Add this parameter to the query after the asterisk. 

Where B = date ‘“&text(today(),”yyyy-mm-dd”)&”’

This parameter instructs the query to use today’s date as the filter. The filter looks in column B. If there is data for today’s date, then it is listed.

It may look like there are three single quotes after date. It is a single quote followed by a double quote. The order is reversed after the ampersand

date parameter

There is a lot of new stuff going on here so I’ll go through the parameters. We are instructing the query to select everything in the columns where the contents of column B match today’s date.

The single quote and quotation marks are like parentheses. The single quotes surround quotation marks and the parameters. The date for today is represented as text in the form of year, month, and date. 

updated query and data

Today’s Temperature Chart

We spent some time customizing the chart earlier. We will use this same chart for our new sheet. Go back to the sensor data sheet. Click once on the chart. Click the three dots in the upper right corner. This is called the action menu. Select the option to copy the chart.

copy chart

Go back to Today's Temp sheet. Click Edit and select paste.

paste chart

Click the chart action menu and select the Edit chart option.

action menu edit chart

Click in the Data range field. Erase the data range.

old data range information

Replace the range with B2:C25.

updated range information

This chart represents the temperature in celsius. We will use another chart to represent the Fahrenheit temperature information.

chart for celsius data

Make a copy of the current chart. Click the actions menu and select Copy chart. Click edit in the Google Sheets menu and select paste. 

copy of celsius chart

Click the actions menu on the duplicate chart and select Edit Chart.

edit the chart copy

Erase the data range. The data for this chart spans two separate columns. Those columns are not next to each other. We need to select the columns separately. Type B2:B25,D2:D25. Note that the selections are separated by a comma.

updated range for chart

Go to the Customize section of the Chart editor. Open Chart & axis titles. Select the Vertical axis title. Change the title from Celsius to Fahrenheit.

The titles are looking a little bland. This makes it difficult to distinguish. Change the chart color to help identify the charts. Go to the Chart style. Click the background color selector. Choose a light color for the background. A light color will help keep the text on the chart legible.

chart background color

Repeat the process with the chart with the celsius information.

celsius and Fahrenheit charts with different colors

Humidity Chart

The chart to report the humidity information is similar to the temperature chart. Click the Plus button to create a new sheet. Rename the chart to Today’s Humidity.

Let's take a look at the sensor datasheet. The humidity data is in column F. We will query the data from columns B, C, and F.

sensor information data

Go back to the Humidity sheet and enter this query.

=query(‘sensor data’!B1:F,”select B,C,F”,1)

query in new sheet

The select parameter is used to choose the columns of data to display. 

We are going to filter the data so only the current day’s humidity information is displayed. We will use the same parameter used for Today’s temperature reading. 

Use the Formula bar and place the cursor right after the letter F. Add this parameter. 

Where B = date ‘“&text(today(),”yyyy-mm-dd”)&”’

filter for today’s date

Today’s Humidity Chart

Go to Today's Temp sheet. Choose one of the charts. Click the actions menu and select Copy chart. Return to Today's Humidity sheet and paste the chart. Click the chart action menu and select Edit chart. Erase the current data range. Replace it with B1:C.

Go to the Customize tab in the chart editor. Open the Chart & axis titles. Select the Vertical axis title. Change the title to Percentage.

Select the Chart title. Change the title to Today’s Humidity.

Open the Chart style section. Change the background color.

humidity chart
Previous
Previous

Google Docs Templates

Next
Next

Weather Station Project: Lesson 8