Text message - Temparature

Hi,

I'm new to the forum and have a question. I'm working on a project to send the temperature and humidity via a text message (SMS).
So for this project I broke up the in two sections:
(1) Temperature & Humidity
(2) SMS
(3) Integrating 1 and 2

(1) Temperature & Humidity
For the temperature and humidity I'm using the SHT15 which I got working, below the code to that.
Maybe some one has a few pointers to that, but as stated it is working and I can read the temperature and humidity from the com port.

int temperatureCommand  = B00000011;  // command used to read temperature
int humidityCommand = B00000101;  // command used to read humidity

int clockPin = 8;  // pin used for clock
int dataPin  = 9;  // pin used for data
int ack;  // track acknowledgment for errors
int val;
float temperature;
float humidity;

void setup()
{
  Serial.begin(9600); // open serial at 9600 bps
}

void loop()
{
  // read the temperature and convert it to centigrades
  sendCommandSHT(temperatureCommand, dataPin, clockPin);
  waitForResultSHT(dataPin);
  val = getData16SHT(dataPin, clockPin);
  skipCrcSHT(dataPin, clockPin);
  temperature = (float)val * 0.01 - 40;
  Serial.print("temperature: ");
  Serial.print(temperature);

  // read the humidity
  sendCommandSHT(humidityCommand, dataPin, clockPin);
  waitForResultSHT(dataPin);
  val = getData16SHT(dataPin, clockPin);
  skipCrcSHT(dataPin, clockPin);
  humidity = -4.0 + 0.0405 * val + -0.0000028 * val * val;
  Serial.print(" humidity: ");
  Serial.println(humidity);
  delay(1800000); // wait for 200 milliseconds for next reading
}

// commands for reading/sending data to a SHTx sensor

// send a command to the SHTx sensor
void sendCommandSHT(int command, int dataPin, int clockPin)
{
  int ack;

  // transmission start
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  digitalWrite(dataPin, HIGH);
  digitalWrite(clockPin, HIGH);
  digitalWrite(dataPin, LOW);
  digitalWrite(clockPin, LOW);
  digitalWrite(clockPin, HIGH);
  digitalWrite(dataPin, HIGH);
  digitalWrite(clockPin, LOW);

  // shift out the command (the 3 MSB are address and must be 000, the last 5 bits are the command)
  shiftOut(dataPin, clockPin, MSBFIRST, command);

  // verify we get the right ACK
  digitalWrite(clockPin, HIGH);
  pinMode(dataPin, INPUT);
  ack = digitalRead(dataPin);
  if (ack != LOW)
    Serial.println("ACK error 0");
  digitalWrite(clockPin, LOW);
  ack = digitalRead(dataPin);
  if (ack != HIGH)
    Serial.println("ACK error 1");
}

// wait for the SHTx answer
void waitForResultSHT(int dataPin)
{
  int ack;

  pinMode(dataPin, INPUT);
  for (int i = 0; i < 100; ++i)
  {
    delay(20);
    ack = digitalRead(dataPin);
    if (ack == LOW)
      break;
  }
  if (ack == HIGH)
    Serial.println("ACK error 2");
}

// get data from the SHTx sensor
int getData16SHT(int dataPin, int clockPin)
{
  int val;

  // get the MSB (most significant bits)
  pinMode(dataPin, INPUT);
  pinMode(clockPin, OUTPUT);
  val = shiftIn(dataPin, clockPin, MSBFIRST);
  val *= 256; // this is equivalent to val << 8;

  // send the required ACK
  pinMode(dataPin, OUTPUT);
  digitalWrite(dataPin, HIGH);
  digitalWrite(dataPin, LOW);
  digitalWrite(clockPin, HIGH);
  digitalWrite(clockPin, LOW);

  // get the LSB (less significant bits)
  pinMode(dataPin, INPUT);
  val |= shiftIn(dataPin, clockPin, MSBFIRST);
  return val;
}

// skip CRC data from the SHTx sensor
void skipCrcSHT(int dataPin, int clockPin)
{
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  digitalWrite(dataPin, HIGH);
  digitalWrite(clockPin, HIGH);
  digitalWrite(clockPin, LOW);
}

(2) SMS
Here is where I'm having trouble. I have the SM5100B shield and connected it to the Arduino Board.
My first question is to look at the picture I have uploaded and have I connected it right?
Secondly and thats why I'm doubting the connection I have tried to send an text message and to check iff the board has an network connection. I found different approaches to on sending an text message on the forum, but none has worked for me so far. I need help.

What I have tried so far on code.

// Serial.println("at+cmgf=1");
// Serial.println("at+cmgs=\"214244****\"");
// Serial.print("This is my message");
// Serial.write(26); // this is ctrl-z



#include <SoftwareSerial.h>
SoftwareSerial cell(2,3);  // We need to create a serial port on D2/D3 to talk to the GSM module
char mobilenumber[] = "xxxxxxxxxx";  // Replace xxxxxxxx with the recipient's mobile number
void setup()

{  //Initialize serial ports for communication.

cell.begin(9600);

delay(35000); // give the GSM module time to initialise, locate network etc.

// this delay time varies. Use example 26.1 sketch to measure the amount
// of time from board reset to SIND: 4, then add five seconds just in case

}

void loop()
{
cell.println("AT+CMGF=1"); // set SMS mode to text
cell.print("AT+CMGS=");  // now send message...
cell.print(34); // ASCII equivalent of "
cell.print(mobilenumber);
cell.println(34);  // ASCII equivalent of "
delay(500); // give the module some thinking time
cell.print("They call me the count... because I like to count! Ah ha ha ha");   // our message to send
cell.println(26);  // ASCII equivalent of Ctrl-Z
delay(15000); // the SMS module needs time to return to OK status
do // You don't want to send out multiple SMSs.... or do you?
	{
		delay(1);
	}

while (1>0);
}

It compiles right, but i'm not receiving any message.

I need help thanks in advance!

Regards,
Jeroen

So your big problem is that your SMS messages aren't working yet.

One problem is that your sketch is sending blindly to the shield. Since it doesn't look at the responses from the shield you don't have much to go on when troubleshooting. Try writing a function that will display characters from the shield until it sees a newline. Call that after every command to the shield.

Have you tried the sample sketch from Sparkfun?

Have you tried the sample sketch from Sparkfun?
https://www.sparkfun.com/products/9607

Yes I have, the output does not make sence.

                  àù´Äùÿ
Startinàÿþ     ÿRaommunication...
    ÿRa

@johnwasser
Could you give me a little help with that? How would i approch this?

Yes I have, the output does not make sence.

Then, trying to write your own will produce no better results. You need to figure out what is interfering with the communication between the shield and the Arduino. Noise? Dirt? Poor contact?

jvdl:

Have you tried the sample sketch from Sparkfun?
https://www.sparkfun.com/products/9607

Yes I have, the output does not make sence.

                  àù´Äùÿ

Startinàÿþ     ÿRaommunication...
    ÿRa




Looks to me like the shield is set to use the hardware serial port to talk to the Arduino. That won't work if you are trying to use the hardware serial port (Serial) to communicate with Serial Monitor. The shield should have a way to move the serial I/O to other pins. Do that, then try the sparkfun example again.


@johnwasser
Could you give me a little help with that? How would i approch this?

johnwasser:

jvdl:

Have you tried the sample sketch from Sparkfun?
https://www.sparkfun.com/products/9607

Yes I have, the output does not make sence.

                  àù´Äùÿ

Startinàÿþ     ÿRaommunication...
    ÿRa




Looks to me like the shield is set to use the hardware serial port to talk to the Arduino. That won't work if you are trying to use the hardware serial port (Serial) to communicate with Serial Monitor. The shield should have a way to move the serial I/O to other pins. Do that, then try the sparkfun example again.


@johnwasser
Could you give me a little help with that? How would i approch this?

I'm a beginner and this is my first project. so please explain how one would move serial IO?

I'm a beginner and this is my first project.

Sending SMS's is not a beginner project.

PaulS:

I'm a beginner and this is my first project.

Sending SMS's is not a beginner project.

Well I have a IT background working with Linux/Solaris and I know basics in different programming languages.
So I like the challange.

So I like the challange.

Well, it's not that big a challenge to learn how to use SoftwareSerial instead of HardwareSerial (which is what Serial is an instance of).

Actually making that shield use other pins for serial communication may or may not be easy. The shield itself is a lousy design in that it doesn't provide for that capability. You'll need to use a breadboard and a bunch of jumper wires instead.

Ok, I'm gonna take it appart tonight and put it on the breadboard. However I do have the #include <SoftwareSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module. declared.

So I have took the smb apart and only connected pin 2 and 3 for the data and of course 5v and gnd. But still the same result. The output is not making sense even with the default program.
Could it be the SM5100B needs more power than usb can give it I read about SM5100B need 9v and usb can only give 5v.

Or does anyone have any other pointers?

PaulS:
Actually making that shield use other pins for serial communication may or may not be easy. The shield itself is a lousy design in that it doesn't provide for that capability. You'll need to use a breadboard and a bunch of jumper wires instead.

If you look at the schematic and the image of the board they do allow the RX/TX pins to be changed. Just de-solder current jumper settings and bridge to the other side so serial becomes D2 & D3 instead of D0 & D1.

09607-02.jpg

Clipboard-1.png

Riva:

PaulS:
Actually making that shield use other pins for serial communication may or may not be easy. The shield itself is a lousy design in that it doesn't provide for that capability. You'll need to use a breadboard and a bunch of jumper wires instead.

If you look at the schematic and the image of the board they do allow the RX/TX pins to be changed. Just de-solder current jumper settings and bridge to the other side so serial becomes D2 & D3 instead of D0 & D1.

Ok thanks for the help. So iff I understand you correctly I bridge the hw RX to the sw RX and hw TX to the sw TX. Then I can use the pin's 2 and 3 as the serial.

jvdl:
Ok thanks for the help. So if I understand you correctly I bridge the hw RX to the sw RX and hw TX to the sw TX. Then I can use the pin's 2 and 3 as the serial.

Yes but also remember to un-bridge the hw RX & hw TX

Riva:

jvdl:
Ok thanks for the help. So if I understand you correctly I bridge the hw RX to the sw RX and hw TX to the sw TX. Then I can use the pin's 2 and 3 as the serial.

Yes but also remember to un-bridge the hw RX & hw TX

How would I do that?

jvdl:
How would I do that?

By the looks of the image from the sparkfun site you will need a soldering iron & solder to change the RX/TX pins. The jumper pads look like they are where I circled with a blue line.

Riva:

jvdl:
How would I do that?

By the looks of the image from the sparkfun site you will need a soldering iron & solder to change the RX/TX pins. The jumper pads look like they are where I circled with a blue line.

Ok so that was obvious. Did'nt really knew it worked like that you only need to solder is to the left or right depending on which pin you want. So the jumpers are set correctly for pin 2 and 3 which is default I believe when I view the layout of the board.

So the module still is not working and I'm still nog satisfied on the power supply. Does any one know iff the board needs more than the 5v usb can give? I have read that the module needs 9v to operate correctly.

So the module still is not working and I'm still nog satisfied on the power supply. Does any one know iff the board needs more than the 5v usb can give? I have read that the module needs 9v to operate correctly.

I'm not sure how simple it is to disconnect the USB + power so you can run the board with a 9v supply and keep serial comms over USB. If your PC has a normal comm port maybe you could connect to that for serial monitoring or even use a second UNO if you have one.

So I have the a 9V battery connected and with multimeter I have checked all connections RX and TX, but still I got the weird ouput from the board just with the default program from sparkfun. I'm still using the software RX / TX. So does anyn one have any pointers?

I want to try the HW do i need extra programming for that or does it work as with SW?