Learn R Programming

PurpleAirAPI (version 0.1.0)

getSensorHistory: getSensorHistory

Description

Download historical data for PurpleAir sensors using API.

Usage

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

Value

Dataframe of PurpleAir history data of one or multiple sensors.

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 Statushardware*, latitude*, longitude*, altitude*, firmware_version*, private, rssi, uptime, pa_latency, memory
Environmentalhumidity, humidity_a, humidity_b, temperature, temperature_a, temperature_b, pressure, pressure_a, pressure_b
Miscellaneousvoc, voc_a, voc_b, analog_input
PM1.0pm1.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.5pm2.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.0pm10.0_atm, pm10.0_atm_a, pm10.0_atm_b, pm10.0_cf_1, pm10.0_cf_1_a, pm10.0_cf_1_b
Visibilityscattering_coefficient, scattering_coefficient_a, scattering_coefficient_b, deciviews, deciviews_a, deciviews_b, visual_range, visual_range_a, visual_range_b
Particle Count0.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

References

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

Examples

Run this code
if (FALSE) {
# 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")
)
}

Run the code above in your browser using DataLab