Arduino GSM SIM900 does not receiving messages - arduino

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);
}

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

Sending data from Arduino UNO to NodeMCU over UART and processing received data on NodeMCU

I'm trying to send data from Arduino UNO to NodeMCU via UART.
What I want to do is that when Arduino UNO sends "on" String to the NodeMCU, NodeMCU lights up its builtin LED, when "off" - it turns off.
I send data from Arduino UNO via standard Serial.println (). On the NodeMCU I use the SoftwareSerial library. I assigned rx and tx to pins D7 and D8 accordingly. Serial ports on Arduino(standard) and NodeMCU(SoftwareSerial) are set at 9600 baud rate.
Standard Serial port (USB) of NodeMCU is set to 115200.
I send the string that I receive from the Arduino to the standard serial port of the node (connected to usb)
The question is:
On the standard port of NodeMCU, which I view through the Arduino IDE, messages coming from the arduino are displayed, and displayed correctly (those that were sent), but the NodeMCU does not want to accept them in conditional statements and light up my LED. Why?
At the same time, when I remap the virtual UART to its original pins (connected to USB, GPIO3 and GPIO1, and send the same messages via usb through the COM port view in the Arduino IDE, the LED turns on and off as I programmed it.
Do you have any ideas why this is happening?
By the way, I do not lower voltage coming from Arduino RX and TX pins from 5V to 3.3V, but since messages are recived coorectly, I don't think that this is causing a problem.
Here's my code:
Arduino:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("on");
delay(1000);
Serial.println("off");
delay(1000);
}
NodeMCU:
#include <SoftwareSerial.h>
SoftwareSerial s(D7,D8);//rx,tx
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
s.begin(9600);
pinMode(D4,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
String str = s.readStringUntil('\n');
Serial.println(str);
if(str == "on"){
digitalWrite(D4, HIGH);
}
if(str=="off"){
digitalWrite(D4, LOW);
}
}
Screenshot of COM4:
Screenshot of COM4:
UPD: I tried using sending 1 or 0 as int value via Serial.write() and s.read() and it works, maybe the prolem is in String type somehow
You Use İt Maybe Work
#include <SoftwareSerial.h>
String text = "";
SoftwareSerial s(D7,D8);//rx,tx
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
s.begin(9600);
pinMode(D4,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
String str = s.readStringUntil('\n');
text = str
Serial.println(text);
if(text == "on"){
digitalWrite(D4, HIGH);
}
if(text =="off"){
digitalWrite(D4, LOW);
}
}

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.

Unable to SMS using AT commands for arduino uno

#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1);
void setup()
{
mySerial.begin(9600); // Setting the baud rate of GSM Module
Serial.begin(9600); // Setting the baud rate of Serial Monitor (Arduino)
delay(100);
}
void loop()
{
if (Serial.available()>0)
SendMessage();
if (mySerial.available()>0)
Serial.write(mySerial.read());
}
void SendMessage()
{
mySerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
delay(1000); // Delay of 1000 milli seconds or 1 second
mySerial.println("AT+CMGS=\"+1876xxxxxxx\"\r"); // Replace x with mobile number
delay(1000);
mySerial.println("I am SMS from GSM Module");// The SMS text you want to send
delay(100);
mySerial.println((char)26);// ASCII code of CTRL+Z
delay(1000);
}
I am trying to send a sms using SIM 800 RPI GSM ADD-on v2.3 module through the arduino platform however everything I try fails. Please assist and explain where i am going wrong. Thank you. My code is above. Thanks
You are missing a carriage return in "AT+CMGF=1".
Change "AT+CMGF=1" to "AT+CMGF=1\r"
Although having delays between command works and suffices the purpose but is not recommended.
It is preferable to catch and analyze the messages returned by the SIM800 especially in case of error has occurred.

Resources