[Solved] Sending Twilio SMS when movement detected

Hi all

I try desperately to make it work, if PLEASE any of you could take few minutes to check my problem I would be so grateful…

The goal : send a SMS when a movement is detected…simple normally

  • On the photon, I got a PIR sensor connected on A0
  • I flashed the photon with the following code app :
void setup() {
    pinMode(A0, INPUT);
}

void loop() {
    if (digitalRead(A0) == HIGH) {
        Spark.publish("twilio", "detected", 60, PRIVATE);
        while (digitalRead(D0) == HIGH); // hang tight here until motion stops
    }
}
  • On my cloud web server, I also ran the command “particle webhook create twilio.json”, havin the following content :
{
  "eventName": "twilio",
  "url": "https://api.twilio.com/2010-04-01/Accounts/xxxxxx/Messages",
  "requestType": "POST",
  "auth": {
    "username": "xxxxxx",
    "password": "xxxxxx"
  },
  "form": {
    "From" : "+xxxxxx",
    "To" : "+xxxxxx",
    Body: '{{SPARK_EVENT_VALUE}}',
    "MediaUrl" : "https://dl.dropboxusercontent.com/u/10931735/big_spark-mark-400px.png"
  },
  "mydevices": true
}

I confirm all twilio values are OK, but nothing happens :frowning: Do you have any idea what could be wrong ? I would be so grateful if you could give me some help. Thanks for all if you could take 5 minutes to check it.

Were you able to trigger the webhook with a curl command?

Is the A0/D0 discrepancy in your code a typo ?

hi all

yes Andy, it was a typ, I confirm both values are A0.
How can I do to check to access my webhook using curl command ? Do I need to open a specific port ?

Sorry, I’m not a webhook ninja - but here are some tips that I believe might help you along:

…I use http://requestb.in/ and Postman when debugging between servers. You can point your webhook at requestbin to see what it’s sending, and use Postman to send specific things (and see the responses) from another API.

This was written in a private message by @Dick, so I can’t just post a link to the thread.
Hopefully @Dick (or others) can expand on that advice a little for you, and the general betterment of the community.

hum thanks Andy, by the way, I just created another webhook on the same VM, and I’m able to access and make it work my communication between the sensor and mobile app (pushover). So it don’t come from here.

arf, any idea where is the problem ?

FOUND ! ! ! :=)

My twilio number phone is enabled for SMS, BUT NOT SMS !
so just removing medialurl variable resolved the problem, since the message is sent in SMS mode, not MMS :slight_smile: you could close thanks :=)