WR Bridge - Send SMS with temperature

Well folks, as I said in the review of this board, we will start a series of posts talking about Arduino + GSM and some other things.

In this first project we applied to the reading of a temperature sensor LM35, and send this data from time to time to a specific number of cell.

The first part is mounting the sensor range 10mV to LM35 each level at its output. The WS Bridge have available on your board analog inputs, where G = GND, VCC = V and S = entry. So to make this connection with the LM35 with his face forward we VDC - OUT - GND as in the following image:


Once the connections are made in the WS Bridge:


Connections made​​:



Now go to settings, have to do the following to configure the serial communication Arduino-GSM, for this we use the library SoftwareSerial. Right after that we start the modem and configure we need to send this command AT + CMGF = 1 , now its working in TEXT mode.

As we configured the modem, now we need to read the temperature, and convert this float value to a string, concatenate the string immediately after the sentence that we want to send ex:
Current temperature: X.
Thus we can only send a string that already has all complete data, it was not easy to understand here is the program to WS Bridge.

Remembering that we have put the number of cell which is indicated in the code:

  1. #include <SoftwareSerial.h>
  2. SoftwareSerial mySerial(3,2);
  3. float temperatura;
  4. String data;
  5. void setup()
  6. {
  7. mySerial.begin(19200);
  8. mySerial.println("\r");
  9. delay(1000);
  10. mySerial.println("AT+CMGF=1\r");
  11. delay(1000);
  12. }
  13. void loop()
  14. {
  15.   if (mySerial.available())
  16.     {
  17.       temperatura = (5.0 * analogRead(A0) * 100.0) / 1024;
  18.       int tempC1 = temperatura;
  19.       int tempC2 = (temperatura - tempC1) * 100;
  20.       char msg[24];
  21.       sprintf(msg, "%i.%i", tempC1,tempC2);
  22.      
  23.       data+="Temperatura atual: ";
  24.       data+=(msg);
  25.       mySerial.println("AT+CMGS=\"+VELL NUMBER\"\r");
  26.       delay(1000);
  27.       mySerial.println(data);
  28.       delay(1000);
  29.       mySerial.println((char)26);
  30.       data="";
  31.     }
  32.     delay(60000);
  33. }

Thus 1 in 1 minute we receive the cell the current temperature read by the Arduino using LM35 sensor

That's right guys, so leave any questions in the comments, we have another project soon applied for this card!

Nenhum comentário:

Postar um comentário