Simulation problem using proteus

NBH

Newbie
Joined
Oct 31, 2024
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
6
Can someone help me fix this problem I don't understand the issue there is Simulation errors that I got and the schematic

And this is the code that I used


C++:
#include <SoftwareSerial.h>
#include <DHT.h>

// Define pins and variables
#define DHTPIN 2          // DHT11 data pin connected to digital pin 2
#define DHTTYPE DHT11     // DHT 11 sensor
DHT dht(DHTPIN, DHTTYPE);

// Initialize SIM800L on software serial
SoftwareSerial sim800l(10, 11);  // RX, TX (connect to TX and RX of SIM800L)

void setup() {
  Serial.begin(9600);          // Serial monitor for debugging
  sim800l.begin(9600);       // SIM800L baud rate
  dht.begin();
  delay(1000);                 // Allow time for SIM800L to initialize

  // Test SIM800L connection
  sim800l.println("AT");
  delay(1000);
  if (sim800l.available()) {
    Serial.println("SIM800L Ready!");
  } else {
    Serial.println("SIM800L not responding");
  }
}

void loop() {
  // Read temperature and humidity
  float humidity = dht.readHumidity();
  float temperature = dht.readTemperature();

  // Check if data is valid
  if (isnan(humidity) || isnan(temperature)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  // Format message
  String message = "Temp: " + String(temperature) + "°C, Humidity: " + String(humidity) + "%";
  Serial.println("Sending SMS: " + message);

  // Send SMS
  sendSMS("+1234567890", message);  // Replace with recipient phone number

  delay(60000);  // Send data every 60 seconds
}

// Function to send SMS
void sendSMS(String phoneNumber, String message) {
  sim800l.println("AT+CMGF=1");       // Set SMS mode to text
  delay(1000);
  sim800l.print("AT+CMGS=\"");
  sim800l.print(phoneNumber);         // Phone number
  sim800l.println("\"");
  delay(1000);
  sim800l.println(message);           // SMS content
  delay(100);
  sim800l.write(26);                  // ASCII code for CTRL+Z to send
  delay(1000);

  Serial.println("SMS sent!");
}
 

Cookies are required to use this site. You must accept them to continue using the site. Learn more…