hello to everyone
i want to control several relays by Node-RED server with Sim800L Internet and Arduino Uno
i config a vps and use MQTT protocol to connect the server , i use this library for making connection to server : https://github.com/elementzonline/SIM800_MQTT
i want to subscribe my board to a topic ( for sample the lights) and send commands from the server for turning on or off the lights , and by reading the serial string i can make gpio pins of Arduino Uno on or off
but i have a problem with this library :
#include "GSM_MQTT.h"
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2); // RX, TX
// GSM modem should be connected to Harware Serial
mySerial.begin(9600);
Serial.begin(9600);
i connect Sim800L to 0,1 TX/RX pins of arduino . but i don't know what should to do with software serial?
all MQTT logs are written with the software serial
Your code specifically says SoftwareSerial mySerial(3, 2); // RX, TX
so you connect your SIM800 to that. Tx>Rx and Rx>Tx.
If you need to connect GSM to hardware serial, and I'm not sure why that is but it's not a bad idea, then connect it to pins 0,1. This would mean that the commands relevant to GSM would be serial.print etc., and there is no need to use software serial. You just need to make up your mind what to do. You have already written the (hardware) serial.begin.
Thank you for answer
I read the library and as you said , all gsm commands are written with hardware serial and software serial is just for mqtt server logs . For a sample when I subscribe to "lights" topic , if I get a message from this topic like "TurnOn" or "TurnOff" , then this message is printed by software serial .
If I had a Arduino Mega, I could connect gsm to Uart1 and Suart to Uart2 , right?
I changed library message subrscriptions from software serial to hardware serial and i can see mqtt new messages in serial and it works like a charm ! but how can i check input serial strings? for sample to check if "LightOn" printed then make some digitalpin high?
Is this a good idea for controlling relays by reading serial mqtt subscription strings?
behzad_a:
I get a message from this topic like "TurnOn" or "TurnOff" , then this message is printed by software serial .
This sounds like nonsense. If by "printed" you mean a message on on the serial monitor, this is always done via hardware serial, no exceptions.
If I had a Arduino Mega, I could connect gsm to Uart1 and Suart to Uart2 , right?
Essentially, just get the names right. Mega has four hardware serial ports, and clearly, you would put GSM on one of those. I have no idea what a suart is but I guess it is a serial device and would go on one of the others.
I changed library message subrscriptions from software serial to hardware serial and i can see mqtt new messages in serial and it works like a charm ! but how can i check input serial strings? for sample to check if "LightOn" printed then make some digitalpin high?
I imagine this is just a matter of comparing the input string with a known char. Also check
http://forum.arduino.cc/index.php?topic=396450.0
Is this a good idea for controlling relays by reading serial mqtt subscription strings?
I have no idea of what this is about, and I think you should start a new thread on this.