softwareSerial was not declared in this scope

WHen I try to upload it it says, “softwareSerial” was not declared in this scope

Hello and welcome to the Blynk forum. You didn’t give any details as to the type of device you are using, but your error is most likely sketch related (bad programming and/or syntax). Google “was not declared in this scope” for better understanding.

Make sure you have #include <SoftwareSerial.h> in the proper place at the beginning of your sketch.

I do look:

Please post your code properly in an accessible format… I can’t compile a picture to test :wink:

#include <SoftwareSerial.h>
#include <BlynkSimpleSerialBLE.h>

// You should get Auth Token in the Blynk App. Go to the Project Settings (nut icon).
const int groundpin = 18;             // analog input pin 4 -- ground
const int powerpin = 19;              // analog input pin 5 -- voltage
const int xpin = A4;                  // x-axis of the accelerometer
const int ypin = A2;                  // y-axis
const int zpin = A0;                  // z-axis (only on 3-axis models)
SoftwareSerial SerialBLE(10, 11); // RX, TX
char auth[] = "d7101319e24d4c61af2429ec19ce35d6"; 
int maximum = 0;
int maxmax = 0;
int xValue = 0;
int yValue = 0;
int zValue = 0;
void setup() 
{
    // initialize the serial communications:
  Serial.begin(9600);
Blynk.begin(softwareSerial, auth);
  // Provide ground and power by using the analog inputs as normal
  // digital pins.  This makes it possible to directly connect the
  // breakout board to the Arduino.  If you use the normal 5V and
  // GND pins on the Arduino, you can remove these lines.
  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW);
  digitalWrite(powerpin, HIGH);
}
void loop() {
  xValue = analogRead(xpin);
  // print a tab between values:
  //Serial.print("\t");
  yValue = analogRead(ypin);
  // print a tab between values:
  //Serial.print("\t");
  zValue = analogRead(zpin);
  //Serial.println();
  // delay before next reading:
  delay(500);
  maximum = max (xValue,yValue);
 maxmax = max(maximum,zValue);
 Serial.print ("maximum Final");
  Serial.println ( maximum);

Blynk.run();
// You can inject your own code here. 
// Remember to avoid delay() function!
}

I think it is
Blynk.begin(SoftwareSerial, auth);
not
Blynk.begin(softwareSerial, auth);

It would actually be this…

Blynk.begin(SerialBLE, auth);

PS, I moved your issue into it’s own topic and corrected your formatting for your code post… you needed to use the backtick key, not apostrophe.

Honestly I have no experience with any BLE stuff. Just noticed his SoftwareSerial did not have the “S” capitalized. :slight_smile:

Not an issue of BT/BLE rather one of previously declaring the variable SerialBLE, which is then the correct item to be used in any further Software Serial commands. (my terminology may be a bit off, but I hope everyone gets the meaning :wink: )

Another thing, the loop() looks a little crowded. Especially with the delay(500);. You may want to put that in a timer loop. Although with an accelerometer, I am not sure how that would workout. I was playing with a two-axis the other day, and finding a good balance between how often to call the timer, and getting good readings was a little difficult (especially when making high-frequency measurements). Never really got the resolution I was hoping for, although for a non-critical application the results were satisfactory.

But with your existing half second delay, I do not see why it couldn’t be put in a half second loop to get similar results to what you currently have.

I missed a line… both need to be corrected.

SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth);

And yes, as @Toro_Blanco pointed out… much overall code cleanup needed :wink:

Now it says ‘Blynk’ does not name a type

Well show us the “now” code :wink:

#include <BlynkSimpleSerialBLE.h>

// You should get Auth Token in the Blynk App. Go to the Project Settings (nut icon).
const int groundpin = 18;             // analog input pin 4 -- ground
const int powerpin = 19;              // analog input pin 5 -- voltage
const int xpin = A4;                  // x-axis of the accelerometer
const int ypin = A2;                  // y-axis
const int zpin = A0;                  // z-axis (only on 3-axis models)
Blynk.begin(SerialBLE, auth); // RX, TX
char auth[] = "d7101319e24d4c61af2429ec19ce35d6"; 
int maximum = 0;
int maxmax = 0;
int xValue = 0;
int yValue = 0;
int zValue = 0;
void setup() 
{
    // initialize the serial communications:
SerialBLE.begin(9600);
Blynk.begin(SerialBLE, auth);
  // Provide ground and power by using the analog inputs as normal
  // digital pins.  This makes it possible to directly connect the
  // breakout board to the Arduino.  If you use the normal 5V and
  // GND pins on the Arduino, you can remove these lines.
  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
  digitalWrite(groundpin, LOW);
  digitalWrite(powerpin, HIGH);
}
void loop() {
  xValue = analogRead(xpin);
  // print a tab between values:
  //Serial.print("\t");
  yValue = analogRead(ypin);
  // print a tab between values:
  //Serial.print("\t");
  zValue = analogRead(zpin);
  //Serial.println();
  // delay before next reading:
  delay(500);
  maximum = max (xValue,yValue);
 maxmax = max(maximum,zValue);
 Serial.print ("maximum Final");
  Serial.println ( maximum);

Blynk.run();
// You can inject your own code here. 
// Remember to avoid delay() function!
}

This line, before the setup loop, didn’t need to be changed… revert it back to this

SoftwareSerial SerialBLE(10, 11); // RX, TX

Now it says BLsoftwareserial does not type a name

This is all good now, however, since you are also using serial prints, add this back in as it enables the basic serial print functions

Serial.begin(9600);

So you end up with this…

Serial.begin(9600);  // Initiates serial
SerialBLE.begin(9600);  // Initiates BLE connection
Blynk.begin(SerialBLE, auth);  // Connects to Blynk via BLE

And you still need this at the beginning

I think that should cover it??? :wink:

Fix it all, test and repost code… you still have potential flooding error issues with your void() loop. And we still need clarification as to the exact hardware you are using as there could be other libraries needed.