Olá Pessoal...
Estou desenvolvendo um medidor de energia por SMS que irá me responder com o valor da potência medida e o valor da fatura.
Segue abaixo o código que estou trabalhando:
#include <SoftwareSerial.h>
//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 8
//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 7
//Create software serial object to communicate with SIM800
SoftwareSerial serialSIM800(SIM800_TX_PIN,SIM800_RX_PIN);
void setup() {
int fatura = 415;
int consumo = 876;
//Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
Serial.begin(9600);
while(!Serial);
//Being serial communication witj Arduino and SIM800
serialSIM800.begin(9600);
delay(1000);
String textSms;
Serial.println("Setup Complete!");
Serial.println("Sending SMS...");
//Set SMS format to ASCII
serialSIM800.println("AT+CMGF=1\r\n");
delay(1000);
//Send new SMS command and message number
serialSIM800.println("AT+CMGS=\"+5531985644009\"\r\n");
delay(1000);
//Send SMS content
serialSIM800.println("Fatura: R$");
serialSIM800.println(fatura);
serialSIM800.println("Consumo: kwh");
serialSIM800.println(consumo);
delay(1000);
//Send Ctrl+Z / ESC to denote SMS message is complete
serialSIM800.println((char)26);
delay(1000);
Serial.println("SMS Sent!");}
void loop() {
}
O que eu preciso implementar é uma função condicional que ao receber um SMS com a palavra "consulta" por exemplo, ele me responda um sms com as variaveis fatura e consumo.
Alguem pode me ajudar?
Tags:
Utilize float ao invés de int.
float fatura;
para mandar SMS
Serial.print(fatura,0);
o zero depois da virgula irá representar um numero inteiro 12, se for 2 irá acrescentar dois dígitos após a virgula: 12,45.
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por