Automatically Sending an Alert with GSM

Hi,

My name is Jack Conrath. I am a senior in high school working on an engineering project developing a solution to kids dying in hot cars (pediatric vehicular hyperthermia). One part of our project is sending an alert (text or call) to emergency services and parents when a device that we made detects that the kid is in danger. Does anyone know how can we automatically send out a text and call when a CO2 and temperature sensor detect that the child is in danger? Any help would be greatly appreciated!

Lots of tutorials posted on line show how to connect an Arduino with a GSM module, and send messages. The search phrase "arduino gsm" will find them.

Likewise for connecting an Arduino and the sensor of your choice.

Here is an example code that demonstrates how to read data from a CO2 and temperature sensor and send an SMS message using a GSM module when the sensor values exceed the threshold values:

#include <SoftwareSerial.h>
#include <DHT.h>

#define DHTPIN 7
#define DHTTYPE DHT11

#define CO2PIN A0

#define THRESHOLD_CO2 1000
#define THRESHOLD_TEMP 40

SoftwareSerial gsmSerial(2, 3); // RX, TX
DHT dht(DHTPIN, DHTTYPE);

void setup() {
  Serial.begin(9600);
  gsmSerial.begin(9600);

  dht.begin();
}

void loop() {
  float temperature = dht.readTemperature();
  int co2 = analogRead(CO2PIN);

  Serial.print("Temperature: ");
  Serial.println(temperature);
  Serial.print("CO2: ");
  Serial.println(co2);

  if (temperature > THRESHOLD_TEMP || co2 > THRESHOLD_CO2) {
    sendSMS("+1234567890", "Child in danger!");
  }

  delay(5000);
}

void sendSMS(String phoneNumber, String message) {
  gsmSerial.println("AT+CMGF=1");
  delay(1000);

  gsmSerial.print("AT+CMGS=\"");
  gsmSerial.print(phoneNumber);
  gsmSerial.println("\"");
  delay(1000);

  gsmSerial.println(message);
  delay(1000);

  gsmSerial.write(26);
  delay(1000);
}

This code reads data from a DHT11 temperature and humidity sensor and a CO2 sensor connected to pin A0. It compares the sensor values against the threshold values for temperature and CO2 and sends an SMS message to the phone number specified in the sendSMS function if the sensor values exceed the thresholds.

Note that this code assumes that you have a GSM module connected to your Uno board and that you have configured it to work with your cellular network. You may need to modify the code to work with your specific GSM module and network.
Z

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.