Giter Site home page Giter Site logo

red-g / light-sensor Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 88 KB

A web server which monitors the serial port for light data, converts it to lux, then graphs it on the client.

License: MIT License

JavaScript 30.22% HTML 1.61% Svelte 68.16%
light-sensor svelte webserver arduino

light-sensor's Introduction

light-sensor

A web server which monitors the serial port for light data, converts it to lux, then graphs it on the client. In order to install your dependencies, run "npm run install-all", after which you can build and run your application. The command "npm start" will build and run the app (which must be run the first time, or after any changes), while "node index.js" will just run it.

Note: this server requires that you have node and npm installed.

Setup

To get the server monitoring real light values, plug in a device which writes light data to the serial port, with each piece of data on a new line. By default, the CONNECTED variable in the index.js file is set to false, so the site will generate dummy data instead of listening to the serial port. You will need to specify your own serial port name and baud rate.

Example implementation

Our implementation used an arduino hooked up to a light detector circuit on a bread board (just a photoresistor and a 2.2k ohm resistor), with the following program running on the arduino:
//change this to match whichever analog input pin you use.
int lightPin=A0;
//the delay time between updates
int dv=250;
int lightVal;

void setup() {
  // put your setup code here, to run once:
  pinMode(lightPin, INPUT);
  // 9600 is the baud rate
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  lightVal = analogRead(lightPin);
  Serial.println(lightVal);
  delay(dv);
}

The lux conversion mechanism will likely still need to be updated, even with a similar setup to ours.

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.