I am taking part in Data Canvas: Sense Your City, a project to build a network of 100 sensor nodes in seven cities around the world: San Francisco, Boston, Rio de Janeiro, Geneva, Bangalore, Singapore and Shanghai.
This app displays the output from a single sensor node. You can view it live here, displaying data from my sensor node in San Francisco.
See here and here for details on the sensors and the node assembly.
-
Install R and RStudio. In R Studio, install/update the packages on which the R scripts depend: jsonlite, dplyr, ggplot2, scales, shiny, markdown and BH. Here is an introduction to working with RStudio, including how to install packages.
-
get_data.R
retrieves your sensor node data. You will need to replace[Your-ID]
with the ID for your own sensor node before running the script, and[Path-to-file]
with the location on your computer where the data file will be saved. -
Upload the resulting file
sensor_data.csv
to a webserver that allows you to run cron jobs. -
update_data.php
updates the filesensor_data.csv
. Again, replace[Your-ID]
with the ID for your own sensor, then upload the script to your webserver in the same folder as the data file. Set a cron job to run this script at the top of each hour. (Your webhosting service should provide instructions on how to do this, for example.) -
The web app is made with Shiny, and depends on three files:
ui.R
,server.R
andinclude.md
. Place these in a folder with an appropriate name for your app. Inserver.R
, you will need to replace[URL]
with the web address for the folder containing yoursensor_data.csv
file.include.md
is a Markdown file that is converted into the HTML of the app's title and intro text. Feel free to edit this text, however please retain the link to this code repository on GitHub. (If you are not familiar with Markdown, Haroopad provides a nice UI for editing Markdown documents.) -
You can deploy the app with a free account at shinyapps.io. Sign up and then follow these instructions.