Libraries clashes?

I have a sketch A writing an analogue signal to an 0.91 Inch OLED LCD Display. I have another sketch B that sends a SMS of an analogue signal to a cell phone. I then added the code from sketch B to sketch A to be able to send a SMS and display the signal to the Oled.
Compiling the sketch gives the error below:

E:\Arduino\My Programme\UPS_W5\UPS_W5.ino: In function 'void loop()':
E:\Arduino\My Programme\UPS_W5\UPS_W5.ino:115:5: error: 'updateSerial' was not declared in this scope
     updateSerial();

Seems to me the libaries clashes.

Here is the code:

UPS_W5.ino (6.4 KB)

Any ideas how to solve this problem.

Yea i think its the libraries that's causing the issue

You do not seem to have a function named updateSerial() in your sketch, hence the error

See if it compiles:

#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>

#include <SoftwareSerial.h>

SoftwareSerial mySerial(10, 11); // Example pins for software serial

#define OLED_ADDR 0x3C
Adafruit_SSD1306 display(-1);
#if (SSD1306_LCDHEIGHT != 64)
//#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif

const int RELAY_PIN = 3; // Example pin for relay
byte releAanStatus = LOW;
int ligSterkteGrensBo = 55;
int ligSterkteGrensOnder = 52;
String progNaam = "UPS_W5";

void setup() {
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH); // Turn the built-in LED on
  delay(2000);
  digitalWrite(LED_BUILTIN, LOW); // Turn the built-in LED off

  Serial.begin(9600);
  mySerial.begin(9600);

  display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
  display.clearDisplay();
  display.display();

  display.setTextSize(3);
  display.setTextColor(WHITE);
  display.setCursor(2, 10);
  display.print(progNaam.substring(4, 6) + "  " + ligSterkteGrensBo + "/" + ligSterkteGrensOnder);
  display.display();
  delay(1000);
}

void loop() {
  int ligSterkte = analogRead(A3);
  ligSterkte = map(ligSterkte, 0, 1023, 0, 100);

  display.clearDisplay();
  display.setTextSize(3);
  display.setTextColor(WHITE);
  display.setCursor(0, 20);
  display.print("Son ");
  display.print(ligSterkte);
  display.print("%");
  display.display();

  if (ligSterkte >= ligSterkteGrensBo && releAanStatus == LOW) {
    digitalWrite(LED_BUILTIN, HIGH);
    digitalWrite(RELAY_PIN, HIGH);
    releAanStatus = HIGH;
    sendSMS("Skakel sonpanele aan");
  }

  if (ligSterkte <= ligSterkteGrensOnder && releAanStatus == HIGH) {
    digitalWrite(LED_BUILTIN, LOW);
    digitalWrite(RELAY_PIN, LOW);
    releAanStatus = LOW;
    sendSMS("Skakel sonpanele af");
  }

  delay(2000);
}

void sendSMS(String message) {
  mySerial.println("AT+CMGF=1");
  updateSerial();
  mySerial.println("AT+CMGS=\"+27812708761\"");
  updateSerial();
  mySerial.println(message);
  updateSerial();
  mySerial.write(26);
}

void updateSerial() {
  delay(500);
  while (Serial.available()) {
    mySerial.write(Serial.read());
  }
  while (mySerial.available()) {
    Serial.write(mySerial.read());
  }
}

Thanks liaifat85, I use the code as you suggested and changed the SoftwareSerial mySerial(10, 11); // Example pins for software serial as you suggested.

I get the following when trying to send a SMS:

AT+CMGF=1

ERROR

RDY

+CFUN: 1

AT+CMGS="+27812708761"

ERROR

+CPIN: READY

Sending SMS is still not working.

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