I'm trying to convert all my NodeMCU boards from standard to API. I found something interesting and not sure if this is an user error (Most likely), something in the API or the board. I have attached the picture and the code. When I use the standard NodeMCU type, I have no issues, I connect 3 of these sensors on Pin 16 (D0) Pin 5 (D1) and Pin 4 (D2). When I instead use the API, some pins work and some pin do not. In few cases, as an example when I plug it in D0 the red light on the NodeMCU comes up while On D3 (Not sure if this is the right pin, may be D2) when the sensor is close, I have a blue light on the board and when is open I have no light. What am I doing wrong?
Thanks,
Aldo
Thanks,
Aldo
Code:
//**************Declare your variables here******************* int sensorPin = 4; // ESP 12E pin D2 int sensorValue = 0; // variable to store the value coming from the sensor //**************************************************************** void HSSetup() { //************************ //Add YOUR SETUP HERE; //************************ pinMode(sensorPin, INPUT); } void HSloop() { //************************ //Add YOUR CODE HERE; //************************ /*Execute regardless of connection status*/ if (IsConnected == true) { /*Execute ONLY when HomeSeer is connected*/ // read the input pin and compare to the last state if (digitalRead(sensorPin) != sensorValue) { sensorValue = digitalRead(sensorPin); SendToHS(1, sensorValue); } } } // end of 'if (IsConnected == true) {'
Comment