Calibrating the LED colours of the Wave Buoy

Here’s how we will calibrate the colours of the LED to change to your preferred heights.

  1. Double click the node circled below in Node Red

A window will open with the code below - the trick is here is to decide what size wave heights you want to trigger the different colour LED’s. I advise small = blue, green = medium, red = large. The reason this is enabled to be easily calibrated is that very different swell heights hit different wave buoys around the UK… So the wave heights in Porthleven will be massively different to those further up the English Channel.

The part of the code you need to change is (msg.payload.hs <= 0.8) This will trigger the Blue LED if the waves are under 0.8m. Then this (msg.payload.hs >= 0.81 && msg.payload.hs <2.6) will light the Green LED if the waves are between 0.81m and 2.6m and (msg.payload.hs >= 2.61) anything over 2.61 will cause the Red LED to flash.

So calibrate them to your desire - click Done and Deploy

var msg1 = {};
var msg2 = {};
var msg3 = {};

if (msg.payload.hs <= 0.8) {
   msg1.payload = 0; // Swell is small turn on Blue LED = GPIO 15
   msg2.payload = 1; // Swell is small turn off Green LED = GPIO 15
   msg3.payload = 1; // Swell is small turn off Red LED = GPIO 15
} else if (msg.payload.hs >= 0.81  &&  msg.payload.hs <2.6)   {
   msg1.payload = 1; // Swell is medium turn off Blue LED = GPIO 13
   msg2.payload = 0; // Swell is medium turn on Green LED = GPIO 13
   msg3.payload = 1; // Swell is medium turn off Red LED = GPIO 13
} else if (msg.payload.hs >= 2.61)   {
   msg1.payload = 1; // Swell is large turn off Blue LED = GPIO 11
   msg2.payload = 1; // Swell is large turn off Green LED  = GPIO 11
   msg3.payload = 0; // Swell is large turn on Red LED  = GPIO 11
}

return [msg1, msg2, msg3];


//payload.hs