NodeJS : Send SMS via GSM device connected at serial port

Your script

var SerialPort = require("serialport").SerialPort
var serialPort = new SerialPort("/dev/ttyUSB0", {
     baudrate: 9600,  dataBits: 8,  parity: 'none',  stopBits: 1, flowControl: false, xon : false, rtscts:false, xoff:false, xany:false, buffersize:0
});

serialPort.on("open", function () {
    console.log('Serial communication open');
    serialPort.write("AT^SYSCFG=13,1,3FFFFFFF,2,4");
    serialPort.write('\r');
    serialPort.on('data', function(data) {
        console.log("Received data: " + data);
    });
    gsm_message_sending(serialPort, "test2", "<you phone number>");
});

function gsm_message_sending(serial, message, phone_no) {
    serial.write("AT+CMGF=1");
    serial.write('\r');
    serial.write("AT+CMGS=\"");
    serial.write(phone_no);
    serial.write('"')
    serial.write('\r');
    serial.write(message); 
    serial.write(Buffer([0x1A]));
    serial.write('^z');
}

works perfectly for me with E3131 modem. As you can see, I changed a bit the script so that it only emits one sms and prints the messages:

Received data: AT^SYSCFG=13,1,3FFFFFFF,2,4
Received data:
OK

Received data: AT+CMGF=1
Received data:
OK

Received data: AT+CMGS="
Received data: 0671358943
Received data: "
Received data:
>
Received data: test2
Received data:
Received data: ^z
Received data:
+CMGS: 28

OK

Tags:

Sms

Node.Js