Trigger script on Pi using IFTTT

Hi there,

I’m trying to get a script to run on my Pi that will control the universal remote functions I’ve programmed.

My script is located:
/home/pi/scripts/change-source.sh

Contents:

irsend SEND_ONCE Samsung_BN59-01175N KEY_CHANNELUP
sleep 2.5
irsend SEND_ONCE Samsung_BN59-01175N KEY_MODE
sleep 2
irsend SEND_ONCE Samsung_BN59-01175N KEY_RIGHT
sleep 0.5
irsend SEND_ONCE Samsung_BN59-01175N KEY_RIGHT
sleep 0.5
irsend SEND_ONCE Samsung_BN59-01175N KEY_RIGHT
sleep 1
irsend SEND_ONCE Samsung_BN59-01175N KEY_ENTER
sleep 0.5
exit

(I also have a Python version available)

It wouldn’t be easy to script all of this in Particle, hence wanting the trigger the script to run from the Pi itself.

So far I have put together this from various other posts:

#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

#include "Particle.h"

void doCall(String arguments){
    Particle.publish(arguments);
  Process proc = Process::run(arguments);
    proc.wait();
    while (!proc.exited()) {
        delay(10);   
    }

    Particle.publish(String("exit_code ")+String(proc.exitCode()));
    delay(10);   
}

void stdoutEventHandler(const char *event, const char *data){
    //Particle.publish("changesourcepi");
    String arguments {data}; 
    
    String command {"/home/pi/scripts/change-source.sh"};
    String command_and_arguments{command +arguments};
    //Particle.publish(command_and_arguments);
    doCall(command_and_arguments);
}

void setup() {
    Particle.subscribe("changesourcepi", stdoutEventHandler);
    Particle.publish("changesourcepi");
}

void loop() {
}

It flashes to the Pi fine. However, when I try to trigger through IFTTT nothing happens on my Pi.

Could someone point me in the right direction as to what I could be missing out?

Wait, what? You can push Particle code to a Raspberry Pi?
Can I simply access Particle and Mesh communication, or do I have to convert the Pi to a “Big Particle Node”, then flash code to it?

I have a need to communicate between Particle nodes and Pi’s. I am using MQTT to aggregate triggers from PLCs I built myself, Pi’s, and Particle nodes, with a Raspberry Pi reacting to the events.
Works great!

hey Jeffrey!
yes you can push Particle code to a rasp pi, following the instructions here.
The project has been discontinued, but I still use it in a couple of projects at home.

Cheers,
Gustavo.

1 Like

Hey Daniel,

I remember playing with the Pi some time ago, and the project is still working, meaning the code is still good.

In it, I created cloud functions like playSound() and then called them from the particle console, but in your case you could choose to call them from IFTTT.

In case it helps, the project is below. Perhaps you can take a look at how I did it and fix your issue?
(you can forget about the Blynk part of my project).

1 Like