getSensorHistory {PurpleAirAPI}R Documentation

getSensorHistory

Description

Download historical data for PurpleAir sensors using API.

Usage

getSensorHistory(
  sensorIndex = NULL,
  apiReadKey = NULL,
  startDate = NULL,
  endDate = NULL,
  average = NULL,
  fields = NULL
)

Arguments

sensorIndex

PurpleAir sensor's index.

apiReadKey

PurpleAir API read key.

startDate

Date of the first required history entry.

endDate

Date of the history to return. Uses end of date specified.

average

The desired average in minutes: 0, 10, 30, 60, 360, 1440, 10080, 43200, 525600

fields

The 'sensor data fields' to include in the response.

Details

Available fields:

Station Information and Status hardware*, latitude*, longitude*, altitude*, firmware_version*, private, rssi, uptime, pa_latency, memory
Environmental humidity, humidity_a, humidity_b, temperature, temperature_a, temperature_b, pressure, pressure_a, pressure_b
Miscellaneous voc, voc_a, voc_b, analog_input
PM1.0 pm1.0_atm, pm1.0_atm_a, pm1.0_atm_b, pm1.0_cf_1, pm1.0_cf_1_a, pm1.0_cf_1_b
PM2.5 pm2.5_alt, pm2.5_alt_a, pm2.5_alt_b, pm2.5_atm, pm2.5_atm_a, pm2.5_atm_b, pm2.5_cf_1, pm2.5_cf_1_a, pm2.5_cf_1_b
PM10.0 pm10.0_atm, pm10.0_atm_a, pm10.0_atm_b, pm10.0_cf_1, pm10.0_cf_1_a, pm10.0_cf_1_b
Visibility scattering_coefficient, scattering_coefficient_a, scattering_coefficient_b, deciviews, deciviews_a, deciviews_b, visual_range, visual_range_a, visual_range_b
Particle Count 0.3_um_count, 0.3_um_count_a, 0.3_um_count_b, 0.5_um_count, 0.5_um_count_a, 0.5_um_count_b, 1.0_um_count, 1.0_um_count_a, 1.0_um_count_b, 2.5_um_count, 2.5_um_count_a, 2.5_um_count_b, 5.0_um_count, 5.0_um_count_a, 5.0_um_count_b, 10.0_um_count, 10.0_um_count_a, 10.0_um_count_b

Value

Dataframe of PurpleAir history data of one or multiple sensors.

References

For more details on the available fields, see the PurpleAir API documentation: https://api.purpleair.com/#api-sensors-get-sensor-history-csv

Examples

## Not run: 
# Download hourly PM2.5 data for one month
history <- getSensorHistory(
  sensorIndex = c(6127, 9014, 3124),
  apiReadKey = "YOUR_API_KEY",
  startDate = "2024-01-01",
  endDate = "2024-01-31",
  average = 60,
  fields = c("pm2.5_alt", "temperature", "humidity")
)

## End(Not run)


[Package PurpleAirAPI version 0.1.0 Index]