Farooq Kaiser
Published © MIT

Build Digital Photo Frame with a Raspberry Pi

With a $35 Raspberry Pi and an old screen, you too can build your own digital photo frame.

IntermediateFull instructions provided3 hours2,005
Build Digital Photo Frame with a Raspberry Pi

Things used in this project

Hardware components

Raspberry Pi 3 Model B
Raspberry Pi 3 Model B
×1

Software apps and online services

NGINX web server

Story

Read more

Schematics

Demo

Code

Untitled file

HTML
<div class="container" style="overflow: hidden;">
        <div class="event">
            <h1 style="margin-bottom: 5px;font-family:Alegreya Sans;text-align: center;"><span style="padding-left:15px;" id="dateHead"></span></h1>
            <h1 style="margin-bottom: 5px;font-family:Alegreya Sans;"><span style="padding-left:15px;" id="weatherHead"></span></h1>
            <h4 style="margin-top: 5px;font-family:Alegreya Sans;"><span style="padding-left:15px;font-size:18px;" id="weatherBody"></span></h4>
            <h1 style="margin-bottom:5px;font-family:Alegreya Sans;text-align: center;"><span id="timeHead"></span></h1>
        </div>
       <canvas id="photoGallery" style="background-color :black;top: 0px;left: 0px;">
                Your browser does not support the HTML5 canvas tag.
       </canvas>
</div>


var imgIndex = 0;
var photoTimer = 10000;
var weatherTimer = 1000 * 60 * 60;
var clockTimer = 1000;
var canvas = document.getElementById('photoGallery');
var context = canvas.getContext('2d');
var img = new Image();
img.src = images[imgIndex];
img.onload = function() {
    var width = window.innerWidth;
    var height = window.innerHeight;
    context.canvas.width = width;
    context.canvas.height = height;
    context.drawImage(img, 0, 0, width, height);
};
setClock();
setInterval(loadPhoto, photoTimer);
setInterval(getWeather, weatherTimer);
setInterval(setClock, clockTimer);
function loadPhoto() {
    imgIndex = imgIndex >= images.length ? 0 : ++imgIndex;
    img.src = images[imgIndex];
}
function setClock() {
    var d = new Date();
    $("#dateHead").html(d.toDateString());
    $("#timeHead").html(d.toLocaleTimeString());
}
function getWeather() {
    $.simpleWeather({
        location: 'Burlington,CA',
        woeid: '',
        unit: 'c',
        success: function(weather) {
            html = weather.city + ', ' + weather.region + '   ' + weather.temp + '°' + weather.units.temp;
            $("#weatherHead").html(html);
            html = 'Feel like ' + eval(weather.wind.chill + weather.temp) + '°' + '  ' + weather.currently + '  ' + weather.wind.direction + '  ' + weather.wind.speed + '  ' + weather.units.speed;
            $("#weatherBody").html(html);
        },
        error: function(error) {
            $(".weather").html('<p>' + error + '</p>');
        }
    });
    $(function() {
        getWeather();
    });

Credits

Farooq Kaiser

Farooq Kaiser

2 projects • 1 follower
I'm full stack software developer using Microsoft technologies, recently exploring raspberry Pi with .Net core.

Comments