ESP-MQTT-JSON-Multisensor icon indicating copy to clipboard operation
ESP-MQTT-JSON-Multisensor copied to clipboard

'D1' was not declared in this scope

Open DoomzKid opened this issue 7 years ago • 7 comments

I get this error when, Any Idea how to fix this ?


Multisensor:37: error: 'D1' was not declared in this scope

const int redPin = D1;

                ^

Multisensor:38: error: 'D2' was not declared in this scope

const int greenPin = D2;

                  ^

Multisensor:39: error: 'D3' was not declared in this scope

const int bluePin = D3;

                 ^

Multisensor:41: error: 'D7' was not declared in this scope

#define DHTPIN D7

               ^

C:\Users*****\Documents\Arduino\Multisensor\Multisensor.ino:105:9: note: in expansion of macro 'DHTPIN'

DHT dht(DHTPIN, DHTTYPE);

     ^

C:\Users****\Documents\Arduino\Multisensor\Multisensor.ino: In function 'void setup()':

Multisensor:40: error: 'D5' was not declared in this scope

#define PIRPIN D5

               ^

C:\Users*****\Documents\Arduino\Multisensor\Multisensor.ino:114:11: note: in expansion of macro 'PIRPIN'

pinMode(PIRPIN, INPUT);

       ^

Multisensor:41: error: 'D7' was not declared in this scope

#define DHTPIN D7

               ^

C:\Users******\Documents\Arduino\Multisensor\Multisensor.ino:115:11: note: in expansion of macro 'DHTPIN'

pinMode(DHTPIN, INPUT);

       ^

C:\Users*****\Documents\Arduino\Multisensor\Multisensor.ino: In function 'void loop()':

Multisensor:40: error: 'D5' was not declared in this scope

#define PIRPIN D5

               ^

C:\Users*****\Documents\Arduino\Multisensor\Multisensor.ino:397:28: note: in expansion of macro 'PIRPIN'

 pirValue = digitalRead(PIRPIN); //read state of the

                        ^

exit status 1 'D1' was not declared in this scope

DoomzKid avatar May 24 '17 17:05 DoomzKid

Please make sure you selected the right board.

TheFitzZZ avatar May 24 '17 18:05 TheFitzZZ

Thanks !,

I was using the video on youtube, Testing the file, But a bit further in the video. Doas he the settings of the board. after that the code "D1" Error wiln't show,

Now i am only stuck at Serial Montitor with the message>

failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, rc=-2 try again in 5 seconds Attempting MQTT connection...failed, rc=-2 try again in 5 seconds... ... ..

DoomzKid avatar May 24 '17 19:05 DoomzKid

It's likely an issue with the MQTT server or credentials you are using. Verify your MQTT adress and the username/password info and try again. Cheers!

bruhautomation avatar May 29 '17 23:05 bruhautomation

I picked this board and I think my problem is fixed.

image

bbrendon avatar Jun 08 '17 15:06 bbrendon

If that fixed your issue, make sure you hit close issue on this thread

timmo001 avatar Oct 16 '17 12:10 timmo001

I too had this "issue".

I was using an ESP-01 board and put D0 and D2. But they're not defined as data pins on the ESP-01. So if this is the case you have to just put 0 and 2 for these boards.

Philje123 avatar Dec 04 '17 20:12 Philje123

Tks. I was using ESP8266 and had the same problem. Changed to ESP-12 1.0, as sudgested by bbrandon, and it all workrd.

mmilton62 avatar Jul 29 '18 15:07 mmilton62