Categories
Beeruino Uncategorized

How-To process the raw Beeruino data using R

One of the first things after getting the Beeruino working, is to leave it running in your brewing environment where fermentation will take place.

Let it capture a few weeks worth of data, maybe even during different seasons, then learn how to process the data and finally display it in a more informative plot.  Plots allow the human eye to makes sense of all the data and what happened during the fermenation much easier than looking at some bunch of summary statistics.

R code is below with comments, enough to get you started…

# download R and RStidio and install for your computer in that order...
# https://www.r-project.org/
# https://www.rstudio.com/

# install all the packages and load them up
install.packages(c("lubridate","tidyverse","dyplr","ggplot2"))
library(lubridate)
library(tidyverse)
library(dplyr)
library(ggplot2)

# see what your working directory is, you can set using the setwd()
getwd()

# move the data to a working directory on your computer and read it into a data.frame
BeerData = read.csv(file="./beer_analysis/FILE01.TXT", header=FALSE, sep=",")

# select every 10th row, since Data log samples were taken every 20 seconds, this is too much data to display in a plot!
# you can make less data from more, but not more from less 
BeerData2 = BeerData[seq(1, nrow(BeerData), 10), ]

# give the columns more meaninfull names 
BeerData2 = rename(BeerData2, COUNTER=V1,HEAT_INDICATOR=V2,EXTERNAL_TEMP=V3,INTERNAL_TEMP=V4,DATE_TIME_STAMP=V5)

# head allows you to take a quick look at the data
head(BeerData2)

# summarise and average the internal/external temperatures by Hour and Day using dplyr and chaining...
byhour = clean %>% 
  mutate(date = as.Date(DATE_TIME_STAMP),
         hour = hour(DATE_TIME_STAMP)) %>% 
  group_by(date, hour) %>% 
  summarise(mean_int = mean(INTERNAL_TEMP),
            mean_ext = mean(EXTERNAL_TEMP))


# Set up the Axis from the Y Variables since we have more than one
ext = byhour$mean_ext # externate temp.
int = byhour$mean_int # internal tepp.

# plot it
ggplot(byhour, aes(date, y=sensor_temperature, color = variable)) + 
  geom_point(aes(y = ext, col = "ext")) + 
  geom_point(aes(y = int, col = "int")) +
  geom_smooth(aes(y = ext, col = "ext")) + 
  geom_smooth(aes(y = int, col = "int")) 

# the plot displays a scatter of the averages temp values for each distinct date using the dots
# it then plots a smooth line of the averages

# in this example you can see that the sensors are not caribrated, but even so they follow each other...
  
# beyond this point - you have to learn R on your own - it takes time but its worth it, good luck!

This plot clearly displays that the internal and external temperature sensors are not calibrated and off by about 2F degrees, but even so you can see that they follow each other almost exactly.  This is why it is a good idea to have a second temp sensor as a baseline to compare against.  If you were doing a real fermentation, the exothermic process would show the internal sensor behaving different.

So now that you know how to plot, you can learn more about aesthetics and scale.

Thanks!