Ivan Golubic
Published © Apache-2.0

Sending SMS with ESP32

I've built a device for sending SMS alerts if the temperature reaches a certain level.

BeginnerFull instructions provided2 hours1,052
Sending SMS with ESP32

Things used in this project

Hardware components

ESP32S
Espressif ESP32S
×1
SparkFun Atmospheric Sensor Breakout - BME280
SparkFun Atmospheric Sensor Breakout - BME280
×1

Software apps and online services

IoTaaP

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

ESP32 - BME280 Schematics

Code

Full code

C/C++
It needs Platformio and configuration with ESP32.

platformio.ini:
[env:release]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
lib_deps =
iotaap/IoTaaP OS@^5.2.2
adafruit/Adafruit BME280 Library@^2.2.2
board_build.partitions = partitions/default_fat.csv
#include <IoTaaP_OS.h>
#include <Arduino.h>
#include <ArduinoJson.h>
#include "Adafruit_BME280.h"

#define TOKEN "<iotaap-link-secret>" // IoTaaP Link Secret

Adafruit_BME280 bme;         // I2C
IoTaaP_OS iotaapOs("3.2.8"); // Defining Firmware version

// IoTaaP Network (MQTT) callback function
void callback(char *topic, byte *message, unsigned int length)
{
  Serial.println("-------#-----#-----#----------");
  Serial.println("Received data on the topic:");
  Serial.println(topic); // Print topic

  Serial.println("Data:");

  for (int i = 0; i < length; i++) // Print message
  {
    Serial.print((char)message[i]);
  }
  Serial.println();
  Serial.println("------#------#------#---------");
}

void setup()
{
  // BME280 related stuff
  unsigned status;
  status = bme.begin(0x76);
  if (!status)
  {
    Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
    while (1)
      delay(10);
  }

  iotaapOs.start(); // Start IoTaaP OS

  iotaapOs.startWifi();         // Connect to WiFi
  iotaapOs.startMqtt(callback); // Connect to MQTT broker
}

void loop()
{

  // Fetch measurements from BME280 sensor
  float temperatureC = bme.readTemperature();

  // If temperature is higher than 30°C, send SMS using IoTaaP SMS service, and subscribe to callback topic
  if (temperatureC > 30)
  {
    char message[50];
    sprintf(message, "Current temperature is: %.1f°C", temperatureC);
    iotaapOs.smsServiceSend(TOKEN, "+38599", message, "/pgiIzx7n/smsservice/response");
  }

  delay(5000);
}

Credits

Ivan Golubic

Ivan Golubic

1 project • 0 followers
Tech entrepreneur currently focused on building IoTaaP, a Swiss Army Knife for IoT, simplifying IoT development and deployment.
Thanks to Tomica Car.

Comments