i WANT my DS18b20 TO SEND data using my arduino and SIM900D to phone but i don't get any messages. ![]()
here is my code:
#include <SoftwareSerial.h>
#include <OneWire.h>
#include <DallasTemperature.h>
SoftwareSerial SIM900(0, 1);
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int x;
String textForSMS;
void setup()
{
SIM900.begin(19200);
SIM900power();
delay(20000); // give time to log on to network.
Serial.begin(9600);
Serial.println("Dallas Temperature IC Control Library Demo");
sensors.begin();
}
void SIM900power()
// software equivalent of pressing the GSM shield "power" button
{
digitalWrite(9, HIGH);
delay(1000);
digitalWrite(9, LOW);
delay(7000);
}
void sendSMS(String message)
{
SIM900.print("AT+CMGF=1\r"); // AT command to send SMS message
delay(100);
SIM900.println("AT + CMGS = \"+639125016648\""); // recipient's mobile number, in international format
delay(100);
SIM900.println(message); // message to send
delay(100);
SIM900.println((char)26); // End AT command with a ^Z, ASCII code 26
delay(100);
SIM900.println();
delay(5000); // give module time to send SMS
SIM900power(); // turn off module
}
void loop()
{
Serial.print(" Requesting temperatures...");
sensors.requestTemperatures();
Serial.print(sensors.getTempCByIndex(0));
x = (int) sensors.getTempCByIndex(0);
textForSMS = "Temperature is ";
textForSMS.concat(x);
textForSMS = textForSMS + " .";
sendSMS(textForSMS);
delay (60000);
}