Getting JustGage to work with Photon

I am working my way through Simons’s book with the goal of creating an internet connected sunlight logging network. I am playing his example p_09_light_meter.html and cannot get JustGage to work. It returns ‘JustGage’ is undefined. There must be something I needed to do before running the script but I cannot figure out what it is. I expect it is something very basic that everyone else knows? Any suggestions?

David V

If you have a link or some code for us to look at, that’d be great :wink:

It fails at line 32, where it creates the instance of JustGage:

<script src="" type="text/javascript" charset="utf-8"></script>
<script src="raphael.2.1.0.min.js"></script>
<script src="justgage.1.0.1.min.js"></script>

var accessToken = "cb8b348000e9d0ea9e354990bbd39ccbfb57b30e";
var deviceID = "54ff72066672524860351167"
var url = "" + deviceID + "/tempf";
function callback(data, status){
	if (status == "success") {
		temp = parseFloat(data.result);
		temp = temp.toFixed(2);
		setTimeout(getReading, 1000);
	else {
		alert("There was a problem");
function getReading(){
   	$.get(url, {access_token: accessToken}, callback);

<div id="gauge" class="200x160px"></div>

var g = new JustGage({
    id: "gauge",
    value: 0,
    min: 30,
    max: 100,
    title: "Degrees F"


Are the libraries included in the same directory?

Tell me more about “the libraries” and “same directory”. Which directory?

<script src="raphael.2.1.0.min.js"></script>
<script src="justgage.1.0.1.min.js"></script>

Since there are local, they should be in the same directory as the HTML file they’re in.

OK, got it. Do the libraries have to be named exactly that? That is, if there is a new version of the library with a new name, then you need to change the script? Is there a environment variable that locates libraries?

BTW, thanks to you, Moors7. You have been very helpful to me.

If you want them to be found, then yes :wink:

Well… yes :wink:

I honestly have no idea, I’m not that into JS yet. Perhaps there’s someone on here that does know :slight_smile:

You need to search Google for the exact libraries by name. Then, once you have them, copy them into the same folder that your HTML page is located.

  1. Make sure that the file names are exactly the same in the include lines, and the files you downloaded.
  2. Watch for minified files (filename.min.js) - these are similar but different. They are okay to use, but check that the .html file states the correct file name.
  3. JustGage calls on Raphael, so there’s no specific call to it within the HTML file.

I’ve submitted these to the errata page for Simon Monk’s book.

your instructions were spot on. thank you. downloaded the two .js files from, moved them to my html docs folder, and modified my html to match the file names. as of today’s revision, the code should appear as follows. note the dash “-” in the raphael name.