B4R Question Pin 8 in Wemos D1

derez

Expert
Licensed User
I have got my WeMos D1 and within an hour it was working as a PIR detector with my home control server.
Something strange with pin 8 which is connected to a led:
B4X:
  Private pin8, pin7, pin6 As Pin
  Private D1 As D1Pins
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Log("AppStart")
   pin6.Initialize(D1.D6, pin6.MODE_INPUT_PULLUP)
   pin7.Initialize(D1.D7 ,pin7.MODE_OUTPUT)
   pin8.Initialize("D8" ,pin8.MODE_OUTPUT)
   pin6.AddListener("PIR_StateChanged")
   pin7.DigitalWrite(False)
   pin8.DigitalWrite(False)

The pin number "D8" is the only way it works. When I put D1.D8 the led lights half volume constantly without reaction to commands.
Putting 8 - the board resets continuously.
 

Cableguy

Expert
Licensed User
are you using the esp8266Pin lib? the WeMos, although physically equivalent to the Arduino, has a different pin reference table, be sure to check it out
 
Upvote 0

derez

Expert
Licensed User
I use rESP8266 and rESP8266WiFi , I defined an object D1 as D1Pins and it works for pins 6 and 7 but not for 8
Actually, if I put "D2" or any other string - it also works...
 
Last edited:
Upvote 0

Hypnos

Active Member
Licensed User
hi derez,

I'm also try to connect a PIR sensor to my new Wemos D1 board but as I'm not familiar with electronic, may I have some advise from you? my question is the PIR sensor is powered up by 5V, is there any problem if the PIR output pin connected to Wemos Data Pin (e.g. D5) ? Thanks!
 
Upvote 0

derez

Expert
Licensed User
The data return from the PIR is 5v so it may harm the Wemos. You should convert the voltage to 3.3 volt.
Connect two resistors, one of 10Kohm and the other of 5 Kohm (if you have only 10 k resistors, two such in parallel are equal 5 k !)
Connect the 10k to ground, the 5k to the PIR data pin and the Wemos input pin to the point where the two resistors connect:
upload_2016-8-8_10-30-1.png


5v * 10/(5+10) = 3.3v
 
Upvote 0
Top