GSM not responding to AT commands - arduino

I am using GSM 900A modem which requires 5V Supply. I am connecting it to Arduino UNO. I am giving supply to modem by arduino 5V and GND pin. I am connecting RXD pin to TX(pin 1) of arduino TXD pin to RX(pin 0) of arduino and GND to GND of arduino i.e. pin 14. I am running the basic example codes but GSM is not responding. I have also tried other softwares like Putty but I am unable to write any AT command Please help me. When I tested the modem using this code:
/*
This example tests to see if the modem of the
GSM shield is working correctly. You do not need
a SIM card for this example.
Circuit:
* GSM shield attached
Created 12 Jun 2012
by David del Peral
modified 21 Nov 2012
by Tom Igoe
http://www.arduino.cc/en/Tutorial/GSMToolsTestModem
This sample code is part of the public domain
*/
// libraries
#include <GSM.h>
// modem verification object
GSMModem modem;
// IMEI variable
String IMEI = "";
void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start modem test (reset and check response)
Serial.print("Starting modem test...");
if (modem.begin()) {
Serial.println("modem.begin() succeeded");
} else {
Serial.println("ERROR, no modem answer.");
}
}
void loop() {
// get modem IMEI
Serial.print("Checking IMEI...");
IMEI = modem.getIMEI();
// check IMEI response
if (IMEI != NULL) {
// show IMEI in serial monitor
Serial.println("Modem's IMEI: " + IMEI);
// reset modem to check booting:
Serial.print("Resetting modem...");
modem.begin();
// get and check IMEI one more time
if (modem.getIMEI() != NULL) {
Serial.println("Modem is functoning properly");
} else {
Serial.println("Error: getIMEI() failed after modem.begin()");
}
} else {
Serial.println("Error: Could not get IMEI");
}
// do nothing:
while (true);
}
I am getting this output on Serial Monitor for 9600 baud rate:
Starting modem test...ERROR, no modem answer. Checking IMEI...Modem's IMEI: 0 Resetting modem...Modem is functioning properly

I think it has to do with your supply, try using an adapter, that outputs a current of 500mA to 1A.

Related

Arduino ESP32-Wroom-32D to XBee Via BlueTooth

I have a few questions as to why my input isn't behaving correctly. I have 2 functioning scripts I've used:
ESP32 to Xbee using UART2, I open a serial connection to Xbee3 and type "+++" or AT Commands "ATID" and I am able to view to xbee's response via serial monitoring, works fine
Samsung Phone Serial App to ESP32 using Bluetooth, I'm also able to connect to the phone and type commands from phone to terminal and terminal to phone, works fine.
code for item 1:
//Arduino IDE
//ESP32 to Xbee UART2
//Select your modem:
#define TINY_GSM_MODEM_XBEE
// Set serial for debug console (to the Serial Monitor, speed 115200)
#define SerialMon Serial
// Set serial for AT commands (to the module)
// Use Hardware Serial on Mega, Leonardo, Micro
HardwareSerial SerialAT(2);
#define TINY_GSM_DEBUG SerialMon
void setup() {
// put your setup code here, to run once:
// Set console baud rate
SerialMon.begin(115200);
SerialAT.begin(9600);
delay(1000);
SerialAT.print("+++"); while (SerialAT.available()) {SerialMon.write(SerialAT.read());}
delay(1000);
}
void loop() {
// put your main code here, to run repeatedly:
// Access AT commands from Serial Monitor
SerialMon.println(F("***********************************************************"));
SerialMon.println(F(" You can now send AT commands"));
SerialMon.println(F(" Enter \"AT\" (without quotes), and you should see \"OK\""));
SerialMon.println(F(" If it doesn't work, select \"Both NL & CR\" in Serial Monitor"));
SerialMon.println(F("***********************************************************"));
while(true) {
if (SerialAT.available()) {
delay(1000);
SerialAT.println("ATID");
SerialMon.write(SerialAT.read());
}
if (SerialMon.available()) {
SerialAT.write(SerialMon.read());
}
delay(0);
}
}
Code for item 2:
//This example code is in the Public Domain (or CC0 licensed, at your option.)
//By Evandro Copercini - 2018
//
//This example creates a bridge between Serial and Classical Bluetooth (SPP)
//and also demonstrate that SerialBT have the same functionalities of a normal Serial
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
#define TINY_GSM_MODEM_XBEE
#define SerialMon Serial
HardwareSerial SerialAT(2);
#define TINY_GSM_DEBUG SerialMon
void setup() {
SerialMon.begin(115200);
SerialAT.begin(9600);
SerialBT.begin("ESP32testBLMfalse"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
// Access AT commands from Serial Monitor
if (Serial.available()) {
SerialBT.write(Serial.read());
}
if (SerialBT.available()) {
Serial.write(SerialBT.read());
}
delay(1000);
}
My issue was when I tried to combine these. See, I wanted to know if it was possible to open a Bluetooth connection with the ESP32 and send the AT commands from the phone app to the XBEE connected to it on UART2. This is what I'm currently doing. The command looks like it sends fine, but my serial output on reads:
"
The device started, now you can pair it with bluetooth!
10:44:04.546-> OK????????????????????????????????????????????????????????????????????????????????????
"
not sure if it's due to the bit rate, let me know if anyone can assist.
Thank you
#include "BluetoothSerial.h"
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
BluetoothSerial SerialBT;
#define TINY_GSM_MODEM_XBEE
#define SerialMon Serial
HardwareSerial SerialAT(2);
#define TINY_GSM_DEBUG SerialMon
void setup() {
SerialMon.begin(115200);
SerialAT.begin(9600);
SerialBT.begin("ESP32testBLMfalse"); //Bluetooth device name
delay(1000);
SerialAT.print("+++"); while (SerialAT.available()) {SerialMon.write(SerialAT.read());}
delay(1000);
Serial.println("The device started, now you can pair it with bluetooth!");
}
void loop() {
// Access AT commands from Serial Monitor
if (SerialBT.available()) {
delay(1000);
Serial.write(SerialAT.read()); //send phone input to xbee
}
if (SerialMon.available()) {
SerialAT.write(SerialBT.read()); //send xbee output to phone
SerialAT.write(SerialMon.read()); //send xbee output to serial monitor
}
delay(1000);
}
I was expecting
Samsung phone [input] --BlueTooth--> ESP32 --UART2-> Xbee
Xbee [output] --UART2--> ESP32 serial monitor --BLueTooth-->Samsung phone

Trouble accessing SIM card with MRK GSM 1400

I received yesterday my brand new Arduino MKR GSM 1400 and started playing around with today.
However, I'm having trouble stablishing the connection with the SIM card. I'm using the "ReceiveSMS" example from the MKRGSM library (code below), but the execution is getting stuck at the gsmAccess.begin(PINNUMBER) command.
Using AT commands and the debug mode, I got the following description for the error message:
AT+CPIN?
+CME ERROR: SIM not inserted
I have tried connecting with 3 different SIM cards, all tested beforehand with a smartphone and confirmed to be functional. I have tried removing the PIN, but still got the same error.
Does anybody have any idea on what could be going wrong?
Thanks in advance
Code:
// include the GSM library
#include <MKRGSM.h>
#include "arduino_secrets.h"
// Please enter your sensitive data in the Secret tab or arduino_secrets.h
// PIN Number
const char PINNUMBER[] = SECRET_PINNUMBER;
// initialize the library instances
GSM gsmAccess;
GSM_SMS sms;
// Array to hold the number a SMS is retreived 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 connected = false;
// Start GSM connection
while (!connected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
connected = true;
} else {
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
Serial.println("Waiting for messages");
}

How do I repeatedly send an AT command to a Bluetooth module arduino

I've been working on a project and want an Arduino uno with an HM-19 Bluetooth module to repeatedly send an AT command to the module then print the modules result in the serial monitor. I'm having trouble and it is only returning the number 53 and not the response 'OK'. Thanks for any insight you're able to give.
//import Software Serial to communicate over comms port
#include <SoftwareSerial.h>
// 0 and 1 are the tx and rx pins ans should be where the hm-19 is
// may be 0,1 instead
SoftwareSerial HM19(1,0);
void setup() {
// begin serial monitor and wait for something(?, found online)
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
//tell user it's started
Serial.println("Started");
//I believe this begins the monitor for the HM-19
HM19.begin(9600);
delay(1000);
}
void loop() {
// give user status report
delay(1000);
Serial.println("Sending an AT command...");
// need to find if this is how you send an AT command (currenty send 'AT' as a test)
HM19.write("AT\r");
delay(30);
//wait for the HM19 to respond then print it out
int HMresponse = 0;
if (HM19.available()){}
HMresponse = HM19.read();
Serial.println(HMresponse);
}

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.

Communicating serially through arduino xbeeshield

I have a ladyada xbee adapter on the computer side and an arduino xbeeshield which I am trying to communicate with over wireless. Both xbees are configured correctly in that I can receive data from the xbeeshield to the computer. However it doesn't work the other way i.e. xbeeshield does not echo a byte sent from the computer serially. Any idea what I might be doing wrong? (Note: When I connect the arduino board to the computer using USB cable, the echo program works just fine. It seems to be a problem in wireless mode only)
processing code
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
Serial.print((char) Serial.read());
delay(10);
}
}
I am just sending keystrokes from computer and waiting for a reply. I am not getting any.
I use the code I answered to the following question in regards to sending serial bytes from PC to Xbee/Arduino. It's been working fine for months. Ensure you've configured both your Xbee modules on the PC and Arduino side. Ensure your PAN ID's are the same as well.
Arduino making decision according to a packet received from serial port
What version of the Xbee modules are you using? My code works with Series 1 but should work with newer versions as well.
Try using softwareSerial library and connecting Tx and Rx to pin 4 and 2. Run the following sketch and tell me what happens. Change the Baudrate value to match your own
#include <SoftwareSerial.h>
uint8_t pinRx = 2 , pinTx = 4; // the pin on Arduino
long BaudRate = 57600; // Please set your Baudrate. It should match the one in XC-TU
char GotChar, getData;
// Xbee SoftwareSerial initialization
SoftwareSerial xbee(pinRx, pinTx); // RX, TX
void setup()
{
Serial.begin(9600);
Serial.println( "Welcome to the XBee Communication Test" );
Serial.print("BaudRate:");
Serial.println(BaudRate);
Serial.print(" Rx Pin#");
Serial.println(pinRx,DEC);
Serial.print(" Tx Pin#");
Serial.println(pinTx,DEC);
// set the data rate for the SoftwareSerial port
xbee.begin( BaudRate );
xbee.println("Setup Completed!");
}
void loop()
{
if (Serial.available())
{
GotChar = Serial.read();
xbee.print(GotChar);
Serial.print(GotChar);
}
while (xbee.available()>0)
{
Serial.println("Ohohoh");
getData = xbee.read();
Serial.print(" Received: );
Serial.print(getData);
Serial.println();
if(getData == 'a')
{
Serial.println(" sbam");
}
else if(getData == 'b')
{
Serial.println(" sbo");
}
}
}
Upload the program and open the serial monitor. Do you get the 'Setup completed' message on the computer? What happens if you send 'a' or 'b' from the Pc to the Arduino?

Resources