An example application that demonstrates how to send SMS or MMS messages with an ESP8266 connected to a friendly WiFi network, as well as hosts a basic server to receive and respond to SMS and MMS messages.
Please read Send SMS and MMS Messages From the ESP8266 in C++ for more information.
Once this application is loaded to the ESP8266 it will:
- Send an SMS (or MMS if you choose) to a number
- Start a webserver with the route '/message'
- Listen for requests to '/message' and respond with a canned response or by reacting to a command from the master number.
In Arduino IDE, first ensure your ESP8266 is burned with the Arduino bootloader and connected. Then, merely adjust the globals at the top of the .ino file and hit the 'Upload' button.
You'll then want to edit the following variables in twilio_esp8266_arduino_example.ino:
- ssid: Your network SSID
- password: Network's password
- fingerprint (maybe): The SHA1 Fingerprint of api.twilio.com, you can check with a web browser
- account_sid: from twilio.com/console
- auth_token: from twilio.com/console
- to_number: A number to send the test SMS (or MMS) to
- from_number: An number from twilio.com/console authorized to send SMS and/or MMSes
- message_body: Message body to send
- master_number: 'Authorized' number for this ESP8266 example
- media_url (optional): Url to an image to send a test MMS
Will run automatically once uploaded to the board. If you do not get a message, enable serial debugging.
Either serial debugging or perhaps a peek at your router screen will reveal the assigned IP address of the ESP8266. :8000/message is the webhook of interest; use ngrok or another means to espose it to Twilio. Note that you'll need to provide a https endpoint!
The most common reason the sketch fails (assumign you correctly copied credentials) is the api.twilio.com
certificate changes. See this section of the Twilio Docs to update the fingerprint in your code.
Hopefully you can use this as the base of your ESP8266 project with Twilio!
- MIT License
- Lovingly crafted by Twilio Developer Education.