Pages: [1]   Go Down
Author Topic: GSM library is eating my w's SIM900/Mega2560/DHT11/Nokia5110_lcd  (Read 2043 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

yup, GSM library is eating my "w" whenever I'll receive an SMS it is not displayed neither on my LCD nor through the serial console.
Though "W" are displayed... :/ (capitol ones)
and I'm completely out of ideas... not even know where to look...
im using Adafruit's Nokia 5110 LCD library (not my fav, but it has contrast option)
dht11 for temp, and sim900 sheild from elecfreaks

only modification was in the GSM3SoftSerial.cpp I've set value of "#define __RXPIN__  " under "mega" section to 52 for RX pin.

code is modified example, and there it is:

Code:

/*
 SMS receiver
*/
#include <dht11.h>

dht11 DHT111;
dht11 DHT112;
dht11 DHT113;

#define DHT11PIN1 16
#define DHT11PIN2 17
#define DHT11PIN3 18

// include the GSM library
#include <GSM.h>

#include <Adafruit_GFX.h>
#include <Adafruit_PCD8544.h>

// pin 9 - Serial clock out (SCLK)
// pin 10 - Serial data out (DIN)
// pin 11 - Data/Command select (D/C)
// pin 12 - LCD chip select (CS)
// pin 13 - LCD reset (RST)
Adafruit_PCD8544 display = Adafruit_PCD8544(9, 10, 11, 12, 13);



// PIN Number for the SIM
#define 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()
{
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
 
  display.begin();
  display.setContrast(40);
  //display.display(); // show splashscreen
  delay(100);
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(0,0);
  display.println("SMS Receiver");
  display.display();
  delay(500);
  display.clearDisplay();
 
 
  readout();
 
 
  // initialize serial communications and wait for port to open:


  Serial.println("SMS Receiver");
  display.setCursor(0,0);
  display.println("SMS Receiver"); 
  // connection state
  boolean notConnected = true;
 
  // Start GSM connection
  while(notConnected)
  {
    if(gsmAccess.begin(PINNUMBER)==GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
   
      display.clearDisplay();     
      display.setCursor(0,0);
      display.println("Not connected");
   
      delay(1000);
    }
  }
      display.clearDisplay();     
      display.setCursor(0,0);
      display.println("Start GSM");
      display.println("Waiting for SMS");
      display.display();
  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:");

    display.clearDisplay();
    display.setCursor(0,0);
    display.println("SMS from:");

    // Get remote number
    sms.remoteNumber(senderNumber, 20);
    Serial.println(senderNumber);
    display.println(senderNumber);
    display.display();
   

    // 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())
       {   
      display.print(c);
      Serial.print(c);
       }
      //display.clearDisplay();
      //display.println(".\n");
      display.display();
    Serial.println("\nEND OF MESSAGE");
   
    // Delete message from modem memory
    sms.flush();
    Serial.println("MESSAGE DELETED");
  }

  delay(1000);

}

void readout()
{
  display.setTextSize(1);
  display.setTextColor(BLACK);
  display.setCursor(0,0);
   
  int chk1 = DHT111.read(DHT11PIN1);
  switch (chk1)
  {
    case DHTLIB_OK:
                  Serial.println("Sensor#1: OK");
                  Serial.print("Tmp#1:");
                  Serial.print((float)DHT111.temperature, 2);
                  Serial.print("\tH#1(%):");
                  Serial.println((float)DHT111.humidity, 2);
                  display.print("Temp #1:");
                  display.println((float)DHT111.temperature, 0);
                  display.print("Hum #1:");
                  display.println((float)DHT111.humidity, 0);
                 
                  break;
    default:
                Serial.println("Error");
                break;
  }
  int chk2 = DHT112.read(DHT11PIN2);
  switch (chk2)
  {
    case DHTLIB_OK:
                Serial.println("Sensor#2: OK");
                  Serial.print("Tmp#2:");
                  Serial.print((float)DHT112.temperature, 2);
                  Serial.print("\tH#2(%):");
                  Serial.println((float)DHT112.humidity, 2);
                  display.print("Temp #2:");
                  display.println((float)DHT112.temperature, 0);
                  display.print("Hum #2:");
                  display.println((float)(DHT112.humidity+2), 0);               
                break;
    default:
                Serial.println("Error");
                break;
  }

  int chk3 = DHT113.read(DHT11PIN3);
  switch (chk3)
  {
    case DHTLIB_OK:
                Serial.println("Sensor#3: OK");
                  Serial.print("Tmp#3:");
                  Serial.print((float)DHT113.temperature, 2);
                  Serial.print("\tH#3(%):");
                  Serial.println((float)DHT113.humidity, 2);
                  display.print("Temp #3:");
                  display.println((float)DHT113.temperature, 0);
                  display.print("Hum #3:");
                  display.println((float)DHT111.humidity, 0);
                break;
    default:
                Serial.println("Error");
                break;
  } 
  display.display();
  delay(500);
  display.clearDisplay();
 
}

Logged

--
HE3r0
d(R)ive safe

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 216
Posts: 13668
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

a good way to tackle these kind of bugs is to minimize the sketch step by step to see when the problem (dis)appears.
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

a good way to tackle these kind of bugs is to minimize the sketch step by step to see when the problem (dis)appears.


I've verified it on the "sms_receive" example from GSM library, (stock, without modificaions) and it does the same thing.
no "w" (lowercase) letter in incoming messages, while "W" (uppercase) is there. not surre how much more I can cut the example to still have it working.
Logged

--
HE3r0
d(R)ive safe

Global Moderator
Netherlands
Online Online
Shannon Member
*****
Karma: 216
Posts: 13668
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

do you have a link to the GSM library used?
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

do you have a link to the GSM library used?
the library I'm using is that one attached to he arduino 1.0.4
so really nothing fancy :/

http://arduino.cc/en/Reference/GSM
Logged

--
HE3r0
d(R)ive safe

Offline Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've checked it on another mega 2560, on a freshly loaded arduino IDE 1.0.4 on completely different computer, and on the example sms_receive.
issue still there,
while receiveng text message, it displays all letters but lowercase "w"

Can somebody run that on theirs and verify if library is ok?
Logged

--
HE3r0
d(R)ive safe

Offline Offline
God Member
*****
Karma: 16
Posts: 597
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll give try ASAP, and let you know ...
For now, I don't use the library (and don't plan to use it, as I prefer to spare as much memory as I can, so, I don't really need it smiley-wink ) , and what I can tell is that "w" is received and displayed the way it should be .
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7189
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So the lower case w is missing from the text or replaced with a space or something else like a question mark? Are you sending English or non-English characters?
Logged


Offline Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So the lower case w is missing from the text or replaced with a space or something else like a question mark? Are you sending English or non-English characters?
lowercase "w" is missing completlely from the text (for ex. if I'll sent "it_works!" I'll get "it_orks!" and yes, I'm sending only English characters.
http://youtu.be/8X4Ki2DD8jY

(at this moment the only posibility to test it i have from online text service, since my prepaid stopped working, though it looked the same)
« Last Edit: May 27, 2013, 07:00:04 pm by he3r0 » Logged

--
HE3r0
d(R)ive safe

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey!! I'm doing something similar and i just wanted to ask you how did you decide the baud rate??
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I went with default example rates
Logged

--
HE3r0
d(R)ive safe

Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oh okay, thanks
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"Progress" so far...
I'm still not getting "w" on default GSM library while receiving SMS, since im not so "fluent" in libraries enough to fix it by myself.
I've found different library, and after tweaking ports, it started to work, (http://www.ebay.co.uk/itm/GSM-GPRS-Shield-For-Arduino-/230911052682?pt=LH_DefaultDomain_0&hash=item35c35f0b8a)

and in this one "w"-s are showing up IF it receives SMS...
I'm completely out of ideas...
Logged

--
HE3r0
d(R)ive safe

Offline Offline
Newbie
*
Karma: 0
Posts: 33
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The shield you have bought off ebay uses a SIM900 chip, as opposed to the M10 chip that the GSM library was designed for. Consider using a library dedicated to the SIM900 chip.

I'm not sure of how much of a difference it will make, but rather err on the side of caution.
Logged

Offline Offline
Newbie
*
Karma: 2
Posts: 39
...noob...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

1-nice timing ;P
2-not bought it off ebay.
3-its all about AT codes
4-both shields now completely stopped to respond :/ no matter what library im using.
Logged

--
HE3r0
d(R)ive safe

Pages: [1]   Go Up
Jump to: