GSM not responsing? - arduino

using gsm 6A module with arduino mega
gsm utx to 3 arduin
gsm rtx to 2 arduino
gsm gnd to gnd arduin
I am not getting any response from gsm and further AT and other command are not displaying.
#include <SoftwareSerial.h>
//Create software serial object to communicate with SIM800L
SoftwareSerial mySerial(3, 2); //SIM800L Tx & Rx is connected to Arduino #3 & #2
void setup()
{
//Begin serial communication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
//Begin serial communication with Arduino and SIM800L
mySerial.begin(9600);
Serial.println("Initializing...");
delay(1000);
mySerial.println("AT"); //Once the handshake test is successful, it will back to OK
updateSerial();
mySerial.println("AT+CSQ"); //Signal quality test, value range is 0-31 , 31 is the best
updateSerial();
mySerial.println("AT+CCID"); //Read SIM information to confirm whether the SIM is plugged
updateSerial();
mySerial.println("AT+CREG?"); //Check whether it has registered in the network
updateSerial();
}
void loop()
{
updateSerial();
}
void updateSerial()
{
delay(500);
while (Serial.available())
{
mySerial.write(Serial.read());//Forward what Serial received to Software Serial Port
}
while(mySerial.available())
{
Serial.write(mySerial.read());//Forward what Software Serial received to Serial Port
}
}

good day sir. the rx and tx of gsm module should also be connected to rx and tx ports of arduino mega.

Related

Arduino mega SIM800l special characters

I have a problem with the Arduino mega board and the SIM800L module I connect to the RX and TX pins of the module and when I enter the serial monitor it returns these characters, what could it be?
void setup() {
Serial.begin(9600);
//Begin serial communication with Arduino and SIM800L
Serial1.begin(9600);
}
void loop() {
delay(500);
while (Serial.available()) {
Serial1.write(Serial.read()); //Forward what Serial received to Software Serial Port
}
while(Serial1.available()) {
Serial.write(Serial1.read()); //Forward what Software Serial received to Serial Port
}
}
After so much searching and looking on the oscilloscope I have found the solution, In case you are using a LM2596 buck converter to power up the module, remember to common all the ground of the circuit.

Arduino Mega and RS485 Modbus Sensor

I'm trying to connect a soil sensor using RS485 communication to arduino mega and I can't get it to work. I'm using the SparkFun RS485 breakout: https://www.sparkfun.com/products/10124
I've connected TX to pin 18, RS to pin 19 and RTS to pin 8.
I've tried to adapt the code from here: https://www.youtube.com/watch?v=tBw15SfmuwI using the sensor's manufacturers default setting:
Modbus address fixed to 0
The communication configuration is 9600,N,8,1(9600bps, no check bit, 8 data bits,
1 stop bit)
Communication protocol is Modbus-RTU
While the addresses I need to read are 0x0000-0x0002.
However, I get random characters as output when I open the serial monitor "?", any idea why? I'd appreciate any help reading the sensor's output.
This is the code I've used:
#include <ModbusMaster.h>
#define MAX485_DE 8
#define MAX485_RE_NEG 8
ModbusMaster node;
void preTransmission () {
digitalWrite(MAX485_RE_NEG, 1);
digitalWrite(MAX485_DE, 1);
}
void postTransmission () {
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
}
void setup() {
pinMode(MAX485_RE_NEG, OUTPUT);
pinMode(MAX485_DE, OUTPUT);
digitalWrite(MAX485_RE_NEG, 0);
digitalWrite(MAX485_DE, 0);
Serial.begin(9600);
node.begin(0,Serial);
node.preTransmission(preTransmission);
node.postTransmission(postTransmission);
}
void loop() {
uint8_t resultMain;
resultMain = node.readInputRegisters(0x0000, 3);
if (resultMain == node.ku8MBSuccess) {
Serial.println("-------");
Serial.print("Temp: ");
Serial.println(node.getResponseBuffer(0x00) /100);
Serial.print("VWC: ");
Serial.println(node.getResponseBuffer(0x01) /100);
Serial.print("EC: ");
Serial.println(node.getResponseBuffer(0x02) /100);
}
}
The arduino mega has 3 serial ports:
Serial
Serial1
Serial2
You could think of it as Serial as Serial0 (the zero is never written). This port is hardwired to the USB port on the arduino mega.
Your RS485 breakout board is connected to Serial1. You may notice the screenprinting on the mega next to pins 18 and 19 says TX1 and RX1.
So when you initialize your node at this line:
node.begin(0,Serial);
you should pass it Serial1 instead of Serial
eg
node.begin(0,Serial1);

Arduino gsm shield not responding. gsmAccess.begin() doesnt work

I'm trying to get my arduino GSM shield working with the example "Send SMS" code provided. However, when I upload and compile the program, the serial monitor displays "SMS Messages Sender" and nothing else occurs.
I am using Arduino uno r3 and gsm sim 900. powered gsm with 5V 1.5A. I have connected arduino pins 7&8 to pins 7&8 of gsm. I have connected the gsm to ground too.
When I use SoftwareSerial.h it works. But I wish to use GSM.h library which now isn't working. Any help please
// include the GSM library
#include <GSM.h>
// PIN Number for the SIM
#define PINNUMBER ""
// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;
// Array to hold the number a SMS is retrieved from
char senderNumber[20];
void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("SMS Messages Receiver");
// connection state
bool notConnected = true;
// Start GSM connection
while (notConnected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
notConnected = false;
} else {
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}
void loop() {
char c;
// If there are any SMSs available()
if (sms.available()) {
Serial.println("Message received from:");
// Get remote number
sms.remoteNumber(senderNumber, 20);
Serial.println(senderNumber);
// An example of message disposal
// Any messages starting with # should be discarded
if (sms.peek() == '#') {
Serial.println("Discarded SMS");
sms.flush();
}
// Read message bytes and print them
while (c = sms.read()) {
Serial.print(c);
}
Serial.println("\nEND OF MESSAGE");
// Delete message from modem memory
sms.flush();
Serial.println("MESSAGE DELETED");
}
delay(1000);
}
i expected this code to enable me to receive message and i can modify it to store the message in variables
Your problem is probably the wiring.
Your board (Arduino UNO R3) has its UART (the one you intend to use when you define Serial.begin(9600) on pins 0 RX and 1 TX. See here for the schematic and picture below (top right corner with tags TX and RX).
Software emulated serial works because you're defining pins 7 and 8 to be the emulated UART TX and RX signals.

RobotDyn Uno wifi not working

I am using a Uno+WiFi R3 ATmega328P+ESP8266 board, 32Mb flash, USB-TTL CH340G, Micro-USB.
I am able to see the network SSID on my PC and to connect to it, but when I tried to upload a sketch using the Arduino IDE I am getting espcomm_upload_mem failed.
I used the sketch from https://robotdyn.com/uno-wifi-r3-atmega328p-esp8266-32mb-flash-usb-ttl-ch340g-micro-usb.html
void setup() {
Serial.begin(115200);
pinMode(13,OUTPUT);
delay(500);
Serial.println("AT+CIPMUX=1");
delay(2000);
Serial.println("AT+CIPSERVER=1,5000");
delay(2000);
Serial.println("AT+CIPSTO=3600");
delay(2000);
}
void loop() {
while(Serial.available()) {
char Rdata;
Rdata=Serial.read();
if(Rdata=='A'|Rdata=='a') {
digitalWrite(13,HIGH);
delay(50);
} else if(Rdata=='B'|Rdata=='b') {
digitalWrite(13, LOW);
delay(10);
digitalWrite(13, HIGH);
delay(10);
digitalWrite(13,LOW);
} else {
digitalWrite(13, LOW);
}
}
}
Robotdyn Uno/Mega + WiFi boards have switches to make serial connections of Atmega to Usb, esp8266 to USB and Atmega to esp8266. To flash the esp8266 the switches 5, 6, 7 must be ON. switch 7 is flashing mode. to communicate with esp8266 from Serial Monitor, switches 5 and 6 must be ON.
For communication of Atmega with the esp8266 switches 1 and 2 must be ON. In tis settings none of the MCUs is connected to USB. Therefore it is better to use SoftwareSerial on some Atmega pins and connect them with jumpers to the esp8266 header. The header is documented in the schematic.
The code in post is for the Atmega directly connected to esp8266 (switches 1,2)

Arduino GSM SIM900 does not receiving messages

Following URL will be appear my GSM module and it is included data sheet of the SIM900 module.
http://www.pennybuying.com/gsm-gprs-module-sim900-development-board-lbs-mms-support-arduino-uno-ttl-rs232.html
I have connected only RX,TX,GND and PWR pin between GSM module and Arduino mega board.
Sending a SMS is work properly but receiving SMS is doesn't work.
This is the Arduino Code of sending sms - (Reference - http://tronixstuff.com/2014/01/08/tutorial-arduino-and-sim900-gsm-modules/)
#include <SoftwareSerial.h>
SoftwareSerial SIM900(15,14);
char incoming_char=0;
void setup()
{
Serial.begin(19200); // for serial monitor
SIM900.begin(19200); // for GSM shield
SIM900power(); // turn on shield
delay(20000); // give time to log on to network.
SIM900.print("AT+CMGF=1\r"); // set SMS mode to text
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(100);
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}
void loop()
{
// Now we simply display any text that the GSM shield sends out on the serial monitor
Serial.println("loop");
if(SIM900.available() > 0)
{
Serial.print("waiting");
incoming_char=SIM900.read(); //Get the character from the cellular serial port.
Serial.print(incoming_char); //Print the incoming character to the terminal.
while(1){};
}
}
Try to add SIM900.print("AT+CMGD=1,4\r"); in your setup(). I faced similar problems and the reason was that sim-card memory for messages is full.
You wont get any messages or notification if there is no space in sim memory!
So your setuo loop would look like this
void setup()
{
Serial.begin(19200); // for serial monitor
SIM900.begin(19200); // for GSM shield
SIM900power(); // turn on shield
delay(20000); // give time to log on to network.
SIM900.print("AT+CMGF=1\r"); // set SMS mode to text
delay(100);
SIM900.print("AT+CMGD=1,4\r"); // Deletes all SMS saved in SIM memory
delay(100);
SIM900.print("AT+CNMI=2,2,0,0,0\r");
// blurt out contents of new SMS upon receipt to the GSM shield's serial out
delay(100);
}

Resources