npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

j5-sparkfun-weather-shield

v2.0.0

Published

SparkFun Weather Shield plugin for Johnny-Five

Downloads

20

Readme

SparkFun Weather Shield

Build Status

For use with Johnny-Five.

API & Documentation

For use with Particle Photon:

npm install johnny-five particle-io j5-sparkfun-weather-shield

For use with Arduino:

npm install johnny-five j5-sparkfun-weather-shield

Weather

The Weather class constructs objects that represent the built-in components of the shield.

  • Explicit Initialization, defaults "data" to 25ms intervals

    const weather = new Weather({
      variant: "DEV-13956",
    });
    
    ...or...
      
    const weather = new Weather({
      variant: "DEV-13674",
    });
  • Explicit Initialization, specify "data" to 200ms intervals

    const weather = new Weather({
      variant: "DEV-13956",
      period: 200
    });
    
    ...or...
    
    const weather = new Weather({
      variant: "DEV-13674",
      period: 200
    });

Parameters

| Property | Type | Value(s)/Description | Default | Required | Version | |------------|-----------|---------------------------|---------|----------|---------------| | variant | string | "ARDUINO", "PHOTON" | no | yes | v0.1.0-v1.0.0 | | variant | string or number | See Variants | no | yes | v2.0.0+ | | elevation | number | Base elevation in meters (You can use whatismyelevation.com to find out the base elevation for your location) | | yes * | yes | all | | ~~freq~~ | number | Use period | 25 (ms) | no | v0.1.0-v1.0.0 | | period | number | Milliseconds. The rate in milliseconds to emit the data event | 25 (ms) | no | v2.0.0+ |

* If elevation is omitted, the value of the feet and meters properties will be null. When elevation is included, there is a 3 second calibration window before all values are reported.

Variants

| Shield | Product Name | Variant Values | Retired ? | |----------|----------|--------------------|-----------| | | SparkFun Weather Shield | "DEV-13956", "DEV13956", 13956 | No | | | SparkFun Weather Shield | "DEV-12081", "DEV12081", 12081 | Yes | | | SparkFun Photon Weather Shield | "DEV-13674", "DEV13674", 13674 | No | | | SparkFun Photon Weather Shield | "DEV-13630", "DEV13630", 13630 | Yes |

Using the Arduino shield

(Without a specified elevation)

const five = require("johnny-five");
const Weather = require("j5-sparkfun-weather-shield")(five);
const board = new five.Board();

board.on("ready", () => {
  const weather = new Weather({
    variant: "DEV-13956",
    period: 200
  });

  weather.on("data", () => {
    const {
      celsius,
      fahrenheit,
      kelvin,
      pressure,
      relativeHumidity,
      lightLevel
    } = weather;

    console.log("celsius: %d°C", celsius);
    console.log("fahrenheit: %d°F", fahrenheit);
    console.log("kelvin: %d°K", kelvin);
    console.log("pressure: %d kPa", pressure);
    console.log("relativeHumidity: %d RH", relativeHumidity);
    console.log("lightLevel: %d%", lightLevel);
    console.log("----------------------------------------");
  });
});

(With a specified elevation)

const five = require("johnny-five");
const Weather = require("j5-sparkfun-weather-shield")(five);
const board = new five.Board();

board.on("ready", () => {
  const weather = new Weather({
    variant: "DEV-13956",
    period: 200, 
    // Set your base elevation with a value in meters,
    // as reported by http://www.whatismyelevation.com/.
    // `5` is the elevation (meters) of the
    // Bocoup office in downtown Boston
    elevation: 5,
  });

  // Including elevation for altitude readings will
  // incure an additional 3 second calibration time.
  weather.on("data", () => {
    const {
      celsius,
      fahrenheit,
      kelvin,
      pressure,
      feet,
      meters,
      relativeHumidity,
      lightLevel
    } = weather;

    console.log("celsius: %d°C", celsius);
    console.log("fahrenheit: %d°F", fahrenheit);
    console.log("kelvin: %d°K", kelvin);
    console.log("pressure: %d kPa", pressure);
    console.log("feet: %d'", feet);
    console.log("meters: %d", meters);
    console.log("relativeHumidity: %d RH", relativeHumidity);
    console.log("lightLevel: %d%", lightLevel);
    console.log("----------------------------------------");
  });
});

Using the Photon shield

(Without a specified elevation)

const Particle = require("particle-io");
const five = require("johnny-five");
const Weather = require("j5-sparkfun-weather-shield")(five);
const board = new five.Board({
  io: new Particle({
    token: process.env.PARTICLE_TOKEN,
    deviceId: process.env.PARTICLE_PHOTON_DEVICE_ID
  })
});

board.on("ready", function() {
  var weather = new Weather({
    variant: "DEV-13674",
    period: 200
  });

  weather.on("data", () => {
    const {
      celsius,
      fahrenheit,
      kelvin,
      pressure,
      relativeHumidity,
      lightLevel
    } = weather;

    console.log("celsius: %d°C", celsius);
    console.log("fahrenheit: %d°F", fahrenheit);
    console.log("kelvin: %d°K", kelvin);
    console.log("pressure: %d kPa", pressure);
    console.log("relativeHumidity: %d RH", relativeHumidity);
    console.log("lightLevel: %d%", lightLevel);
    console.log("----------------------------------------");
  });
});

(With a specified elevation)

const Particle = require("particle-io");
const five = require("johnny-five");
const Weather = require("j5-sparkfun-weather-shield")(five);
const board = new five.Board({
  io: new Particle({
    token: process.env.PARTICLE_TOKEN,
    deviceId: process.env.PARTICLE_PHOTON_DEVICE_ID
  })
});

board.on("ready", () => {
  const weather = new Weather({
    variant: "DEV-13674",
    period: 200,
    // Set your base elevation with a value in meters,
    // as reported by http://www.whatismyelevation.com/.
    // `5` is the elevation (meters) of the
    // Bocoup office in downtown Boston
    elevation: 5,  
  });

  // Including elevation for altitude readings will
  // incure an additional 3 second calibration time.
  weather.on("data", () => {
    const {
      celsius,
      fahrenheit,
      kelvin,
      pressure,
      feet,
      meters,
      relativeHumidity,
      lightLevel
    } = weather;

    console.log("celsius: %d°C", celsius);
    console.log("fahrenheit: %d°F", fahrenheit);
    console.log("kelvin: %d°K", kelvin);
    console.log("pressure: %d kPa", pressure);
    console.log("feet: %d'", feet);
    console.log("meters: %d", meters);
    console.log("relativeHumidity: %d RH", relativeHumidity);
    console.log("lightLevel: %d%", lightLevel);
    console.log("----------------------------------------");
  });
});

Convenient serialization for data payloads:

const weather = new Weather({
  variant: ...
});

weather.on("data", () => {
  console.log(JSON.stringify(weather, null, 2));
});

Produces:

{
  "celsius": 24,
  "fahrenheit": 75.2,
  "kelvin": 297.15,
  "pressure": 125.5,
  "feet": 3.28,
  "meters": 1,
  "relativeHumidity": 48,
  "lightLevel": 50
}

Since the Photon shield does not include the ALS-PT19 light sensor, the lightLevel property will always be null for that variant.

NOTE

The examples shown here are provided for illustration and do no specifically indicate variant support. This component class is expected to work with any variant that has I2C support.