'SoftwareSerial' does not name a type

Hi, I'm having a minor problem with my code that I'm trying to sort out. I have this code. I'm currently trying to develop a gps tracker and I'm involving a LCD display, LM35. ESP8266 and an Arduino Uno. Everything has been working fine using this code until I put in void printGpsGsm(), and then I get the following errors at the bottom

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <TinyGPS++.h>

//I2C pins declaration
LiquidCrystal_I2C lcd(0x27, 16, 2);
SoftwareSerial Serial serial_connection (11, 10);
TinyGPSPlus gps;

const int sensor = A1; // Assigning analog pin A1 to variable 'sensor'
float tempc;  //variable to store temperature in degree Celsius
float tempf;  //variable to store temperature in Fahreinheit 
float vout;  //temporary variable to hold sensor reading

#include "WiFiEsp.h"

// Emulate Serial1 on pins 6/7 if not present
#ifndef HAVE_HWSERIAL1
#include "SoftwareSerial.h"
SoftwareSerial Serial1(6, 7); // RX, TX
#endif

char ssid[] = "";            // your network SSID (name)
char pass[] = "";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
int reqCount = 0;                // number of requests received

WiFiEspServer server(80);

void setup()
{
  // initialize serial for debugging
  Serial.begin(115200);
  // initialize serial for ESP module
  Serial1.begin(9600);
  // initialize ESP module
  WiFi.init(&Serial1);

pinMode(sensor,INPUT); // Configuring pin A1 as input
Serial.begin(9600);

lcd.begin();//Initializing display
lcd.backlight();//To Power ON the back light
//lcd.backlight();// To Power OFF the back light

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  Serial.println("You're connected to the network");
  printWifiStatus();
  printGpsGsm();
  
  // start the web server on port 80
  server.begin();
}


void loop()
{
  lcd.setCursor(0,0); //Defining positon to write from first row,first column .
lcd.print(" Message");
delay(1000);//Delay used to give a dynamic effect
lcd.setCursor(0,1);  //Defining positon to write from second row,first column .
lcd.print(" Device " );
delay(5000); 
lcd.clear();//Clean the screen
lcd.setCursor(0,0); 
lcd.print(" Project ");
lcd.setCursor(0,1);
lcd.print(" 2021 ");
lcd.clear();
delay(3000); 

vout=analogRead(sensor);
vout=(vout*500)/1023;
tempc=vout; // Storing value in Degree Celsius
tempf=(vout*1.8)+32; // Converting to Fahrenheit 
lcd.setCursor(0,0);
lcd.print(" Temparature ");
delay(3000);
lcd.setCursor(0,0);
lcd.print("Degrees=C");
lcd.print(tempc);
lcd.setCursor(0,1);
lcd.print("Fahrenheit=F");
lcd.print(tempf);
delay(10000); //Delay of 10 seconds for ease of viewing in serial monitor
lcd.clear();
delay(5000);

  // listen for incoming clients
  WiFiEspClient client = server.available();
  if (client) {
    Serial.println("New client");
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        Serial.write(c);
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          Serial.println("Sending response");
          
          // send a standard http response header
          // use \r\n instead of many println statements to speedup data send
          client.print(
            "HTTP/1.1 200 OK\r\n"
            "Content-Type: text/html\r\n"
            "Connection: close\r\n"  // the connection will be closed after completion of the response
            "Refresh: 20\r\n"        // refresh the page automatically every 20 sec
            "\r\n");
          client.print("<!DOCTYPE HTML>\r\n");
          client.print("<html>\r\n");
          client.print("Title"</h1>\r\n");
          client.print("Name\n\n");
          client.print("<img src = ”https://tractive.com/static/images/sections/tractive-dog-lte-live-tracking.jpg”>");
          client.print("Requests received: ");
          client.print(++reqCount);
          client.print("
\r\n");
          client.print("Analog input A0: ");
          client.print(analogRead(0));
          client.print("
\r\n");
          client.print("</html>\r\n");
          break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        }
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(10);

    // close the connection:
    client.stop();
    Serial.println("Client disconnected");
  }
}
void printWifiStatus()
{
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);
  
  // print where to go in the browser
  Serial.println();
  Serial.print("To see this page in action, open a browser to http://");
  Serial.println(ip);
  Serial.println();
}

void printGpsGsm()
{
  while(serial_connection.available())
  {
    gps.location.isUpdated();
}
if (gps.location.isUpdated())
{
 Serial.begin(9600);
 Serial.print("\r");
 delay(1000);
 Serial.print("AT+CMGF=1\r");
 delay(1000);
 Serial.print("AT+CMGS=\"35385243321\"\r");
 delay(1000);
 Serial.print("HELP! Please Check!");
 Serial.print("www.google.com.ph/naga/place");
 Serial.print(gps.location.lat(), 6);
 Serial.print(",");
 Serial.print(gps.location.lat(), 6);
 Serial.print("\r");
 delay(1000);
 Serial.print((char) 26);
 delay(1000);
 Serial.write(0x1A);
 Serial.write(0x00);
 Serial.write(0x0A);
 delay(1000);
}
}
Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

Tracker_2021:7:1: error: 'SoftwareSerial' does not name a type; did you mean 'SoftwareSerial_h'?

 SoftwareSerial Serial serial_connection (11, 10);

 ^~~~~~~~~~~~~~

 SoftwareSerial_h

C:\Users\Owner\Documents\Arduino\Tracker_2021\Tracker_2021.ino: In function 'void printGpsGsm()':

Tracker_2021:175:9: error: 'serial_connection' was not declared in this scope

   while(serial_connection.available())

         ^~~~~~~~~~~~~~~~~

C:\Users\Owner\Documents\Arduino\Tracker_2021\Tracker_2021.ino:175:9: note: suggested alternative: 'serialEventRun'

   while(serial_connection.available())

         ^~~~~~~~~~~~~~~~~

         serialEventRun

exit status 1

'SoftwareSerial' does not name a type; did you mean 'SoftwareSerial_h'?

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I'm just wondering could someone solve this issue for me? Thank you

Maybe it works if you get rid of Serial in SoftwareSerial Serial serial_connection

And you seem to be missing the include.

Sorry that was a mistake putting in Serial in there, it shouldn't have been in there but I still have the same issues when I take it out also

And my second point?

sterretje:
And my second point?

The #include is it? I'm not sure which #include you are talking about, I'm sorry

#include <SoftwareSerial.h>

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