hii .. i am trying to send a message containing the temperature value with the condition if the temperature value has reached 33 then sim800l will send a message containing the sensor value dht22 therein. I've managed to send a message with the sketch below, but the sensor value on the message sent to '!' this may be ascii code. can anyone help me ?. I really appreciate your help all. GBU
#include <dht.h>
#include <SoftwareSerial.h>
#define DATA_PIN 7
dht DHT;
SoftwareSerial SIM800L(2, 3);
int temp;
void setup() {
Â
Serial.begin(9600);
SIM800L.begin(9600);
while(!Serial);
  SIM800L.write("AT+CMGF=1\r\n");
  Serial.println("Ready");
  delay(1000);
 Â
}
void loop() {
int readData = DHT.read22(DATA_PIN);
temp = DHT.temperature;
  Serial.print("Temperature = ");
  Serial.print(temp);
  Serial.println(" *C ");
  delay(500);
 if(temp ==33){
 Â
  sendSMS();
Â
 }
}
void sendSMS(){
 delay(500);
 SIM800L.write("AT+CMGS=\"081241xxxx\"\r\n");
 delay(500);
 SIM800L.write("Temperature is over!!");
 delay(500);
 SIM800L.write("\r\n");
 delay(500);
 SIM800L.write("Temperature Value : ");
 delay(500);
 SIM800L.write(temp);
 delay(500);
SIM800L.write((char)26);
delay(500);
}
Read the documentation for write()
You should be able to see what happens on when you pass an integer to be sent and question yourself what it is really you want to send (hint see how you sent an ASCII representation in the loop)
If you are still stuck, come back here and we’ll help
PS: if you reach 33 your code will send hundreds of sms whilst at that Temperature and will stop if you go to 34 (or down below 32)
hii .. i am very grateful for already responding to this, i have managed to send the sensor value into the message, but it is true that you say the message sent repeatedly. if you can help me to sketch my sketch so that only send one message in two condition, sketch I attached below. but I thank you for your attention.
#include <dht.h>
#include <SoftwareSerial.h>
#define DATA_PIN 7
dht DHT;
SoftwareSerial SIM800L(2, 3);
int temp;
String tempS;
void setup() {
Â
Serial.begin(9600);
SIM800L.begin(9600);
while(!Serial);
  SIM800L.write("AT+CMGF=1\r\n");
  Serial.println("Ready");
  delay(1000);
}
void loop() {
int readData = DHT.read22(DATA_PIN);
temp = DHT.temperature;
tempS = String(temp);
  Serial.print("Suhu = ");
  Serial.print(temp);
  Serial.println(" *C ");
  delay(400);
 if(temp > 36){
  sendMessage();
 }
 if (temp < 35){
  safeCondition();
 }
}
void sendMessage(){
 delay(300);
 SIM800L.write("AT+CMGS=\"081241xxxx\"\r\n");
 delay(300);
 SIM800L.write("Suhu Melebihi Batas!!");
 delay(300);
 SIM800L.write("\r\n");
 delay(300);
 SIM800L.write("Nilai Suhu : ");
 delay(300);
 SIM800L.print(tempS);
 delay(100);
 SIM800L.write(" °C");
 delay(300);
SIM800L.write((char)26);
delay(300);
}
void safeCondition(){
 delay(300);
 SIM800L.write("AT+CMGS=\"081241xxxx\"\r\n");
 delay(300);
 SIM800L.write("Suhu ruangan dalam kondisi aman");
 delay(300);
 SIM800L.write("\r\n");
 delay(300);
 SIM800L.write("Nilai Suhu : ");
 delay(300);
 SIM800L.print(tempS);
 delay(300);
SIM800L.write((char)26);
delay(300);
}
using the String class to send basic text is really overkill.. you should not do that.... instead of using write to send your variable, just use print which will get you the ASCII representation...
when you want to do something only once in a program, you need to remember if you've done the action or not. For that we usually use a boolean variable that you set when the action is done and you test it before triggering the action of course
boolean actionWaitingTobeDone = true;
... later in the code
if (<condition for trigger> && actionWaitingTobeDone) {
 actionWaitingTobeDone =false;
 do your action here like sending the SMS
}
this will only do the action once. So you need to think of a strategy to reset the boolean after a while, maybe if the temperature goes back down below 34° for example (not just 36° because if you are close to 36° you will oscillate and send tons of messages)