Giter Club home page Giter Club logo

weather-station's Introduction

Weather Station

Raspberry Pi Weather Station with Node/React webserver to display data

How to Start the Development Server

  1. Navigate into the root of the project directory with your terminal and run:
npm run dev

How to Start the Production Server

  1. Generate a build of the React frontend
cd website/
npm run build
cd ../
  1. Run the production server
npm run prod

File Structure

  1. server
  • controllers/: Contains all routes for each controller type.
  • models/: Contains all bookshelf (our ORM) models for the database. Import these when accessing data.
  • migrations/: Contains all knex database migrations as well as our initial db setup file.
  • bookshelf.js & knex.js: Database configuration files
  • server.js: Starts the express server.
  • app.js: Maps controllers to urls on the server.
  1. client/
  • client.py: Runs the client code meant to go on the Raspberry Pi
  1. website/
  • components/: Component classes which will be individually styled and placed into containers
  • containers/: Full page container (such as the "Connected Stations" page) which combines our components
  • styles/: All of our .css files are placed here
  • images/: All of our images are placed here
  • test/: React test files are placed here

Installing New Dependencies

  1. If you want to install a new dependency to be used both in development and in production:
npm install packagename --save
  1. If you want to install a new dependency only in development for testing purposes:
npm install packagename --save-dev

Migrating Databases

  1. Install knex, our query builder globally
npm install knex -g
  1. Run latest migrations
npm run migrate
  1. If you have any issues, rollback the database to the beginning
npm run rollback
  1. Review the knex documentation for more information here

Install Node Server + Website

This project requires the following dependencies before continuing the install:

  1. Node v9.5.0 - Install here
  2. Yarn v1.3.2 - Install here
  3. MySQL (On Mac OS, install via homebrew. For Windows, go here)
# Mac OS X only
brew install mysql
brew services start mysql

Database Setup:

  1. Create a MySQL user with the name "weatherstation" and password "ws1234".
# Log into your MySQL shell. If you have a password on your root account 
# also add -p onto the end of the following command. 
mysql -u root
# Once logged in, create the user
mysql > CREATE USER 'weatherstation'@'localhost' IDENTIFIED BY 'ws1234';
# Grant all privileges to the new user you have created
mysql > GRANT ALL PRIVILEGES ON * . * TO 'weatherstation'@'localhost';
mysql > FLUSH PRIVILEGES;
  1. Create a database with the name weatherstation while logged into your MySQL shell.
mysql > CREATE DATABASE weatherstation;

After you have installed the above dependencies:

  1. Using your terminal, cd into where you want to store your project directory.
  2. Install nodemon globally and the server dependencies:
npm i nodemon -g
  1. Clone the git repository
git clone https://github.com/batiyeh/weather-station-site
  1. Navigate inside the weather-station directory:
cd weather-station-site
  1. Install all required dependencies for both the server and the website
npm install; cd website; npm install; cd ../
  1. Create all necessary database tables
npm run migrate
  1. Run the development server
npm run dev

Install Client Code on Raspberry Pi

This is meant to be used on a Raspberry Pi running Raspbian OS but can be installed for testing on Mac OS or Windows. We are officially supporting only Raspbian OS for now.

Raspberry Pi

This project requires the following dependencies before continuing the install:

  1. Python 3.5+ (included on Raspberry Pi 3 Model B)

After you have installed the above dependencies:

  1. Open up terminal and navigate to where you want to store this project
  2. Clone the repository and navigate inside it.
git clone https://github.com/batiyeh/weather-station-site
cd weather-station/client
  1. Install the requirements that come with the project:
sudo pip3 install -r pi-requirements.txt
  1. Go to the weather station website and obtain an API Key from the admin page
  2. Go back to your Raspberry Pi, run the program with sudo, and enter in your API Key when prompted
sudo python3 client.py

Build Client Binary

  1. Open up terminal and navigate to where you have stored this project
  2. Navigate into the client folder
cd client/
  1. Run Pyinstaller to generate a binary build from our config file
pyinstaller weatherstation.spec -F
  1. The new client build should be in the dist/ directory in the client folder.

Set Binary to Start on Reboot

  1. Add the following line to the bottom of your .bashrc file in your home directory on the Raspberry Pi
cd path/to/weatherstation/binary; ./weatherstation > /dev/null 2> /dev/null &
  1. Same thing with just the code itself (optional for test purposes)
/usr/bin/python /home/pi/dev/weather-station-site/client/weatherstation.py > /dev/null 2> /dev/null &

Sensors

GPS

  1. Ensure the GPS sensor and RPI is near a window or outside.

  2. Install the necessary GPS libraries for data retrieval

sudo apt-get install gpsd gpsd-clients python-gps
  1. Connect our device to the gpsd library socket
sudo gpsd /dev/ttyACM0 -F /var/run/gpsd.sock
  1. Open the gpsd.sock file
sudo nano /etc/default/gpsd
  1. Add the following lines to the bottom of the gpsd.sock file
# Other options you want to pass to gpsd
START_DAEMON="true"
GPSD_OPTIONS="/dev/ttyACM0"
DEVICE=""
USBAUTO="true"
GPSD_SOCKET="/var/run/gpsd.sock"
  1. Reboot the Raspberry Pi.
sudo reboot
  1. Test that it is working
cpgs -s
# Wait a minute or two for it to find a satellite
# If it is not working, try running step #2 again

Humidity and Temperature

  1. Make sure that the sensor is open and not being covered by anything.

  2. Connect the + wire to the 2 pin on the Pi which is for 5V of power.

  3. Connect the - wire to the 6 pin on the Pi which is for Ground.

  4. Connect the data wire to the 8 pin on the Pi which is for the GPIO 14.

For pin numbering check this website with the GPIO Pinout Diagram https://www.jameco.com/Jameco/workshop/circuitnotes/raspberry-pi-circuit-note.html

  1. Follow this tutorial for installing the proper software

Pressure

  1. Make sure that the sensor is open and not being covered by anything.

  2. Connect the female to female wires to the Vin, Gnd, Sck, and Sdi pins on the pressure sensor.

  3. Connect the Vin wire to the 1 pin on the Pi which is for 3V of power.

  4. Connect the Gnd wire to the 9 pin on the Pi which is for Ground.

  5. Connect the Sck wire to the 5 pin on the Pi which is for the I2C clock.

  6. Connect the Sdi wire to the 3 pin on the Pi which is for the I2c data.

  7. Once all wires have been connected go to the Raspberry Pi configuration and enable I2c.

  8. To make sure that the sensor has properly been connected you can run the command sudo i2cdetect -y 1

For more information about the sensor check this website https://learn.adafruit.com/adafruit-bmp280-barometric-pressure-plus-temperature-sensor-breakout?view=all

Sense Hat

  1. Install the sense hat library
sudo apt-get update
sudo apt-get install sense-hat
  1. Reboot Raspberry Pi
sudo reboot

weather-station's People

Contributors

batiyeh avatar fa4269 avatar tmalarkey avatar jeswanthk avatar xmonument avatar

Watchers

Greg Czerniak avatar  avatar  avatar  avatar

Forkers

foxittt

weather-station's Issues

Show Station Location History

Allow the user to look through the location history of a station on a map along with the weather data at each location

Change alerts page to use tabs

Decouple the triggered/historical alerts from the custom alerts (they are all in one component right now) and split them into their own tabs on the page

Navbar on the map page is scrollable

On the map page, the navbar is scrollable for some reason. This should be fixed when we update the map UI to be smaller and more centrally located.

Dismissing all alerts is a hard delete

Change to a soft delete with a dismissed column in the table to mark 1/0. Also when clicking dismiss, you have to reload the page to see that they were all dismissed.

Uptime is not correctly displayed

It only displays the updated at time for now. We should change created_at every time it is disconnected and reconnected then subtract created_at from updated_at to get the uptime.

Build a UI for the Raspberry Pi client

Add a UI to the client that makes it easier for users to install/uninstall Raspberry Pi code, change the API key for that station, mess with data files, etc.

README incomplete

I dont think the README is complete. I am trying to run this on my mac, and have followed your steps but can not be able to run it.

Marker Clustering

Add the feature to cluster markers that are too close together on the map

Handle all times in UTC

Currently, all times are in EST. This can mess up the connection indicator when running the app on different servers that are not also set to be in EST. The client must change to send data in UTC as well as the moment() javascript library.

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.