Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
        <span class="sr-only"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Marni Duffy</a>
    </div>

    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="http://marnibuilds.com" target="_blank">Site/Resume</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>

<br>
<br>
<div class="container col-sm-10">
  <div class="row">
    <div class="col-sm-10 col-sm-offset-2 text-center">
        <div id="chartContainer" style="height: 460px;"></div>
    </div>
  </div>
</div>
<div class="container">
  <div class="row">
    <div class="col-sm-6 col-sm-offset-3 text-center text">
      <h3>Greenhouse Project</h3>
  <p>I built this greenhouse project out of a need on my <a href="http://zerafarm.com" target="_blank">small farm</a>. I have an unheated greenhouse and I wanted to see how the temperature in the greenhouse fluctuated overnight. I wanted to see if the greenhouse mats that my partner made would actually keep the soil temperature of my seeding trays warmer than the ambient and outdoor temperatures.</p>
  <p>I created a Raspberry Pi temperature sensor and created a script that runs constantly on the Pi. It first checks for WiFi connection. If it is connected, it takes a temperature reading from the sensor, converts it to Fahrenheit, and sends the datetime and temperature to a Firebase database. This chart shows that temperature, and a black dot indicating the current outdoor temperature. If the Pi is not connected to wifi, it waits and attempts reconnection in a minute.</p>
    </div>
  </div>
</div>

<div class="row photos ">
  <div class="col-sm-6 col-sm-offset-3 text-center">
    <h3 class="text">Video of the sensor in the greenhouse:</h3>
    <a data-flickr-embed="true" data-context="true"  href="https://www.flickr.com/photos/marniduffy/40968393615/" title="Raspberry Pi WiFi Greenhouse Temperature Sensor"><img src="https://farm1.staticflickr.com/949/40968393615_5d3343e70e_b.jpg" width="404" height="720" alt="Raspberry Pi WiFi Greenhouse Temperature Sensor"></a><script async src="//embedr.flickr.com/assets/client-code.js" charset="utf-8"></script>
  </div>
</div>

              
            
!

CSS

              
                $blue: #2176AE;
$lightgreen: #A9E5BB;
$lightyellow: #FCFCDD;
$pinkcoral: #FF5E83;
$darkblue: #03254E;

#chartContainer {
  margin-bottom: 30px; 
}
body {
  background-image: linear-gradient(to bottom, rgba($lightyellow,0.5) 0%,rgba($darkblue,0.5) 100%), url("https://images.unsplash.com/photo-1504541891213-1b1dfdadb739?ixlib=rb-0.3.5&ixid=eyJhcHBfaWQiOjEyMDd9&s=c4d38cd4a172ae578450edcee8295538&auto=format&fit=crop&w=2250&q=80");
  background-repeat: no-repeat; 
  background-position: bottom;
}
.text {
  border: 2px solid $darkblue;
  border-radius: 5px; 
  background-color: rgba($darkblue, 0.75); 
  padding: 20px; 
  color: $lightyellow;
  a {
    color: $pinkcoral; 
  }
}
              
            
!

JS

              
                var config = {
  databaseURL: "https://greenhouse-temp-and-humidity.firebaseio.com",
  storageBucket: "greenhouse-temp-and-humidity.appspot.com"
};

firebase.initializeApp(config);

var dataPoints = [];
var dataPoints2 = [];

var chart = new CanvasJS.Chart("chartContainer", {
  animationEnabled: false,
  theme: "light2",
  title: {
    text: "GREENHOUSE TEMPERATURE",
    fontColor: '#03254E'
  },
  toolTip: {
    content: "{name}: {y}°F"
  },
  axisY: {
    minimum: 20,
    maximum: 110,
    title: "Temperature",
    titleFontColor: '#2176AE',
    titleFontSize: 24,
    labelFontColor: '#03254E',
    fontFamily: "'Patrick Hand SC', cursive"
  },
  axisX: {
    title: "Time",
    titleFontSize: 24,
    titleFontColor: '#2176AE',
    valueFormatString: "hh TT",
    labelFontColor: '#03254E', 
    fontFamily: "'Patrick Hand SC', cursive"
  },
  data: [
    {
    xValueType: "dateTime",
    type: "line",
    dataPoints: dataPoints, 
    name: "Greenhouse Temperature",
    color: "#FF5E83"
  }
  ]
});

var database = firebase.database().ref('/Greenhouse1/temperature');
loadLocation();

database.on('value', function(snapshot) {
  addData(snapshot.val());
});

function addData(data) {  
  Object.keys(data).map(function(e){ 
    const temperatureHere = roundTemp(data[e]["value"]);
    if(temperatureHere != 185) {
      dataPoints.push(
        {x: (data[e]["timestamp"]*1000), y: +temperatureHere}
      )
    }
  }) 
  chart.render();
}

function loadLocation() {  
    var lat = 42.916148;
    var lon = -76.647153;
    var weatherAPI = "https://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&units=imperial&appid=f7e61ec2dc9fb713acdef2c3386e3372";   
  $.getJSON(weatherAPI, function(weather) {
    var temp = weather.main.temp;
    var dateTime = Date.now();
    dataPoints2.push({x: dateTime, y: temp});
  });
}

function roundTemp(temp){
  return temp.toFixed(2);  
}
              
            
!
999px

Console