Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Okay I want the push tempC value to *message but there is condtion if tempC < 33 || tempC > 38 I tried to convert

Okay I want the push tempC value to *message

but there is condtion if tempC < 33 || tempC > 38

I tried to convert to float but could not

My all problem is here

static const char *message = "Temp is "+tempC;

Check the code below and see if you can do somthin about it

I give up T_T

#include

#include

#define SENSOR_PIN 21 // ESP32 pin GIOP21 connected to DS18B20 sensor's DQ pin

OneWire oneWire(SENSOR_PIN);

DallasTemperature DS18B20(&oneWire);

float tempC; // temperature in Celsius

float tempF; // temperature in Fahrenheit

#include "twilio.hpp"

// Set these - but DON'T push them to GitHub!

static const char *ssid = "";

static const char *password = "";

// Values from Twilio (find them on the dashboard)

static const char *account_sid = "";

static const char *auth_token = "";

// Phone number should start with "+"

static const char *from_number = "";

// You choose!

// Phone number should start with "+"

static const char *to_number = "";

static const char *message = "Sent from my ESP32"tempC[19];

Twilio *twilio;

void setup() {

Serial.begin(9600); // initialize serial

DS18B20.begin(); // initialize the DS18B20 sensor

Serial.begin(115200);

Serial.print("Connecting to WiFi network '");

Serial.print(ssid);

Serial.println("'...");

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {

Serial.println("Connecting...");

delay(500);

}

Serial.println("Connected!");

twilio = new Twilio(account_sid, auth_token);

}

void loop() {

DS18B20.requestTemperatures(); // send the command to get temperatures

tempC = DS18B20.getTempCByIndex(0); // read temperature in C

tempF = tempC * 9 / 5 + 32; // convert C to F

Serial.print("Temperature: ");

Serial.print(tempC); // print the temperature in C

Serial.print("C");

Serial.print(" ~ "); // separator between C and F

Serial.print(tempF); // print the temperature in F

Serial.println("F");

delay(500);

String response;

bool success = twilio->send_message(to_number, from_number, message, response);

if (success) {

Serial.println("Sent message successfully!");

} else {

Serial.println(response);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data In Just 7 Chapters

Authors: Prof Marcus Vinicius Pinto

1st Edition

B09NZ7ZX72, 979-8787954036

More Books

Students also viewed these Databases questions