# AT Commands how to check and respond on return messages from modem

**URL:** <https://discourse.nodered.org/t/at-commands-how-to-check-and-respond-on-return-messages-from-modem/70569>\
**Category:** General\
**Created:** [14 November 2022 11:21 UTC](https://discourse.nodered.org/t/at-commands-how-to-check-and-respond-on-return-messages-from-modem/70569 "2022-11-14T11:21:07Z")\
**Posts on this page:** 8\
**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:** [14 November 2022 11:21 UTC](https://discourse.nodered.org/t/at-commands-how-to-check-and-respond-on-return-messages-from-modem/70569/1 "2022-11-14T11:21:07Z")

</div>

I have a SIM7000E hat connected to my Raspberry. I want to connect the Raspberry to the internet using the SIM7000E hat.

I have manged to get everything working and get responses from the modem when i send the AT commands. I am however unable to get a way to resend the at command if the modem does not return an "OK" and/or respond with an error.

The modem returns two strings when i send the the at command like in the example below.

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

How can i resend the message if "OK" was not returned and/or when i get an error from the modem. it must only look at the "OK: when "AT+CGDCONT=1,"IP","internet","0.0.0.0",0,0" was send.

I hope that makes sense 🙂

---

<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:** [14 November 2022 14:28 UTC](https://discourse.nodered.org/t/at-commands-how-to-check-and-respond-on-return-messages-from-modem/70569/2 "2022-11-14T14:28:30Z")

</div>

What do you see from the modem for other commands?

---

<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:** [14 November 2022 14:59 UTC](https://discourse.nodered.org/t/at-commands-how-to-check-and-respond-on-return-messages-from-modem/70569/3 "2022-11-14T14:59:31Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/f/4f7f5f2ff513f9fd1566015c70866e46a4bf8e02.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:** [14 November 2022 15:00 UTC](https://discourse.nodered.org/t/at-commands-how-to-check-and-respond-on-return-messages-from-modem/70569/4 "2022-11-14T15:00:34Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/423e521426a34289af8b4d9a74a0d310eb4ed893.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:** [14 November 2022 15:01 UTC](https://discourse.nodered.org/t/at-commands-how-to-check-and-respond-on-return-messages-from-modem/70569/5 "2022-11-14T15:01:26Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/3/233bf436c2f1bcec1bd96243f7558d6af0b8815e.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:** [14 November 2022 15:02 UTC](https://discourse.nodered.org/t/at-commands-how-to-check-and-respond-on-return-messages-from-modem/70569/6 "2022-11-14T15:02:08Z")

</div>

The above is a couple of examples.

Sometimes when there is no reception or something is wrong it will return an error......or nothing....then i must have a way to resend the at command.

---

<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:** [14 November 2022 16:03 UTC](https://discourse.nodered.org/t/at-commands-how-to-check-and-respond-on-return-messages-from-modem/70569/7 "2022-11-14T16:03:01Z")

</div>

When you send the `AT+CGDCONT` you could start a Trigger node set to Send Nothing then after a delay (set to the timeout which you expect to receive OK in) to loop back to resend the command. On the output of the serial node use a Switch node to detect OK and use that to send msg.reset to the Trigger node to cancel the timeout.

---

<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:** [13 January 2023 16:03 UTC](https://discourse.nodered.org/t/at-commands-how-to-check-and-respond-on-return-messages-from-modem/70569/8 "2023-01-13T16:03:41Z")

</div>

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