This notebook compares the data from rh-1 with the meteorological data obtained from wow metoffice.

require(dplyr)
require(ggplot2)
require(plotly)
require(lubridate)
require(stringr)

rh_1 <- readRDS(file="C:/Github/lorawan-analysis/data/rh-1.Rds")

wow_met <- readRDS("C:/Github/lorawan-analysis/data/wow_metoffice.Rds")

rh_1_day <- rh_1 %>%
    filter(time<=as.POSIXct("2019-11-16",tz="UTC")) %>%
    group_by(date=as.Date(time, tz="UTC")) %>%
    summarise(ok=n(), transmit= 60*24) %>%
    mutate(device = "rh-1", percentage=ok/transmit*100)

rh_1_day <- rh_1 %>%
    filter(time<=as.POSIXct("2019-11-16",tz="UTC")) %>%
    group_by(date=as.Date(time, tz="UTC")) %>%
    summarise(ok=n(), transmit=60*24) %>%
    mutate(device="rh-1", percentage=ok/transmit*100)

wow_day <- wow_met %>%
  group_by(date=as.Date(time,tz="Europe/London")) %>%
  summarise(rainfall=sum(Rainfall.Accumulation), 
            rh=mean(Relative.Humidity, na.rm=TRUE),
            temperature=mean(Air.Temperature, na.rm=TRUE),
            dew_point = mean(Dew.Point, na.rm=TRUE))

1 Impact of daily environmental factors

comp<-inner_join(rh_1_day, wow_day, by = c("date", "date"))

require(ggplot2)
require(plotly)

p <- ggplot(data=comp, aes(x = rainfall, y = percentage)) + geom_point() + ggtitle("Impact of rainfall on Percentage received - Daily")

ggplotly(p)
p <- ggplot(data=comp, aes(x = rh, y = percentage)) + geom_point() + ggtitle("Impact of RH on Percentage received - Daily")

ggplotly(p)
p <- ggplot(data=comp, aes(x = temperature, y = percentage)) + geom_point() + ggtitle("Impact of temperature on Percentage received - Daily")

ggplotly(p)
p <- ggplot(data=comp, aes(x = dew_point, y = percentage)) + geom_point() + ggtitle("Impact of dew point on Percentage received - Daily")

ggplotly(p)

We have very few data points and there is no obvious trend in the data. Look at hourly data instead.

2 Impact of hourly environmental factors

rh_1_hour <- rh_1 %>%
    filter(time<=as.POSIXct("2019-11-16",tz="UTC")) %>%
    group_by(hour=make_datetime(year = year(time), month = month(time), day = day(time), hour = hour(time))) %>%
    summarise(ok=n(), transmit=60) %>%
    mutate(device="rh-1", percentage=ok/transmit*100)

wow_hour <- wow_met %>%
  group_by(hour=make_datetime(year = year(time), month = month(time), day = day(time), hour = hour(time))) %>%
  summarise(rainfall=sum(Rainfall.Accumulation), 
            rh=mean(Relative.Humidity, na.rm=TRUE),
            temperature=mean(Air.Temperature, na.rm=TRUE),
            dew_point = mean(Dew.Point, na.rm=TRUE))
comp<-inner_join(rh_1_hour, wow_hour, by = c("hour", "hour"))

require(ggplot2)
require(plotly)

p <- ggplot(data=comp, aes(x = rainfall, y = percentage)) + geom_point() + ggtitle("Impact of rainfall on Percentage received - Hourly")

ggplotly(p)
p <- ggplot(data=comp, aes(x = rh, y = percentage)) + geom_point() + ggtitle("Impact of RH on Percentage received - Hourly")

ggplotly(p)
p <- ggplot(data=comp, aes(x = temperature, y = percentage)) + geom_point() + ggtitle("Impact of temperature on Percentage received - Hourly")

ggplotly(p)
p <- ggplot(data=comp, aes(x = dew_point, y = percentage)) + geom_point() + ggtitle("Impact of dew point on Percentage received - Hourly")

ggplotly(p)

No pattern appearing but again, the dataset is very small.

summary(lm(percentage~ temperature + rh + dew_point + rainfall, data= comp))
## 
## Call:
## lm(formula = percentage ~ temperature + rh + dew_point + rainfall, 
##     data = comp)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -59.395 -11.260   2.625  12.735  41.981 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept) -84.2442   184.6866  -0.456    0.649
## temperature   6.3050    10.3482   0.609    0.543
## rh            1.6272     1.8967   0.858    0.391
## dew_point    -7.2689    10.6275  -0.684    0.494
## rainfall     -0.2703     0.1953  -1.384    0.167
## 
## Residual standard error: 18.41 on 388 degrees of freedom
## Multiple R-squared:  0.03592,    Adjusted R-squared:  0.02598 
## F-statistic: 3.614 on 4 and 388 DF,  p-value: 0.006601

2.1 Temperature and humidity recorded by the sensor

rh_1_hour <- rh_1 %>%
    filter(time<=as.POSIXct("2019-11-16",tz="UTC")) %>%
    group_by(hour=make_datetime(year = year(time), month = month(time), day = day(time), hour = hour(time))) %>%
    summarise(ok=n(), transmit=60,
              temperature = mean(payload_fields.temperature, na.rm=TRUE),
              rh = mean(payload_fields.humidity, na.rm=TRUE)) %>%
    mutate(device="rh-1", percentage=ok/transmit*100)
p <- rh_1_hour %>%
  ggplot(aes(x=temperature, y = percentage))+geom_point()+ggtitle("Temperature recorded by device")

ggplotly(p)
p <- rh_1_hour %>%
  ggplot(aes(x=rh, y = percentage))+geom_point()+ggtitle("RH recorded by device")

ggplotly(p)

3 Percentage per hour of the day

p<-rh_1_hour %>%
  ggplot(aes(x=hour(hour),y=percentage))+geom_boxplot()+ggtitle("Percentage per hour of the day")

ggplotly(p)
## Warning: Continuous x aesthetic -- did you forget aes(group=...)?

4 Spreading factor

head(rh_1)
port counter payload_raw dev_id hardware_serial app_id metadata.data_rate metadata.gateways metadata.coding_rate metadata.modulation metadata.airtime metadata.time metadata.frequency payload_fields.temperature payload_fields.humidity payload_fields.vdd time
5 116 AQDtAiY= rht1 A81758FFFE041CA6 rhtsensors SF7BW125 list(altitude = c(84, 90, 90), latitude = c(50.93692, 50.93672, 50.93672), gtw_id = c(“eui-b827ebfffee36ef8”, “eui-7276fffffe0103ec”, “eui-7276fffffe0103ec”), channel = c(4, 1, 17), timestamp = c(2031651523, 3536643083, 3536643083), rssi = c(-89, -86, -84), longitude = c(-1.40461, -1.40445, -1.40445), rf_chain = c(0, 0, 0), time = c(“2019-10-30T15:39:53.317749Z”, “2019-10-30T15:39:52.317751Z”, “2019-10-30T15:39:52.317751Z”), snr = c(6.2, 14, 14), fine_timestamp_encrypted = c(NA, “LCA1159QvlL8I6S1kgBe2Q==”,
"zBRFox Isqt6YEx7k lJRSTQ=="), an tenna = c (NA, NA, 1)) 4 /5 LORA 51456000 2019-10-30T15:39:53.332484018Z 867.3 23.7 38 NA 1572449993
5 117 AQDsAiY= rht1 A81758FFFE041CA6 rhtsensors SF7BW125 list(altitude = c(83, 96, 96), latitude = c(50.93691, 50.93674, 50.93674), gtw_id = c(“eui-b827ebfffee36ef8”, “eui-7276fffffe0103ec”, “eui-7276fffffe0103ec”), channel = c(5, 2, 18), timestamp = c(2091648492, 3596640027, 3596640027), rssi = c(-88, -86, -85), longitude = c(-1.40454, -1.40444, -1.40444), rf_chain = c(0, 0, 0), time = c(“2019-10-30T15:40:53.314708Z”, “2019-10-30T15:40:52.314708Z”, “2019-10-30T15:40:52.314708Z”), snr = c(0, 15, 14), fine_timestamp_encrypted = c(NA, “KCLzybnQKJrJFcFGR0eUAA==”,
"vuPi4R hspG4Tlf87 hU7qZA=="), an tenna = c (NA, NA, 1)) 4/5 LORA 51456000 2019-10-30T15:40:53.32512567Z 867.5 23.6 38 NA 1572450053
5 118 AQDsAiY= rht1 A81758FFFE041CA6 rhtsensors SF7BW125 list(altitude = c(76, 96, 96), latitude = c(50.93696, 50.93675, 50.93675), gtw_id = c(“eui-b827ebfffee36ef8”, “eui-7276fffffe0103ec”, “eui-7276fffffe0103ec”), channel = c(2, 7, 23), timestamp = c(2151645451, 18209964, 18209964), rssi = c(-83, -85, -82), longitude = c(-1.40447, -1.40442, -1.40442), rf_chain = c(1, 0, 0), time = c(“2019-10-30T15:41:53.311655Z”, "“,”"), snr = c(6.5, 15, 15), antenna = c(NA, NA, 1)) 4/5 LORA 51456000 2019-10-30T15:41:53.329615285Z 868.5 23.6 38 NA 1572450113
5 119 AQDsAiY= rht1 A81758FFFE041CA6 rhtsensors SF7BW125 list(altitude = c(75, 92, 92), latitude = c(50.93697, 50.9367, 50.9367), gtw_id = c(“eui-b827ebfffee36ef8”, “eui-7276fffffe0103ec”, “eui-7276fffffe0103ec”), channel = c(4, 1, 17), timestamp = c(2211642427, 78206907, 78206907), rssi = c(-95, -84, -84), longitude = c(-1.40447, -1.40445, -1.40445), rf_chain = c(0, 0, 0), time = c(“2019-10-30T15:42:53.308617Z”, “2019-10-30T15:42:52.308619Z”, “2019-10-30T15:42:52.308619Z”), snr = c(6.2, 15, 15), fine_timestamp_encrypted = c(NA, “dZh3OA0PPHe0cC2vd8ineg==”,
"pcyxBX jadbuQRo1S 07bc7g=="), an tenna = c (NA, NA, 1)) 4/5 LORA 51456000 2019-10-30T15:42:53.320970841Z 867.3 23.6 38 NA 1572450173
5 120 AQDsAiY= rht1 A81758FFFE041CA6 rhtsensors SF7BW125 list(altitude = c(75, 89, 89), latitude = c(50.93696, 50.93667, 50.93667), gtw_id = c(“eui-b827ebfffee36ef8”, “eui-7276fffffe0103ec”, “eui-7276fffffe0103ec”), channel = c(1, 6, 22), timestamp = c(2271639379, 138203836, 138203836), rssi = c(-94, -84, -82), longitude = c(-1.40446, -1.40445, -1.40445), rf_chain = c(1, 0, 0), time = c(“2019-10-30T15:43:53.305558Z”, “2019-10-30T15:43:52.305561Z”, “2019-10-30T15:43:52.305561Z”), snr = c(8.5, 13, 14), fine_timestamp_encrypted = c(NA, “CY8fYjrWoSlEBukswVVCEA==”,
"kscEEI Y2Jp3lMmaD OTiTHg=="), fi ne_timest amp = c(NA, NA, 305 183144), ante nna = c(NA, NA, 1)) 4/5 LORA 51456000 2019-10-30T15:43:53.324552859Z 868.3 23.6 38 NA 1572450233
5 121 AQDsAiY= rht1 A81758FFFE041CA6 rhtsensors SF7BW125 list(altitude = c(75, 95, 95), latitude = c(50.93696, 50.93664, 50.93664), gtw_id = c(“eui-b827ebfffee36ef8”, “eui-7276fffffe0103ec”, “eui-7276fffffe0103ec”), channel = c(1, 6, 22), timestamp = c(2331636355, 198200788, 198200788), rssi = c(-94, -84, -82), longitude = c(-1.40447, -1.40452, -1.40452), rf_chain = c(1, 0, 0), time = c(“2019-10-30T15:44:53.302524Z”, “2019-10-30T15:44:52.302526Z”, “2019-10-30T15:44:52.302526Z”), snr = c(9, 13, 14), fine_timestamp_encrypted = c(NA, “BgbEUOM6+bvZ7UawKo043Q==”,
"O6Ng29 p8dIMUSY3s qtW5bA=="), an tenna = c (NA, NA, 1)) 4/5 LORA 51456000 2019-10-30T15:44:53.319938202Z 868.3 23.6 38 NA 1572450293
str_sub(rh_1$metadata.data_rate[1],3,3)
## [1] "7"
rh_1$SF <-str_extract(rh_1$metadata.data_rate, "\\d+")
# grep("^SF[1-9]+", rh_1$metadata.data_rate[1])

4.1 Temperature and humidity recorded by the sensor

p <- rh_1 %>%
  ggplot(aes(x=time, y = SF))+geom_point()+ggtitle("SF and time")

ggplotly(p)
p <- rh_1 %>%
  ggplot(aes(x=payload_fields.temperature, y = SF))+geom_point()+ggtitle("SF and Temperature recorded by device")

ggplotly(p)
p <- rh_1 %>%
  ggplot(aes(x=payload_fields.humidity, y = SF))+geom_point()+ggtitle("SF and RH recorded by device")

ggplotly(p)