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?
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);
};
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
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".