# Send sms with node-RED

**URL:** <https://discourse.nodered.org/t/send-sms-with-node-red/13630>\
**Category:** General\
**Created:** [24 July 2019 03:39 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630 "2019-07-24T03:39:01Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jason\_tien](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jason\_tien](https://discourse.nodered.org/u/jason_tien)\
**Post date:** [24 July 2019 03:39 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630/1 "2019-07-24T03:39:01Z")

</div>

Hi everyone. I would like to use node-RED send the sms to my phone. My sms device is Maestro.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f3bfb8b9b5c935f24c436d33c5bd54b4147d4c20.png)

I write the format send sms to Maestro and they just display this.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4d183be4752205a16a0a40afbf5fcb3d9aa74817.png)  
I did not receive any message on my phone.

This is my code.

```auto
`[{"id":"b6b35c7e.3e30b","type":"tcp out","z":"cf481068.5cc7d","host":"192.168.1.1","port":"22","beserver":"client","base64":false,"end":false,"name":"","x":590,"y":620,"wires":[]},{"id":"803eb305.439d6","type":"inject","z":"cf481068.5cc7d","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":500,"wires":[["1ec5339b.4e72dc"]]},{"id":"7264934f.e3240c","type":"debug","z":"cf481068.5cc7d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":500,"wires":[]},{"id":"791ae714.afef28","type":"tcp request","z":"cf481068.5cc7d","server":"192.168.1.1","port":"22","out":"time","splitc":"0","name":"","x":470,"y":500,"wires":[["7264934f.e3240c"]]},{"id":"1ec5339b.4e72dc","type":"function","z":"cf481068.5cc7d","name":"","func":"msg={payload:\"AT#SENDSMS=\"<+60182090000>\"This is a test from Ethernet SMS\"}\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":620,"wires":[["791ae714.afef28","b6b35c7e.3e30b"]]}]`

```

TQVM.

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 July 2019 04:19 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630/2 "2019-07-24T04:19:58Z")

</div>

> [@jason\_tien](#):
>
> `[{"id":"b6b35c7e.3e30b","type":"tcp out","z":"cf481068.5cc7d","host":"192.168.1.1","port":"22","beserver":"client","base64":false,"end":false,"name":"","x":590,"y":620,"wires":[]},{"id":"803eb305.439d6","type":"inject","z":"cf481068.5cc7d","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":500,"wires":[["1ec5339b.4e72dc"]]},{"id":"7264934f.e3240c","type":"debug","z":"cf481068.5cc7d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":670,"y":500,"wires":[]},{"id":"791ae714.afef28","type":"tcp request","z":"cf481068.5cc7d","server":"192.168.1.1","port":"22","out":"time","splitc":"0","name":"","x":470,"y":500,"wires":[["7264934f.e3240c"]]},{"id":"1ec5339b.4e72dc","type":"function","z":"cf481068.5cc7d","name":"","func":"msg={payload:\"AT#SENDSMS=\"<+60182090000>\"This is a test from Ethernet SMS\"}\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":620,"wires":[["791ae714.afef28","b6b35c7e.3e30b"]]}]`

It would be pretty unusual for a device to be at port 22 on 192.168.1.1 - for many people that is their home gateway on their network

ALso based on your screenshot you have set the port to 22 (which is the port for SSH) - but it states that the default is 5555 - which is it ?

Craig

---

<div class="post-metadata">

**Author:** ![jason\_tien](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jason\_tien](https://discourse.nodered.org/u/jason_tien)\
**Post date:** [24 July 2019 04:25 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630/3 "2019-07-24T04:25:16Z")

</div>

> [@craigcurtin](#):
>
> ALso based on your screenshot you have set the port to 22 (which is the port for SSH) - but it states that the default is 5555 - which is it ?

If the default is 5555 the node red will show connection failed. I dont know wheather is tcp got problems or the function node.

jason

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 July 2019 04:39 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630/4 "2019-07-24T04:39:23Z")

</div>

So what is the default gateway on your network - and what are your network details (i.e. IP range, DNS etc etc)

---

<div class="post-metadata">

**Author:** ![jason\_tien](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jason\_tien](https://discourse.nodered.org/u/jason_tien)\
**Post date:** [24 July 2019 05:01 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630/5 "2019-07-24T05:01:01Z")

</div>

hi craig, i know my default gateway for pc one already. so what is the next step i show do?  
thanks.

jason

---

<div class="post-metadata">

**Author:** ![craigcurtin](https://avatars.discourse-cdn.com/v4/letter/c/94ad74/32.png) [@craigcurtin](https://discourse.nodered.org/u/craigcurtin)\
**Post date:** [24 July 2019 06:45 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630/6 "2019-07-24T06:45:33Z")

</div>

I have no idea what you wre saying in that last sentence. ?

Is you default gateway on the network 192.168.1.1. ?? if so then you can not do a TCP node to it (or you can but it will not do anything about sending an SMS for you !)

The reason why when you hit 192.168.1.1 on port 22 that is responds is that you have SSH enabled on your Firewall/router.

Is the SMS solution you are trying to use - a piece of hardware that you plug into your network - or is this an Internet based service ?

Craig

---

<div class="post-metadata">

**Author:** ![jason\_tien](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@jason\_tien](https://discourse.nodered.org/u/jason_tien)\
**Post date:** [24 July 2019 08:06 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630/7 "2019-07-24T08:06:13Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/510eecc85a909b23d2a620bf37e023b2e92b647c.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/efcb81c70bc234a9f20f2b98f6194a0db2bee77e.png)  
Why I will get this type of error?  
FYI, Below is the code in function node:  
msg={payload:"AT#SENDSMS="\<+60182090000\>",This is a test from Ethernet SMS^"}  
return msg;

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [24 July 2019 08:16 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630/8 "2019-07-24T08:16:46Z")

</div>

Take a look at your function node

```auto
msg={payload:"AT#SENDSMS="<+60182090000>"This is a test from Ethernet SMS"}

```

You are confusing string start and end with quotes in your string, try

```auto
msg={payload:'AT#SENDSMS="<+60182090000>"This is a test from Ethernet SMS'}

```

But you also need to send it to the correct port.

If you add a debug node to check what you are sending...

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [24 July 2019 08:16 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630/9 "2019-07-24T08:16:47Z")

</div>

What error are you refering to?

The debug output shows the TCP node has returned a Buffer object containing 362 bytes of data.

That is probably some text. If you click the button that says 'raw' it will try to display it as a string and you'll be able to read what it says.

---

<div class="post-metadata">

**Author:** ![mrdvt92](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mrdvt92/32/33122_2.png) [@mrdvt92](https://discourse.nodered.org/u/mrdvt92)\
**Post date:** [2 January 2021 02:27 UTC](https://discourse.nodered.org/t/send-sms-with-node-red/13630/10 "2021-01-02T02:27:21Z")

</div>

I wrote a JSON API Adapter to the Perl SMS::Send Architecture. So, if there is an SMS::Send driver for your provider, you can just use the JSON web service adapter. [SMS-Send-Adapter-Node-Red-0.05 - SMS::Send Adapter to Node-RED JSON HTTP request - metacpan.org](https://metacpan.org/release/SMS-Send-Adapter-Node-Red).

```auto
[{"id":"3313f548.d53dba","type":"inject","z":"bbbcee28.8891c","name":"Inject","topic":"","payload":"My SMS Text","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":1540,"wires":[["5cb3e4eb.f6d34c"]]},{"id":"3a6aed54.d74342","type":"debug","z":"bbbcee28.8891c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.sent","targetType":"msg","x":710,"y":1540,"wires":[]},{"id":"a9dfd541.a3b3f8","type":"http request","z":"bbbcee28.8891c","name":"SMS::Send","method":"POST","ret":"obj","paytoqs":false,"url":"https://127.0.0.1/cgi-bin/perl-SMS-Send-Adapter-Node-Red.cgi","tls":"","persist":false,"proxy":"","authType":"","x":490,"y":1540,"wires":[["3a6aed54.d74342","aec87ffa.ec17f"]]},{"id":"aec87ffa.ec17f","type":"debug","z":"bbbcee28.8891c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"statusCode","targetType":"msg","x":700,"y":1500,"wires":[]},{"id":"707cfb7e.11b714","type":"debug","z":"bbbcee28.8891c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":490,"y":1500,"wires":[]},{"id":"5cb3e4eb.f6d34c","type":"function","z":"bbbcee28.8891c","name":"payload formatter","func":"my_text = msg.payload;\nmsg.payload = {\n \"driver\" : \"VoIP::MS\",\n \"text\" : my_text,\n \"to\" : \"7035551212\",\n \"options\" : {\"key\" : \"value\"},\n };\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":1540,"wires":[["707cfb7e.11b714","a9dfd541.a3b3f8"]]}]

```
