I can't solve the "was not declared in this scope".

Hi guys, i’m trying to set up a rain sensor, but i can’t find the error, i’ve read a lot of problems that were similar, but i was unsuccessful.
The problem is in the " int pino_d = D0", that appears “D0 was not declared in this scope”
Sorry for the bad english!
Thanks for the help!!

// Projeto Curto Circuito - Estação Meteorológica - Sensor de Chuva
//Chuva
int pino_d = D0; // Pino ligado ao D0 do sensor
int pino_a = A0; // Pino ligado ao A0 do sensor
int val_d = 0;   // Armazena o valor lido do pino digital
int val_a = 0;   // Armazena o valor lido do pino analógico
void setup() {
  // Sensores INPUT
  pinMode(pino_d, INPUT);
  pinMode(pino_a, INPUT);
}

void loop() {
  // Armazena os valores de leitura dos sensores nas variáveis
  val_d = digitalRead(pino_d);
  val_a = analogRead(pino_a);
  // Se a leitura analógica for menor que 300 
  if ( val_a < 300) {       // Chuva intensa 
  }
  // Se a leitura analógica for menor que 500 e maior que 300 
  if (val_a <= 500 && val_a >= 300) { // Chuva moderada
  }
  // Se a leitura analógica for maior que 500 
  if ( val_a > 500) {        // Sem previsão de Chuva 
  }
}
ESP8266_Standalone:3:14: error: 'D0' was not declared in this scope
 int pino_d = D0; // Pino ligado ao D0 do sensor
              ^
C:\Users\gusta\OneDrive\Documentos\Arduino\ESP8266_Standalone\ESP8266_Standalone.ino: In function 'void setup()':
ESP8266_Standalone:9:14: error: 'D0' was not declared in this scope
 int pino_d = D0; // Pino ligado ao D0 do sensor
              ^
C:\Users\gusta\OneDrive\Documentos\Arduino\ESP8266_Standalone\ESP8266_Standalone.ino: In function 'void loop()':
ESP8266_Standalone:19:14: error: 'D0' was not declared in this scope
 int pino_d = D0; // Pino ligado ao D0 do sensor
              ^
exit status 1
'D0' was not declared in this scope

I believe the Arduino alias for D0 is 16. Maybe try

int pino_d = 16; // Pino ligado ao D0 do sensor

You don't say what board you are using, but the IDE aliases the ESP data pins as D0, D1, etc. If you are using the Uno, you have to use the Uno pin numbering convention.

SteveMann:
You don't say what board you are using, but the IDE aliases the ESP data pins as D0, D1, etc. If you are using the Uno, you have to use the Uno pin numbering convention.

Sorry man, i forgot, i'm using a NodeMcu ESP8266

i'm using a NodeMcu ESP8266

What board did you select with the pull down menu under "Tools".

Your sketch compiles without error for me with selection of either choice of NodeMCU 0.9 or 1.0.

Blackfin:
I believe the Arduino alias for D0 is 16. Maybe try

int pino_d = 16; // Pino ligado ao D0 do sensor

Hey dude thanks a lot, it's working now, i didn't know about this numbers, thanks!!!!

cattledog:
What board did you select with the pull down menu under "Tools".

Your sketch compiles without error for me with selection of either choice of NodeMCU 0.9 or 1.0.

Ok, i will try here, but change the "D0" for numbers works too. Thanks for the help man!!

hotdoug:
Ok, i will try here, but change the "D0" for numbers works too. Thanks for the help man!!

if you select a wrong board resulted code may not work as expected.

@hotdoug - your duplicate topic has been deleted

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a timeout from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the sticky "How to use this forum - please read." post you will find at the top of every forum board. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.