# Connect SIM7000E to the Internet

**URL:** <https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489>\
**Category:** General\
**Tags:** function-node\
**Created:** [12 November 2022 11:06 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489 "2022-11-12T11:06:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [12 November 2022 11:06 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/1 "2022-11-12T11:06:33Z")

</div>

Hi.

I want to connect my SIM7000E to the internet.

When i send the following form a python file i get an "OK" responce from the modem.

```auto
send_at('AT+CGDCONT=1,\"IP\",\"'+APN+'\",\"0.0.0.0\",0,0','OK',1)

```

But when i send the following from a function node in Node-red i get an error from the SIM7000E modem.

```auto
var at_cmd = "AT + CGDCONT = ";
msg.payload = at_cmd + "1" + "," + '"IP"' +"," + '"internet"' + "," + '"0.0.0.0"' + "," + "0" + "," + "0" + "\r";
return msg;

```

When i send the above mention from a function node I get the following reply from the modem: AT + CGDCONT = 1,"IP","internet","0.0.0.0",0,0 followed by an error.

Kindly assist.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [12 November 2022 12:56 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/2 "2022-11-12T12:56:53Z")

</div>

How have you created your node?  
Can you publish it so other people can try it out and see if it works for them?

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [12 November 2022 14:05 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/3 "2022-11-12T14:05:54Z")

</div>

The following is the nodes. Basically a function node with a serial in and a serial out.

```auto
[
    {
        "id": "631f73ea1fff92a3",
        "type": "serial out",
        "z": "8f721a97cf856861",
        "name": "Serial-Out",
        "serial": "f4ec6284837b4b4c",
        "x": 1160,
        "y": 120,
        "wires": []
    },
    {
        "id": "36261b28659f2087",
        "type": "serial in",
        "z": "8f721a97cf856861",
        "name": "Serial-In",
        "serial": "f4ec6284837b4b4c",
        "x": 140,
        "y": 420,
        "wires": [
            [
                "7ebbcb39cd8a2533"
            ]
        ]
    },
    {
        "id": "75d63ecf7375cc1b",
        "type": "inject",
        "z": "8f721a97cf856861",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 200,
        "wires": [
            [
                "afeb1dae1c42364d"
            ]
        ]
    },
    {
        "id": "7ebbcb39cd8a2533",
        "type": "debug",
        "z": "8f721a97cf856861",
        "name": "debug 10",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 440,
        "y": 440,
        "wires": []
    },
    {
        "id": "afeb1dae1c42364d",
        "type": "function",
        "z": "8f721a97cf856861",
        "name": "AT+CPSI?",
        "func": "var at_cmd = \"AT+CPSI?\";\nmsg.payload = at_cmd + \"\\r\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 410,
        "y": 200,
        "wires": [
            [
                "631f73ea1fff92a3",
                "c5b679ad85becc56"
            ]
        ]
    },
    {
        "id": "c5b679ad85becc56",
        "type": "debug",
        "z": "8f721a97cf856861",
        "name": "debug 11",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 160,
        "wires": []
    },
    {
        "id": "e894131fc75ea9fc",
        "type": "function",
        "z": "8f721a97cf856861",
        "name": "Define pdp context",
        "func": "var at_cmd = \"AT + CGDCONT = \";\n\nmsg.payload = at_cmd + \"1\" + \",\" + '\"IP\"' +\",\" + '\"internet\"' + \",\" + '\"0.0.0.0\"' + \",\" + \"0\" + \",\" + \"0\" + \"\\r\";\n// msg.payload = 'AT + CGDCONT = 1, \"IP\", \"internet\", \"0.0.0.0\", 0, 0';\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 430,
        "y": 280,
        "wires": [
            [
                "631f73ea1fff92a3",
                "dcad3515115d6b57"
            ]
        ]
    },
    {
        "id": "7db0b828a23f1ec3",
        "type": "inject",
        "z": "8f721a97cf856861",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 280,
        "wires": [
            [
                "e894131fc75ea9fc"
            ]
        ]
    },
    {
        "id": "dcad3515115d6b57",
        "type": "debug",
        "z": "8f721a97cf856861",
        "name": "debug 12",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 700,
        "y": 220,
        "wires": []
    },
    {
        "id": "075412faf0940fc5",
        "type": "inject",
        "z": "8f721a97cf856861",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 60,
        "wires": [
            [
                "9f9edb4574b71834"
            ]
        ]
    },
    {
        "id": "9f9edb4574b71834",
        "type": "function",
        "z": "8f721a97cf856861",
        "name": "Get signal strenght",
        "func": "var at_cmd = \"AT+CSQ\";\nmsg.payload = at_cmd + \"\\r\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 430,
        "y": 60,
        "wires": [
            [
                "de6e8d0b283786bc",
                "631f73ea1fff92a3"
            ]
        ]
    },
    {
        "id": "de6e8d0b283786bc",
        "type": "debug",
        "z": "8f721a97cf856861",
        "name": "debug 13",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 40,
        "wires": []
    },
    {
        "id": "f62215e4e9f3ae6c",
        "type": "inject",
        "z": "8f721a97cf856861",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 340,
        "wires": [
            [
                "fedaf03bcd2ab44c"
            ]
        ]
    },
    {
        "id": "fedaf03bcd2ab44c",
        "type": "function",
        "z": "8f721a97cf856861",
        "name": "AT+CSOCKSETPN=1",
        "func": "var at_cmd = \"AT+CSOCKSETPN=1\";\nmsg.payload = at_cmd + \"\\r\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 440,
        "y": 340,
        "wires": [
            [
                "bc12585bf1a47de0",
                "631f73ea1fff92a3"
            ]
        ]
    },
    {
        "id": "bc12585bf1a47de0",
        "type": "debug",
        "z": "8f721a97cf856861",
        "name": "debug 15",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 720,
        "y": 340,
        "wires": []
    },
    {
        "id": "00dbc58b6af33db0",
        "type": "inject",
        "z": "8f721a97cf856861",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 120,
        "wires": [
            [
                "132579eed25c2ca4"
            ]
        ]
    },
    {
        "id": "132579eed25c2ca4",
        "type": "function",
        "z": "8f721a97cf856861",
        "name": "AT CREG",
        "func": "var at_cmd = \"AT+CREG?\";\nmsg.payload = at_cmd + \"\\r\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 120,
        "wires": [
            [
                "a79e049054f6af48",
                "631f73ea1fff92a3"
            ]
        ]
    },
    {
        "id": "a79e049054f6af48",
        "type": "debug",
        "z": "8f721a97cf856861",
        "name": "debug 17",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 100,
        "wires": []
    },
    {
        "id": "f4ec6284837b4b4c",
        "type": "serial-port",
        "serialport": "/dev/ttyS0",
        "serialbaud": "115200",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "waitfor": "",
        "dtr": "none",
        "rts": "none",
        "cts": "none",
        "dsr": "none",
        "newline": "\\n",
        "bin": "false",
        "out": "char",
        "addchar": "",
        "responsetimeout": "10000"
    }
]

```

[Edited by Moderator]

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 November 2022 17:28 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/5 "2022-11-12T17:28:55Z")

</div>

@SplitSecComp

> [@SplitSecComp](#):
>
> `msg.payload = at_cmd + "1" + "," + '"IP"' +"," + '"internet"' + "," + '"0.0.0.0"' + "," + "0" + "," + "0" + "\r";`

Any reason you don't code like this?

```auto
msg.payload = at_cmd + '1,"IP","internet","0.0.0.0",0,0\r';

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 November 2022 21:18 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/6 "2022-11-12T21:18:35Z")

</div>

> [@SplitSecComp](#):
>
> `send_at('AT+CGDCONT=1,\"IP\",\"'+APN+'\",\"0.0.0.0\",0,0','OK',1)`

What does `send_at()` do?

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [12 November 2022 21:24 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/7 "2022-11-12T21:24:06Z")

</div>

send\_at('AT+CGDCONT=1,"IP","'+APN+'","0.0.0.0",0,0','OK',1)

returns an ok if i send it in a python file....it works

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [12 November 2022 21:28 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/8 "2022-11-12T21:28:15Z")

</div>

I have tried this way as well...still get an error. First is what the debug returns from the function node that i send the last two is what the "Serial in" returns  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/e/6ed32a361170a17dfb15fc160f2e34f22efbcf12.png)

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [12 November 2022 21:32 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/9 "2022-11-12T21:32:09Z")

</div>

This is what the python file returns

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b9a66616a141375a19b8cf1d2a8d4262581733e8.png)

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [12 November 2022 21:33 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/10 "2022-11-12T21:33:15Z")

</div>

I am baffled 😀

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 November 2022 21:40 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/11 "2022-11-12T21:40:28Z")

</div>

There is the obvious difference that you have several spaces in the string shown in the debug. Try taking those out.

---

<div class="post-metadata">

**Author:** ![SplitSecComp](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/splitseccomp/32/39802_2.png) [@SplitSecComp](https://discourse.nodered.org/u/SplitSecComp)\
**Post date:** [13 November 2022 07:22 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/12 "2022-11-13T07:22:52Z")

</div>

Many thanks i have removed the spaces. Its now working 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [12 January 2023 10:34 UTC](https://discourse.nodered.org/t/connect-sim7000e-to-the-internet/70489/14 "2023-01-12T10:34:59Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
