We'll show you how to get your Samsung ARTIK to send SMS with Twilio. You can set up your board to send text message alerts about the temperature at your house, the status of a package or anything that's important to you.
This sketch uses our Twilio > SMSMessages > SendSMS Choreo.
1Make sure you have a Temboo account. If you don't already have one, you can register for free.
2If this is the first time using Temboo, you'll need to set up your ARTIK board to find the Temboo libraries. To do so, you'll need to create the file temboo.conf
in /etc/ld.so.conf.d
. Inside of temboo.conf
, you'll want to copy the line below and paste it into the file:
/opt/iothub/artik/temboo/temboo_artik_library/lib
After saving temboo.conf
, run ldconfig
from the command line to add the Temboo library directory to the system library search path.
You’ll also need to get the IP address of your ARTIK board using ifconfig
. The example below shows the results when the ARTIK board is connected to the internet through an ethernet cable. The IP address you'll want to use is listed next to inet.
[root@localhost ~]$ ifconfig eth0: flags=4163mtu 1500 inet 10.11.6.200 netmask 255.255.255.0 broadcast 10.11.6.255
3You'll also need a Twilio account, which you can create for free here.
4When you register with Twilio, you'll be given a Twilio phone number, along with the Account SID and Auth Token. Make sure to use the Account SID and Auth Token from your Twilio Console Dashboard, shown below, as opposed to the test credentials from the Dev Tools panel.
A Twilio Account SID and Auth Token in the Twilio Console Dashboard
5When using a free Twilio account, you'll need to verify the phone number to which messages are being sent by going to Twilio and following the instructions under the "Numbers > Verified Caller IDs" tab.
6Go to the Twilio > SMSMessages > SendSMS Choreo in our Library.
7Select "Samsung" from the drop down menu at the top of the Choreo page.
8Fill in all of the required Choreo inputs, then click Generate Code to test out the Choreo from our website and confirm that you can send an SMS to your own phone.
Testing the SendSMS Choreo from our website
9When you've confirmed that the Choreo runs successfully and you've received an SMS, scroll down to the CODE section, then download the code.
10The auto-generated sketch references the TembooAccount.h
header file, which contains your Temboo account information. You'll find the code for this file beneath your generated Choreo code. Make sure to keep the two files together when moving them on to your ARTIK.
11Copy the downloaded zip file to your ARTIK board using scp
. From your computer, go to the directory where the zip file is located and type the command below. Make sure you use the IP address for your board you found using ifconfig
.
[root@localhost ~]$ scp sendsms.zip root@xxx.xxx.xxx.xxx:/home
12Now go to the sendsms directory and compile your code and start sending SMS from your ARTIK. Run the first command below to compile your code. After compiling has finished and no errors have been reported, run your program using the second command. Check the console and you'll see that the message has been sent successfully. Text away!
[root@localhost ~]$ gcc -L/opt/iothub/artik/temboo/temboo_artik_library/lib -ltemboo -I/opt/iothub/artik/temboo/temboo_artik_library/include sendsms.c -o sendsms [root@localhost ~]$ ./sendsms
Note: If you get an error about cdefs.h not being found, this could mean your ARTIK board was not shipped with glibc-headers. This can be solved by reinstalling glibc-headers using the command below. After reinstalling glibc-headers, run the two commands above to compile and run your code.
[root@localhost ~]$ yum reinstall glibc-headers
Note: Twilio doesn't yet support sending SMS from numbers for all countries. Here's a full list of the countries they currently have SMS support for.
Now that you've mastered SMS, why not check out the rest of the 2000+ Choreos in our Library and start planning your next ARTIK project.
We're always happy to help. Just email us at support@temboo.com, and we'll answer your questions.