lvalue required as left operand of assignment error with ESP32 and constrain cmd

I am changing code from an application using an arduino pro mini 3.3v with HC12 wireless module to
an ESP32 with integrated wifi and bluetooth (ESP32 devkit 1)

I didn't get this error before with similar code for the arduino pro mini module and HC12 module.
However now that I compile it I am getting this error

lvalue required as left operand of assignment error

I found this link to get some clarity on the issue.

However, I don't think I'm making the error mentioned in the link above.
Can someone please explain what I may be doing wrong? Thanks.

I get the error around this line of code: "BR = constrain(BR, 0, 510)"
This portion of code is being used to calibrate photoresistor sensors to report similar values despite
their inherent variances due to manufacturing tolerances, etc...

//Special thanks to geobruce at instructables.com
//Special thanks to Robin2 and his code for parsing data, and others on arduino forums
//Special thanks to Ahmet Burkay Kirnik for his code for Measure Angle with a MPU-6050(GY-521)

#include<Wire.h>
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;

const int MPU_addr = 0x68;
int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ;

int minVal = 85;
int maxVal = 402;

double x;
int EA; //elevation angle
double z;

const int sensorPinTL = 33; //top left sensor pin
const int sensorPinBL = 35;
const int sensorPinTR = 32;
const int sensorPinBR = 34;

// The sensor value
int TL = 0;
int BL = 0;
int TR = 0;
int BR = 0;

// As photoresistor approaches minimum sensor value more light is seen by it
int sensorMinTL = 0;
int sensorMinBL = 0;
int sensorMinTR = 0;
int sensorMinBR = 0;

int sensorMaxTL = 4096;
int sensorMaxBL = 4096;
int sensorMaxTR = 4096;
int sensorMaxBR = 4096;

void setup() {
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);

  Serial.begin(115200);
  SerialBT.begin("ESP32TransmitST");
}

void loop() {
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr, 14, true);

  AcX = Wire.read() << 8 | Wire.read();
  AcY = Wire.read() << 8 | Wire.read();
  AcZ = Wire.read() << 8 | Wire.read();

  int xAng = map(AcX, minVal, maxVal, -180, 180);
  int yAng = map(AcY, minVal, maxVal, -180, 180);
  int zAng = map(AcZ, minVal, maxVal, -180, 180);

  EA = RAD_TO_DEG * (atan2(xAng, zAng));

  // Calibrate during the first five seconds
  while (millis() < 5000) {
    TL = analogRead(sensorPinTL);
    BL = analogRead(sensorPinBL);
    TR = analogRead(sensorPinTR);
    BR = analogRead(sensorPinBR);

    // Record the maximum sensor value
    if (TL > sensorMaxTL) {
      sensorMaxTL = TL;
    }
    if (BL > sensorMaxBL) {
      sensorMaxBL = BL;
    }
    if (TR > sensorMaxTR) {
      sensorMaxTR = TR;
    }
    if (BR > sensorMaxBR) {
      sensorMaxBR = BR;
    }

    if (TL < sensorMinTR) {
      sensorMinTR = TL;
    }
    if (BL < sensorMinTR) {
      sensorMinTR = BL;
    }
    if (TR < sensorMinTR) {
      sensorMinTR = TR;
    }
    if (BR < sensorMinTR) {
      sensorMinTR = BR;
    }
  }
  // Signal the end of the calibration period

  // Read the sensor
  TL = analogRead(sensorPinTL); // Top left sensor
  BL = analogRead(sensorPinBL); // Bottom left sensor
  TR = analogRead(sensorPinTR); // Top right sensor
  BR = analogRead(sensorPinBR); // Bottom right sensor

  // Apply the calibration to the sensor reading
  TL = map(TL, sensorMinTL, sensorMaxTL, 0, 510);
  BL = map(BL, sensorMinBL, sensorMaxBL, 0, 510);
  TR = map(TR, sensorMinTR, sensorMaxTR, 0, 510);
  BR = map(BR, sensorMinBR, sensorMaxBR, 0, 510);

  // In case the sensor value is outside the range seen during calibration
  TL = constrain(TL, 0, 510);
  BL = constrain(BL, 0, 510);
  TR = constrain(TR, 0, 510);
  BR = constrain(BR, 0, 510);

  //Sends analog values in this format: i.e. <380,148,224,260,45>
  Serial.print("<");
  Serial.print(TL);
  Serial.print(",");
  Serial.print(BL);
  Serial.print(",");
  Serial.print(TR);
  Serial.print(",");
  Serial.print(BR);
  Serial.print(",");
  Serial.print(EA);
  Serial.print(">");

  Serial.println();

  SerialBT.print("<");
  SerialBT.print(TL);
  SerialBT.print(",");
  SerialBT.print(BL);
  SerialBT.print(",");
  SerialBT.print(TR);
  SerialBT.print(",");
  SerialBT.print(BR);
  SerialBT.print(",");
  SerialBT.print(EA);
  SerialBT.print(">");

  SerialBT.println();

  delay(400);
}

When I try to compile your code I get quite a few more errors than the one you quoted. One of them tells me that BR is a special symbol defined in the ESP32 core.

When you try to use it as a variable name the compiler gets very confused.

Avoid this in future by giving variables longer more descriptive names.

Ah I see. thanks. I will try using a different variable.

FYI...the board I have is Espressif ESP32 dev kit 1.
I select this board in arduino: DOIT ESP32 DEV KIT 1
https://dl.espressif.com/dl/package_esp32_index.json
The url above is what I put in Arduino preferences area to download it in the board manager library.

Here is my code for the Arduino pro mini 3.3V and HC-12 combined.
I get no compile errors.

I purposely abbreviated those letters because if I understood things properly regarding transmittal of data via the HC-12 module and the code I have for both the transmitter end and receiver end it can potentially error out during transmission? (Post becoming too long adding receiver code in next post)

Transmitter:

//Special thanks to geobruce at instructables.com
//Special thanks to Robin2 and his code for parsing data, and others on arduino forums (serial input basics guide by Robin2 was really useful)
//Special thanks to my CS friends.
//HC-12 transmitter code for dual axis solar tracking.
//Special thanks to Ahmet Burkay KIRNIK
//Measure Angle with a MPU-6050(GY-521)

#include<Wire.h>

const int MPU_addr=0x68;
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

int minVal=85;
int maxVal=402;

double x;
int EA;
double z;

#include <SoftwareSerial.h>
SoftwareSerial HC12(11,10); // (HC-12 TX Pin, HC-12 RX)

const int sensorPinTL = A0;  
const int sensorPinBL = A1;
const int sensorPinTR = A2;  
const int sensorPinBR = A3;  

// The sensor value
int TL = 0; 
int BL = 0;
int TR = 0;         
int BR = 0;

// Minimum sensor value, more light is seen
int sensorMinTL = 0; 
int sensorMinBL = 0;
int sensorMinTR = 0;        
int sensorMinBR = 0;

int sensorMaxTL = 1023; 
int sensorMaxBL = 1023; 
int sensorMaxTR = 1023;           
int sensorMaxBR = 1023; 

void setup() {
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);
  
  Serial.begin(9600);
  HC12.begin(9600); //serial port to HC12
}

void loop() {
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr,14,true);
  
  AcX=Wire.read()<<8|Wire.read();
  AcY=Wire.read()<<8|Wire.read();
  AcZ=Wire.read()<<8|Wire.read();
  
  int xAng = map(AcX,minVal,maxVal,-180,180);
  int yAng = map(AcY,minVal,maxVal,-180,180);
  int zAng = map(AcZ,minVal,maxVal,-180,180);

  EA= RAD_TO_DEG * (atan2(xAng, zAng));
  
// Calibrate during the first five seconds
  while (millis() < 5000) {            
    TL = analogRead(sensorPinTL);
    BL = analogRead(sensorPinBL);
    TR = analogRead(sensorPinTR);
    BR = analogRead(sensorPinBR);
    
// Record the maximum sensor value
    if (TL > sensorMaxTL) {sensorMaxTL = TL;}
    if (BL > sensorMaxBL) {sensorMaxBL = BL;}
    if (TR > sensorMaxTR) {sensorMaxTR = TR;}
    if (BR > sensorMaxBR) {sensorMaxBR = BR;}
    
    if (TL < sensorMinTR) {sensorMinTR = TL;}
    if (BL < sensorMinTR) {sensorMinTR = BL;}
    if (TR < sensorMinTR) {sensorMinTR = TR;}
    if (BR < sensorMinTR) {sensorMinTR = BR;}
} 
// Signal the end of the calibration period

// Read the sensor
  TL = analogRead(sensorPinTL); // Top left sensor
  BL = analogRead(sensorPinBL); // Bottom left sensor
  TR = analogRead(sensorPinTR); // Top right sensor
  BR = analogRead(sensorPinBR); // Bottom right sensor

// Apply the calibration to the sensor reading
  TL = map(TL, sensorMinTL, sensorMaxTL, 0, 510);
  BL = map(BL, sensorMinBL, sensorMaxBL, 0, 510);
  TR = map(TR, sensorMinTR, sensorMaxTR, 0, 510);
  BR = map(BR, sensorMinBR, sensorMaxBR, 0, 510);
  
// In case the sensor value is outside the range seen during calibration
  TL = constrain(TL, 0, 510);
  BL = constrain(BL, 0, 510);
  TR = constrain(TR, 0, 510);
  BR = constrain(BR, 0, 510);

//Sends analog values in this format: i.e. <380,148,224,260,45>
  Serial.print("<");
  Serial.print(TL);
  Serial.print(","); 
  Serial.print(BL);
  Serial.print(","); 
  Serial.print(TR);
  Serial.print(",");
  Serial.print(BR);
  Serial.print(",");
  Serial.print(EA);
  Serial.print(">");
  
  Serial.println();   

  HC12.print("<"); 
  HC12.print(TL);
  HC12.print(",");  
  HC12.print(BL);
  HC12.print(",");
  HC12.print(TR);
  HC12.print(",");
  HC12.print(BR);
  HC12.print(",");
  HC12.print(EA);
  HC12.print(">");
  
  HC12.println();

  delay(400);             
}

Wow... thanks changed the variable it's compiling now!

fyi...
TL (top left sensor)
TR (top right sensor)
BRT (bottom right sensor)
BL (bottom left sensor)

//Special thanks to geobruce at instructables.com
//Special thanks to Robin2 and his code for parsing data, and others on arduino forums
//Special thanks to Ahmet Burkay Kirnik for his code for Measure Angle with a MPU-6050(GY-521)

#include<Wire.h>
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;

const int MPU_addr = 0x68;
int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ;

int minVal = 85;
int maxVal = 402;

double x;
int EA; //elevation angle
double z;

const int sensorPinTL = 33; //top left sensor pin
const int sensorPinBL = 35;
const int sensorPinTR = 32;
const int sensorPinBRT = 34;

// The sensor value
int TL = 0;
int BL = 0;
int TR = 0;
int BRT = 0;

// As photoresistor approaches minimum sensor value more light is seen by it
int sensorMinTL = 0;
int sensorMinBL = 0;
int sensorMinTR = 0;
int sensorMinBRT = 0;

int sensorMaxTL = 4096;
int sensorMaxBL = 4096;
int sensorMaxTR = 4096;
int sensorMaxBRT = 4096;

void setup() {
  Wire.begin();
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);

  Serial.begin(115200);
  SerialBT.begin("ESP32TransmitST");
}

void loop() {
  Wire.beginTransmission(MPU_addr);
  Wire.write(0x3B);
  Wire.endTransmission(false);
  Wire.requestFrom(MPU_addr, 14, true);

  AcX = Wire.read() << 8 | Wire.read();
  AcY = Wire.read() << 8 | Wire.read();
  AcZ = Wire.read() << 8 | Wire.read();

  int xAng = map(AcX, minVal, maxVal, -180, 180);
  int yAng = map(AcY, minVal, maxVal, -180, 180);
  int zAng = map(AcZ, minVal, maxVal, -180, 180);

  EA = RAD_TO_DEG * (atan2(xAng, zAng));

  // Calibrate during the first five seconds
  while (millis() < 5000) {
    TL = analogRead(sensorPinTL);
    BL = analogRead(sensorPinBL);
    TR = analogRead(sensorPinTR);
    BRT = analogRead(sensorPinBRT);

    // Record the maximum sensor value
    if (TL > sensorMaxTL) {
      sensorMaxTL = TL;
    }
    if (BL > sensorMaxBL) {
      sensorMaxBL = BL;
    }
    if (TR > sensorMaxTR) {
      sensorMaxTR = TR;
    }
    if (BRT > sensorMaxBRT) {
      sensorMaxBRT = BRT;
    }

    if (TL < sensorMinTL) {
      sensorMinTL = TL;
    }
    if (BL < sensorMinBL) {
      sensorMinBL = BL;
    }
    if (TR < sensorMinTR) {
      sensorMinTR = TR;
    }
    if (BRT < sensorMinBRT) {
      sensorMinBRT = BRT;
    }
  }
  // Signal the end of the calibration period

  // Read the sensor
  TL = analogRead(sensorPinTL); // Top left sensor
  BL = analogRead(sensorPinBL); // Bottom left sensor
  TR = analogRead(sensorPinTR); // Top right sensor
  BRT = analogRead(sensorPinBRT); // Bottom right sensor

  // Apply the calibration to the sensor reading
  TL = map(TL, sensorMinTL, sensorMaxTL, 0, 510);
  BL = map(BL, sensorMinBL, sensorMaxBL, 0, 510);
  TR = map(TR, sensorMinTR, sensorMaxTR, 0, 510);
  BRT = map(BRT, sensorMinBRT, sensorMaxBRT, 0, 510);

  // In case the sensor value is outside the range seen during calibration
  TL = constrain(TL, 0, 510);
  BL = constrain(BL, 0, 510);
  TR = constrain(TR, 0, 510);
  BRT = constrain(BRT, 0, 510);

  //Sends analog values in this format: i.e. <380,148,224,260,45>
  Serial.print("<");
  Serial.print(TL);
  Serial.print(",");
  Serial.print(BL);
  Serial.print(",");
  Serial.print(TR);
  Serial.print(",");
  Serial.print(BRT);
  Serial.print(",");
  Serial.print(EA);
  Serial.print(">");

  Serial.println();

  SerialBT.print("<");
  SerialBT.print(TL);
  SerialBT.print(",");
  SerialBT.print(BL);
  SerialBT.print(",");
  SerialBT.print(TR);
  SerialBT.print(",");
  SerialBT.print(BRT);
  SerialBT.print(",");
  SerialBT.print(EA);
  SerialBT.print(">");

  SerialBT.println();

  delay(400);
}
const int sensorPinTL = 33; //top left sensor pin
const int sensorPinBL = 35;
const int sensorPinTR = 32;
const int sensorPinBRT = 34;

// The sensor value
int TL = 0;
int BL = 0;
int TR = 0;
int BRT = 0;

It's good that you used Pin in the names of variables containing pin numbers. It was pointless to use sensor in those names, though, since there isn't much else you'd connect to the pins.

Now, if you had used Value in the names of variables that held values, you would not have inadvertently reused an already used name.

By convention, all capital letter names are reserved for constants. Constants never appear on the left of equal signs:

    TL = analogRead(sensorPinTL);
    BL = analogRead(sensorPinBL);
    TR = analogRead(sensorPinTR);
    BRT = analogRead(sensorPinBRT);

Thanks I'll reformat the code to match the convention regarding capital letters for constants.