Back to Parent

A short snippet of code added to the TM export to allow it to trigger a Particle cloud event
// The model recognizing a sound will trigger this event
function gotResult(error, results) {
  if (error) {
    console.error(error);
    return;
  }
  // The results are in an array ordered by confidence.
  // console.log(results[0]);
  label = results[0].label;
    // construct HTTP post information -- the event name, any data to pass and that its a private event
  var particle_publish_data = { name: particle_event_name, data: label, private: true};
  //console.log(particle_publish_data);
  // send it
  httpPost(particle_publish_url , 'text', particle_publish_data,  function(result) {
    //console.log( result );
  });
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0