Luiz Fernando da Silva Luiz Fernando da Silva - 1 year ago 239
Node.js Question

Arduino Uno + GSM Shield SIM900 TCP Client Dont Receive Data

I need to communicate an Arduino Uno R3 with Tinysine GSM Shield (sim 900 module) to a NodeJS Server Socket using TCP/IP sockets. So, the embedded system is a TCP client. I need the Arduino sends some message and receive the answer, using the received data to blink a different collor led. The tcp socket is working, and I can send the message, and process it in my server socket, but cant receive the answer (socket.write) in embedded (actually, I receive some fuzzy and variables caracters).

My Server Socket works fine, using the Hercules like client TCP, I could complete whole process.

I am using the SIM900 and InetGSM libraries with AT Commands to TCP connection (initially I dont want to use AT HTTP connection because It would change my system).

How do I can receive a legible message from my server socket? Thanks

Answer Source

I solved it!

When I send the AT+CIPSEND command, what I receive is a sequence of caracters with the AT response for the command and the data sent from my server.

So, what I need to do is storing it in an array and select the data position in this array or pick the answer in the right array position, like example below.

For example:

//Im waiting for char '1'
//After sending message with AT commands ...
char answer;

for(i = 0; i < 15; i++){ //15 is an random limit value that worked for me, I dont know why
    answer = (char);
    if(answer == '1'){
        Serial.println("I find the answer!");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download