Customising the Wave Buoy location

The Wave Buoy design uses Node Red which is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.

  1. The first step is to start the service on the PI from the command line using PuTTY. Login to your PI using the method here

  2. Start Node red by typing this command into the terminal node-red-start

  3. You should be presented with a screen like the below

  4. This has started the Node Red service on your connected PI we now need to type in the IP address into your browser thats indicated in the picture above (yours will be different)

  5. Your browser window should now display the below

  6. We are now going to edit some code to change the location of the Channel Coast Wave Buoy.

  7. Head to the Channel Coast Observatory to obtain an API key via their automated service https://www.channelcoast.org/ccoresources/api/

  8. Make a not of the API key that they send you on email.

  9. Double click on the hhtp request node circled as below

  1. In the URL box enter this http://data.channelcoast.org/observations/waves/latest?key=YOUR_API_KEY_HERE then click ‘Done’

  2. Double click 'Find .hs variable this is a function that is now going to search for the location you specify in the below. The default is Porthleven in the UK. This code will search for this location and the ‘hs’ variable which is the swell height. Click ‘Done’

 g = msg.payload["wfs:FeatureCollection"]["gml:featureMember"]

    var results = [];

    var toSearch = "ENTER LOCATION NAME HERE";

    for(var i=0; i<g.length; i++) {
      for(let key in g[i]) {
    if(g[i]['ms:waves'][0]['ms:sensor'][0].indexOf(toSearch)!=-1) {
      results.push(g[i]);
    }
      }
    }
    return {payload:{results:results,sensor:results[0]["ms:waves"][0]["ms:sensor"][0],hs:parseFloat(results[0]["ms:waves"][0]["ms:hs"][0])}}

    //payload["wfs:FeatureCollection"]["gml:featureMember"][0]["ms:waves"][0]["ms:sensor"][0]`

  1. Now click ‘Deploy’ this will deploy the code to the PI