Hi,
Tommy_768
1

Hi,

The {{ reading }} part isn’t actually important, it’s only used when the page is first loaded (and I think it should actually be {{ sensor }} ).

The important part is where the displayed value gets updated via websockets which is this function in sensor.js:

chatsock.onmessage = function(message) { 
console.log(“Received Sock message!”);
console.log(message);
$(‘#sensor’).text(message.data);
};

The above function get’s called every time a socket message is received by the browser from the main application. The line below is the jquery function that updates the actual displayed value in the DOM:

$(‘#sensor’).text(message.data);

Hope that helps!

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.