Introduction: Send SMS From Arduino Over the Internet Using ENC28J60 and Thingspeak

Picture of Send SMS From Arduino Over the Internet Using ENC28J60 and Thingspeak

This Instructable explains how to send an SMS from an Arduino using the Internet. There are many ways to approach this and I will explain one of the different methods used to accomplish this task.

Some major points needed for my project:

  • I have a standard Ethernet shield, and ENC28J60 Ethernet module, and I needed my program to work with both and also over a wifi connection (using the ESP8266 - I just ordered some to test)
  • I would like the SMS service to be free

So aside from the hardware, I found three main ways to interface with the Arduino and send an SMS.

  1. Using Temboo to send an SMS through Twilio
  2. Using Lithouse connected to IFTTT to send an SMS
  3. Using Thingspeak ThingHTTP to send an SMS through Twilio

I tested all of these methods, and only one successfully worked on my ENC28J60 Ethernet module, the target I was going for. But more importantly the code on the Arduino side is very simple, and should work using WiFi or Ethernet without any special libraries, other than the standard Ethernet communication libraries.

So again I will only explain method number 3. If you want to use another method there are other guides on the internet, but I felt like Thingspeak ThingHTTP is slighjtly undocumented.

Step 1: Setup

Picture of Setup

The hardware is pretty simple.

  1. Arduino Uno, or equivalent
  2. A connection to the internet, using an Ethernet shield, the ENC28J60 Ethernet module, or a WiFi module/shield

The software is a little more complicated to set up.

Since the Arduino does not support HTTPS, we are going to use Thingspeak to trigger Twilio.

You will need:

  1. A Twilio account. Register at After signing up, verify your number.
  2. A Thingspeak account. Register at

If you are using the ENC28J60 or wifi module, you will need the acompaning libraries. For the ENC28J60, I reccomend Arduino UIP. Download the zip and move it to the libraries folder.

Okay now that's all set up, we will start the configuration.

Step 2: Configuring Thingspeak ThingHTTP

Picture of Configuring Thingspeak ThingHTTP

Go to, click on apps, then ThingHTTP, and then New ThingHTTP. This will take you to the setup page. You will have to find your Twilio account SID and auth token on your Twilio dashboard page

Copy the following data into the fields. Where italics and caps you must replace with the data from Twilio.

  1. Name it Twilio Send SMS
  5. Set the method to POST
  6. Content type is application/x-www-form-urlencoded
  7. Click remove headers, and leave host blank
  8. Body = From=YOUR TWILIO NUMBER&To=%%number%%&Body=%%message%%

Click Save ThingHTTP

Take note of the API key for your ThingHTTP. You will need it in the Arduino sketch

Step 3: Arduino Side

The Arduino will need a connection to the internet, again the Ethernet shield and ENC28J60 Ethernet module will both work, and Wifi will too with some small changes to the program

Here is a guide to connect the ENC28J60 to the Arduino

This code will work both with the Arduino Ethernet Shield and the ENC28J60 Ethernet module, with a simple modification. Download the file and change the API key and phone number to your own, then upload it.

Test the program, and hopefully within a few seconds your phone will receive the SMS. The Serial monitor will also display some helpful information for debugging.

Good luck and hope this was helpful!


AngaR1 (author)2017-08-28

I didnt know to set url. can anyone help me?!!

zulemitavaras (author)AngaR12017-10-17

of course


  1. A Twilio account. Register at After signing up, verify your number.
  2. go to Console Dashboard, Home, Dashboard. There you have your data
zulemitavaras (author)AngaR12017-10-17

replace YOUR TWILIO ACCOUNT SID with the account sid of your twilio account, you only have to follow the instruccions

zulemitavaras (author)2017-10-17

hello how I should replace To=%%number%% I from peru. I receive this error, obviusly I change XX from my number

<TwilioResponse><RestException><Code>21211</Code><Message>The 'To' number 519537920XX is not a valid phone number.</Message><MoreInfo></MoreInfo><Status>400</Status></RestException></TwilioResponse>CLOSED

AngaR1 (author)2017-08-28

I didnt know how to frame url can anyone help me?!!

modiksham (author)2017-08-24

I am not receving message it is not showing any error

HTTP/1.1 200 OK

Content-Type: text/html; charset=utf-8

Content-Length: 2

Connection: close

Status: 200 OK

X-Frame-Options: ALLOWALL

Access-Control-Allow-Origin: *

Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH

Access-Control-Allow-Headers: origin, content-type, X-Requested-With

Access-Control-Max-Age: 1800

ETag: "6bb61e3b7bce0931da574d19d1d82c88"

Cache-Control: max-age=0, private, must-revalidate

X-Request-Id: 809e1633-e88b-423d-bba8-a40aa279c0f8

X-Runtime: 0.030564

X-Powered-By: Phusion Passenger 4.0.57

Date: Thu, 24 Aug 2017 09:37:52 GMT

Server: nginx/1.9.3 + Phusion Passenger 4.0.57

jdl1321 (author)2017-04-25

The serial port stops at "sending sms" not sheer what the problem is can anyone help?

cassy73 (author)2017-03-21

Hi All!

You can download smarter UIPEthernet library from:

This support more MCUs and more IDEs.

library for Arduino IDE,Eclipse with arduino plugin and MBED/SMeshStudio
(AVR,STM32F,ESP8266,Intel ARC32, Nordic nRF51, Teensy boards,Realtek
Ameba(RTL8195A,RTL8710)), ENC28j60 network chip. Compatible with Wiznet
W5100 Ethernet library API.)

You can find wiring diagrams:

Best Regards

JimO44 (author)2017-02-12

I want to thank you for this post, I've been trying to send an sms with my Arduino and searching for a successful process. I tried Cayenne , Temboo, Native all with no luck and then stumbled on your post. It was straight forward simple and worked like a champ. Exactly what I was looking for !!

I configured a motion sensor that works out at my shed where I've had some break in's. The remote motion sensor also uses a RF 433Mhz TX and sends a message to my in door unit which in turns sounds a buzzer and now sends me a Text message on my phone !!

You are the best !!...

jinpa108 (author)2017-01-28

Could someone please post example code for WiFi instead of Ethernet. I'm using an ESP8266.

Thank You

Praveen7728 (author)2016-08-21

I am getting an error as To number is not valid. What is happening is that ThingSpeak is removing the '+' sign from the To number. How can I get around this problem?

ChiC19 (author)Praveen77282017-01-14

Hi Praveen, is your problem solved? I am having the same issue as yours :(

diy_bloke (author)Praveen77282017-01-06

are you sure thingspeak removes the plus? I get a non valid number error message as well, but with or without plus Twilio still mentions the plus in front of the number

ChiC19 (author)2017-01-14

I am getting the 'to' number is invalid although I have already registered and verified my mobile phone number. Anyone can help me about this? :(

diy_bloke (author)2017-01-06


The 'From' number +XXXXXXXX is not a valid phone number, shortcode,
or alphanumeric sender ID

When I test directly from Twilio, it works, so the problem must be somewhere in the Thingspeak part

hzrhsani (author)2016-11-23

Hi there, i have a problem with my codes. I changed your ethernet codes and added my wifi library since I am using wifi shield for this project. It only sends

Setting up WiFi...

Attempting to connect to WEP network, SSID: iotlab

Sending SMS


and does not send any message to my phone. I did add my phone number on twilio and did what i am instructed to in this page but I still have error. Are you able to help me?

Ben-DIY (author)2016-11-16

Shall I use my own phone number there? I don't see other numbers, just a button to buy a number and as far as I got it from your "requirements", the SMS service should be free. Am I doing something wrong?

lucasxavier11 (author)Ben-DIY2016-11-18

The To phone number is your cell phone number - this needs to be verified on your twilio account before first use. The From phone number is your free Twilio number, find it in your account. If you can't find it try googling Twilio Trial number. Good luck!

OscarC24 (author)2016-08-31

Hi i can sussesfully create a twilio acount but i dont get a number instantly. I must look from everywere to get one, now i have it in the form +12345678901

i fill the thingspeak whit:

Body = From=+12345678901&To=%%number%%&Body=%%message%%

but how can i test it?

i get these link but i dont know how

if only copy this i get

"21603A 'From' phone number is required."

DustinA20 (author)OscarC242016-11-13

it should be:


Remove the "Body = " from the line.

blackabbys made it! (author)2016-08-22

I am using NodeMCU to send sms, I can get connected to the internet succesfully, also geting connected to the host too. But it returns -1. I checked all twilio and thingspeak stuffs but it doesnt send me an sms. When I try it via Timboo, it is working correctly. Can you say something about this problem.

SpikePlayz. (author)2016-08-10

Hi, can I use one of these options with Arduino MKR1000? I'm trying to get it to send me a message when outside of WiFi if, say a sensor is triggered. I'm new to programming so I'm not quite sure which one to use as i don't want to have to make hundreds of new accounts! thanks

It would be hard to send a message outside of wifi because the Arduino needs wifi to send the message! You might want to look into a cellular shield or other options. However this code should work with the MKR1000, just replace the client library with the native Arduino wifi library. Good luck!

I understand that! What I meant was, picture this: I'm going out somewhere, for the night or day or whatever, and I want to know if anyone breaks in to my house or if i got mail. A sensor (detecting say if a door was opened) would be triggered and I would receive a text message! Thanks a lot, and sorry for the misunderstanding!

That makes more sense! You could definitely do that using this code. Use the default wifi example, and then add the thing speak default URL call. Or if you're looking for a simpler solution, explore using Temboo. Let me know if you run into any issues.

Hi, I made accounts for Thingspeak and Twilio, and went through all the steps you said, but when I try to upload I get an error message. I think I understand that it's to do with the fact that I haven't made the changes you talked about for using Wifi; I'm not completely sure what these changes should be though! Also I'm struggling to get my MKR's mac address and type it in the correct format for this code! Sorry to be a hassle :-/

Thank you for your time and attention! I'll try it out and see how it goes!

Bdmteja (author)2016-01-29

i'm using ESP8266 module how to send message through that using twilio.
"From phone number is required".

could u help me plz..

lucasxavier11 (author)Bdmteja2016-08-04

The from phone number is your Twilio ten digit number that you receive when you sign up for Twilio.

salah0 (author)2016-07-02

please how can i write my phone number correctly ?

lucasxavier11 (author)salah02016-08-04

I believe Twilio wants your phone number in the standard 10 digit form, so +1, then your area code, then your phone number. Let me know if that doesn't work.

ZachR26 (author)2016-08-04

I'm not getting a response from the server. I'm using an arduino uno R3 with an ENC28J60 and the UIPEthernet library (so pin 10 instead of 8 for cs). The sketch gets past printing everything to the client, but then client.connected() is never true for the next part:

while (client.connected())


if ( client.available() )


char c =;




Any advice?

lucasxavier11 (author)ZachR262016-08-04

Have you tried to run some examples from the UIPEthernet library and do they work? If the ENC28J60 cannot connect to the internet that is your first problem. Good luck debugging!

KarthikeyanS8 (author)2016-01-15


I was trying to implement this project and i have faced some errors. Please help me to resolve it........

I have given FROM number correctly in Body section.But there comes error stating that "From phone number is required"

Bdmteja (author)KarthikeyanS82016-01-29

Hi karthikeyan,

Did u succeded in sending message,if so please help me..i've to send msg plz..

thanks in advance

DavidB233 (author)2016-01-22

Hi Lucas,

Thanks for sharing this, it's really cool. I believe I'm real close to getting it to work. I'm using a cc3000 wifi shield. Here is what is being returned:

HTTP/1.1 400 Bad Request

Server: nginx/1.9.3

Date: Sat, 23 Jan 2016 04:42:03 GMT

Content-Type: text/html

Content-Length: 172

When I manually send the ThingHTTP request I get this message:

A 'From' phone number is required.

Do you have any ideas regarding this? Here's a dumb questions also, is the phone number I add to the sketch my smartphone number or a number I get from Twilio? Again, thanks for your work!


lucasxavier11 (author)DavidB2332016-01-23

Hi David,
That request could be a number of errors, but I may be able to help. You did the right thing by testing the thingspeak request before trying to run it on the cc3000.

First off, your twilio number needs to be pasted in the thingspeak request, as the "from" number. Your cellphone number is the "to" number in the arduino sketch. Make sure your cell phone number is verified with twilio if you are using a free account.

I hope that clears some things up for you, and remeber you can test the thingspeak in a browser befrom running it on the arduino.

Best of luck!

wcmiller5 (author)2016-01-10

I have switched over to using the ESP8266 12E (NODEMCU V1) and you mentioned that you were thinking about using the ESP8266 to communicate over WiFi. I'm using the Arduino IDE (1.6.7) with the ESP8266 Add-in libraries. Have you done that and if so is your code available. Opening up the "Cloud" has made the use of these SOC's much more fun. I'm now working with my Son's in Atlanta via a ThingSpeak channel that displays Temp and Humidity of their meat curing chamber. This is where I would like to send an email message when the temperature or humidity gets outside a certain range.

Thanks in advance for your consideraation.


lucasxavier11 (author)wcmiller52016-01-10

Hi AdaBill, Sounds like an interesting project. I have played with the ESP8266 however not with NODEMCU. My projects involve an Arduino communicating over a serial bridge with the ESP8266. Luckily, thingspeak makes this very easy. In fact I believe you can just change the line

EthernetClient client; to your wifi class so it would look like WifiClient client; with the associated libraries and it should work. 

If that doesn't work you can use the example http request in the sendSMS function in your own program. 

Good luck and if you have any questions feel free to ask!

muscluman (author)2015-12-29

In Body = From=YOUR TWILIO NUMBER&To=%%number%%&Body=%%message%%

do I put the + sign in front of my Twilio number?

lucasxavier11 (author)muscluman2015-12-29

Yes, I believe you need the + sign. However you could try it both ways and see what works.

muscluman (author)lucasxavier112015-12-30

It works with the + sign. Thanks for your instructable. I am working on another one and will give you credit for this :-)

Moltes gràcies!

lucasxavier11 (author)muscluman2015-12-30

Im glad it worked. Happy making!

DrEwKo (author)2015-08-05

I use arduino leonardo and the arduino code is too big. I think that the main problem is library. It is too big.

What should i do to resolve the problem?

lucasxavier11 (author)DrEwKo2015-12-26

The library I found is smaller than the other options. Are you using other libraries? Maybe you need an Arduino Mega for your project.

EternusV (author)2015-06-30

This is great! Are you still monitoring this post (in case I have questions xD)?

lucasxavier11 (author)EternusV2015-12-26

Yes I am happy to answer questions ( I wasn't getting comment notifications) and I hope your project was successful!

MichaelP160 (author)2015-12-26

My code is not connecting to

Lets see if we can troubleshoot it. Have you tested loading a page over the internet? Did you update the thingspeak api keys?

seamster (author)2015-01-02

Nicely done. Thanks for sharing this!

About This Instructable




More by lucasxavier11:Send SMS from Arduino over the Internet using ENC28J60 and Thingspeak
Add instructable to: