GithubHelp home page GithubHelp logo

ec463miniproject's Introduction

EC463 Software MiniProject

This is a very simple implementation of a web app retrieving sensor data from a database. It also includes google authentication as a way to log in.

Hosting

We decided to use Firebase as our hosting site since it had a lot of nice functions built in, like google authentication and a database.

Web App

We first set up the google authentication. Upon clicking the sign in button, it first checks if the user is already signed in. At the same time there is a firebase function that detects authentication change and if the user is logged in, it retrieves the appropriate user info like name and email, and creates/updates the entry in the database. Although we did not implement sensor data based on uid of the user, it could be done with the uid already stored.

In order to emulate the sensor we setup a simple structure in which there is temperature and humidity data under every minute. In the startDatabaseQueries function. (shown below)

function startDatabaseQueries() {

  var d = new Date();
  var min = d.getMinutes();
  var myUserId = firebase.auth().currentUser.uid;
  var temperature = firebase.database().ref('sensor/1/' + min + '/temperature');
  var humidity = firebase.database().ref('sensor/1/' + min + '/humidity');

  temperature.on('value', function(snapshot) {
    document.getElementById("temp").innerHTML = "Temperature: " + snapshot.val();
  });

  humidity.on('value', function(snapshot) { 
    document.getElementById("humid").innerHTML = "Humidity: " + snapshot.val();
  });

}

It takes the current minute number and retrieves the appropriate data values based on the current time on a minute scale, and then outputs it to the html page, thus replicating a live sensor reading one could view away from their house for instance.

Contributions

Devin Chen: Database query and setup, google authentication, base html formatting

Adian Mikulic: Google authenication, firebase setup, base html formatting

ec463miniproject's People

Contributors

adi-mikulic avatar djchen0912 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.