Error compiling for board Zero when using ESP8266

I followed this tutorial, and did everything like he did: Sending sensor data to thinkspeak using ESP8266 and Arduino - YouTube.
However, every time I try to compile the code, I get the same error.

String myAPIkey = "VG49CI4A771D3AVZ";
#include <SoftwareSerial.h>
SoftwareSerial ESP8266(1, 0);
long writingTimer = 17;
long startTime = 0;
long waitTime = 0;
boolean relay1_at = false;
boolean relay2_st = false;
unsigned char check_connection = 0;
unsigned char times_check = 0;
boolean error;



#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_TSL2561_U.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>;
#define DHTPIN 5     // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE);
int chk;
float hum;  //Stores humidity value
float temp; //Stores temperature value

int UVOUT = A0; //Output from the sensor
int REF_3V3 = A1; //3.3V power on the Arduino board
int dustPin = 3; // dust sensor - Arduino A0 pin
int ledPin = 2;

float voltsMeasured = 0;
float calcVoltage = 0;
float dustDensity = 0;

LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
Adafruit_TSL2561_Unified tsl = Adafruit_TSL2561_Unified(TSL2561_ADDR_FLOAT, 12345);


void configureSensor(void)
{
  tsl.enableAutoRange(true);            /* Auto-gain ... switches automatically between 1x and 16x */
  tsl.setIntegrationTime(TSL2561_INTEGRATIONTIME_13MS);      /* fast but low resolution */
}

void setup()
{


  Serial.begin(9600);
  ESP8266.begin(9600);
  startTime = millis();
  ESP8266.println("AT+RST");
  delay(2000);
  Serial.println("Connecting to wifi pls");
  while (check_connection == 0)

  {
    Serial.print(",");
    ESP8266.print("AT+CWJAP=\"OnePlus5T\",\"metropolia\"\r\n");
    ESP8266.setTimeout(5000);
    if (ESP8266.find("WIFI CONNECTED\r\n") == 1)
    {
      Serial.println("WIFICONNECTED!!");
      break;
    }
    times_check++;
    if (times_check > 3)
    {
      times_check = 0;
      Serial.println("Tryin to reconnect...");
    }
  }










  pinMode(ledPin, OUTPUT);
  configureSensor();
  pinMode(UVOUT, INPUT);
  pinMode(REF_3V3, INPUT);
  dht.begin();

  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.backlight();
  lcd.clear();
}
void loop()
{
  waitTime = millis() - startTime;
  if (waitTime > (writingTime * 1000))
  {
    readSensors();
    writeThingSpeak();
    startTime = millis();
  }
}




void readSensors(void)
{
  hum = dht.readHumidity();
  temp = dht.readTemperature();
  digitalWrite(ledPin, LOW); // power on the LED
  delayMicroseconds(280);
  voltsMeasured = analogRead(dustPin); // read the dust value

  delayMicroseconds(40);
  digitalWrite(ledPin, HIGH); // turn the LED off
  delayMicroseconds(9680);

  //measure your 5v and change below

  calcVoltage = voltsMeasured * (5.0 / 1024.0);
  dustDensity = 0.17 * calcVoltage - 0.1;


  sensors_event_t event;
  tsl.getEvent(&event);
  int uvLevel = averageAnalogRead(UVOUT);
  int refLevel = averageAnalogRead(REF_3V3);

  //Use the 3.3V power pin as a reference to get a very accurate output value from sensor
  float outputVoltage = 3.3 / refLevel * uvLevel;

  float uvIntensity = mapfloat(outputVoltage, 0.99, 2.8, 0.0, 15.0); //Convert the voltage to a UV intensity level

  const int uvIntensity2 = uvIntensity * 10;

  //Takes an average of readings on a given pin
  //Returns the average
  int averageAnalogRead(int pinToRead)
  {
    byte numberOfReadings = 8;
    unsigned int runningValue = 0;

    for (int x = 0 ; x < numberOfReadings ; x++)
      runningValue += analogRead(pinToRead);
    runningValue /= numberOfReadings;

    return (runningValue);
  }

  //The Arduino Map function but for floats
  //From: http://forum.arduino.cc/index.php?topic=3922.0
  float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
  {
    return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
  }
}



void writeThingSpeak(void)
{
  startThingSpeakCmd();
  String getStr = "GET /update?api_key=";
  getStr += myAPIkey;
  getStr +="&field1=";
  getStr += String(temp);
  getStr +="&field2=";
  getStr += String(hum);
  getStr +="&field3=";
  getStr += String(dustDensity);
  getStr +="&field4=";
  getStr += String(event.light);
  getStr +="&field5=";
  getStr += String(uvIntensity);
  getStr += "\r\n\r\n";
  GetThingspeakcmd(getStr);
}



void startThingSpeakCmd(void)
{
  ESP8266.flush();
  String cmd = "AT+CIPSTART=\"TCP\",\"";
  cmd += "184.106.153.149";
  cmd += "\",80";
  ESP8266.println(cmd);
  Serial.print("Start Commands: ");
  Serial.println(cmd);

  if(ESP8266.find("Error"))
  {
    Serial.println("AT+CIPSTART error");
    return;
  }
}


String GetThingspeakcmd(String getStr)
{
  String cmd = "AT+CIPSEND=";
  cmd += String(getStr.length());
  ESP.println(cmd);
  Serial.println(cmd);

  if(ESP8266.find(">"))
  {
    ESP8266.print(getStr);
    Serial.println(getStr);
    delay(500);
    String messageBody = "";
    while (ESP8266.available())
    {
      String line = ESP8266.readStringUntil('\n');
      if (line.length() == 1)
      {
        messageBody = ESP8266.readStringUntil('\n');
      }
    }
    Serial.print("MessageBody received: ");
    Serial.println(messageBody);
    return messageBody;
  }
  else
  {
    ESP8266.println("AT+CIPCLOSE");
    Serial.println("AT+CIPCLOSE");
  }
}
      
    
  
  







  delay(100);

  lcd.scrollDisplayLeft();
  delay(400);


  lcd.setCursor(0, 0);
  lcd.print("UV");

  lcd.setCursor(0, 1);
  // Set diplay to scroll automatically
  lcd.print(uvIntensity2);      // set characters

  lcd.setCursor(4, 0);
  lcd.print("Illumin.");
  lcd.setCursor(4, 1);
  lcd.print(event.light, 0);
  lcd.print(" lx");
  lcd.setCursor(13, 0);
  lcd.print("DustDensity");
  lcd.setCursor(14, 1);
  lcd.print(dustDensity);
  lcd.print("mg/m3");
  lcd.setCursor(25, 0);
  lcd.print("Humd.");
  lcd.setCursor(25, 1);
  lcd.print(hum, 1);
  lcd.print("%");
  lcd.setCursor(31, 0);
  lcd.print("Temp.");
  lcd.setCursor(31, 1);
  lcd.print(temp, 1);
  lcd.print((char)223);
  lcd.print("C");

Here are things I have tried after reading about this:

  1. Tried USB Native Port instead of usual Programming port. When I first tried ESP8266 couple months ago I recall using ESP8266-board or something like that, but I can’t find one from my board list. I also recall putting some kind of URL in the additional boards manager field, but I don’t remember what.
  2. I tried to download ESP8266 package and copying it to arduinodata-folder.
  3. Yes, instead of using digital pins 2 and 3 like in the video, I am using 8 and 9 because my 2 is used for dust density sensor (I did configure them in the code as you can see). Are the pins 2&3 different from 8&9? I also tried inserting the data wires from ESP to the RX and TX -holes. Even tried them other way around (RX–>TX etc) because another forum post advised so.

fenbhguardsperson:
I get the same error.

And that error would be what? Care to share it?

gfvalvo:
And that error would be what? Care to share it?

the Error compiling for board Arduino Zero (Native USB Port/Programming port) like in the title

OK, this time the COMPLETE error message. There's a button above the black box at the bottom of the IDE. It's very clearly labeled "Copy error message". Press it. Then post it by pasting with code tags.

So, I managed to install the ESP8266 board and use it, but when using it, it doesn't understand the analog pins. Error message as such: "A1' was not declared in this scope"

In the attached file you can find the requested information

arduinoooo.txt (84.2 KB)

None of this code is inside any function as all executable code must be.

delay(100);

lcd.scrollDisplayLeft();
delay(400);


lcd.setCursor(0, 0);
lcd.print("UV");

lcd.setCursor(0, 1);
// Set diplay to scroll automatically
lcd.print(uvIntensity2);      // set characters

lcd.setCursor(4, 0);
lcd.print("Illumin.");
lcd.setCursor(4, 1);
lcd.print(event.light, 0);
lcd.print(" lx");
lcd.setCursor(13, 0);
lcd.print("DustDensity");
lcd.setCursor(14, 1);
lcd.print(dustDensity);
lcd.print("mg/m3");
lcd.setCursor(25, 0);
lcd.print("Humd.");
lcd.setCursor(25, 1);
lcd.print(hum, 1);
lcd.print("%");
lcd.setCursor(31, 0);
lcd.print("Temp.");
lcd.setCursor(31, 1);
lcd.print(temp, 1);
lcd.print((char)223);
lcd.print("C");

fenbhguardsperson:
So, I managed to install the ESP8266 board and use it, but when using it, it doesn't understand the analog pins. Error message as such: "A1' was not declared in this scope"

The ESP8266 only has one analog pin, named A0.
https://arduino-esp8266.readthedocs.io/en/2.6.3/reference.html#analog-input

gfvalvo:
OK, this time the COMPLETE error message. There's a button above the black box at the bottom of the IDE. It's very clearly labeled "Copy error message". Press it. Then post it by pasting with code tags.

gfvalvo:
OK, this time the COMPLETE error message. There's a button above the black box at the bottom of the IDE. It's very clearly labeled "Copy error message". Press it. Then post it by pasting with code tags.

i dont know if you get notified if i dont use the quote option, so friendly reminder: i posted the requested info in my most recent reply

pert:
The ESP8266 only has one analog pin, named A0.
Reference — ESP8266 Arduino Core 2.6.3 documentation

OK, so how does this work in practice? what do I need to do? sorry for asking, I am inexperienced. Just for clarification, my ESP8266 pins are as such:

  • GND & UTXD
  • GP102 & CH_PD
  • GP100 & REST
  • URXD & VCC

It's very difficult to read the error output you posted because you've smashed the output for two different compilations into the same file.

Are you using an Arduino Zero Board, or are you using an ESP8266 board? Which one of these Arduino boards are connected to your computer with a USB cable?

Zero is not Uno. there is no SoftwareSerial for Zero, but it has hardware Serial1 on pins RX/TX.
if you wan to use two boards/MCUs, you must have two sketches or use some universal firmware in one of the MCU.
usually the AT firmware is used in esp8266 if it is used as network adapter.
in the video AT commands are sent to the esp8266

pert:
It's very difficult to read the error output you posted because you've smashed the output for two different compilations into the same file.

Are you using an Arduino Zero Board, or are you using an ESP8266 board? Which one of these Arduino boards are connected to your computer with a USB cable?

I divided the two error messages. You can use ctrl+f funtion and search "if you saw". Yes I am using Zero board. I have tried arduino zero board and esp8266 board. Arduino zero board doesnt let me compile and esp8266 board doesnt understand arduino

Juraj:
Zero is not Uno. there is no SoftwareSerial for Zero, but it has hardware Serial1 on pins RX/TX.
if you wan to use two boards/MCUs, you must have two sketches or use some universal firmware in one of the MCU.
usually the AT firmware is used in esp8266 if it is used as network adapter.
in the video AT commands are sent to the esp8266

So how does this work in practice? Sorry I am inexperienced with this, i didnt understand much of what you said. my goal is a weather station that sends data to thingspeak server using esp8266. So do I remove #include softwareserial library and install serial1 library or so? i suppose i should change 'softwareserial' to 'serial1' wherever 'softwareserial' is mentioned, right? Right now my data wires from ESP8266 are now indeed in RX and TX, they should probably stay there right? I don't know if I want to use two boards or sketches, I just want it to work