css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <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>

            
          
!
            
              $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; 
  }
}
            
          
!
            
              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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console