Go Down

Topic: sim900 with gsm/gprs library reading temperature with sms?? (Read 67 times) previous topic - next topic

goreme

Hello

Code from openelectronics. The main question is how I can read Dallas/Maxim DS18B20 temperature sensor with this code? I have the libraries for dallas and gprs/gsm.
Anyone done this before?


Code: [Select]
include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;
char number[]="3921234567";
int value=0;
int value_old=0;
char message[40];
char value_str[4];
int pin=A0;
 
void setup()
{
 Serial.begin(9600);
 if (gsm.begin(2400))
 Serial.println("\nstatus=READY");
 else Serial.println("\nstatus=IDLE");
 value=analogRead(pin);
 value_old=analogRead(pin);
};
void loop()
{
 value=analogRead(pin);
 Serial.println(value);
  if(value<50&&value_old>=50){
   message[0]='\0';
   strcat(message,"ALLARME LOW, VAL=");
   itoa(value,value_str,10);
   strcat(message,value_str);
   sms.SendSMS(number,message);
 }
 value_old=value;
 delay(1000);
};

Nick_Pyner

You can't and you can bet nobody has done it before.

http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html


goreme

this code can read analog value and send it back sms..
can it modify that it read some other sensor(temperature) and send it back?
I know it is now at "as alert" mode
source site is here: openelectronics
I am using arduino nano and sim900A

Code: [Select]
#include "SIM900.h"
 #include <SoftwareSerial.h>
 #include "sms.h"
 SMSGSM sms;
 char number[]="3921234567";
 int value=0;
 int value_old=0;
 char message[40];
 char value_str[4];
 int pin=A0;
 void setup()
 
{
 
 Serial.begin(9600);
 
 if (gsm.begin(2400))
  Serial.println("\nstatus=READY");
 else Serial.println("\nstatus=IDLE");
 value=analogRead(pin);
 value_old=analogRead(pin);
 
};
 
void loop()
 
{
 value=analogRead(pin);
 Serial.println(value);
 if(value<50&&value_old>=50){
   message[0]='\0';
   strcat(message,"ALLARME LOW, VAL=");
   itoa(value,value_str,10);
   strcat(message,value_str);
   sms.SendSMS(number,message);
 }
 value_old=value;
 delay(1000);
};

dannable

Have you actually looked at the link Nick gave you? How to read the DS18B20?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

goreme

yes read it.. looks very difficult.
Is it able to use other sensors`?

Nick_Pyner

yes read it.. looks very difficult.
It isn't. The DS18B20 is an excellent device, well supported, and I believe rather easier to use than a SIM900. By the time you have the DS18B20 going, you will be better placed to understand how to merge its code with that you already have for the SIM900 and do what you want.

The code you have posted looks like it is intended for use with a thermistor but is pretty crude and may be incomplete. It may be just for a high/low alarm, and not to send actual temperatures, which is not what you implied as your "main question".

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy