Getting more usable input pins on Wemos D1 Mini / ESP8266
I need one more digital input pin on my wemos d1 mini. The RFM96 uses all recommended pins, so I only have pins that have special functions left and I'm not able to get any of them working.
The signal I want to read is a 9600bps serial (from a gps module).
D0, D3, D4, D8 all have special functions and are not recommended for use (according to Kolban's book).
D9 and D10 are not exposed on the d1 mini
I have tried A0. That worked a few times but not always. I am not sure why.
I have looked at http://www.instructables.com/id/ESP8266-Using-GPIO0-GPIO2-as-inputs/?ALLSTEPS but I am not sure if it is possible to use GPIO0 (D3) as pulldown for a serial signal on GPIO2 (D4).
GPIO16 (D0) might be available, but I am not able to make communication work. http://bbs.espressif.com/viewtopic.php?t=632 suggests it is often connected to the reset pin on ESP8266-based boards. https://arduinodiy.wordpress.com/2016/12/25/monitoring-lipo-battery-voltage-with-wemos-d1-minibattery-shield-and-thingspeak/ suggests that the Wemos d1 mini does not connect GPIO16 to reset, but the tests I've done result in no communication with the gps.
Not really sure how you need / have wired everything together so it may not be relevant but:
- Can you use TX and RX to wire your GPS module, maybe using MY_DISABLED_SERIAL
- On a RFM69 (and D1 pro mini) I can use D8 for CSN/NSS without any problems
- D0 should be totally fine to use I had no problem using it for various functions on my side (but never tried with a GPS module)
@emc2 thanks for your reply.
My wiring is like this https://www.mysensors.org/build/connect_radio#rfm69-&-esp8266
Rx/Tx should work. It did not when I tried yesterday though.
What defines did you use when using D8? Only #define MY_RF69_SPI_CS D8 ?
D8 (gpio15) must be pulled low at bootup of the esp. A serial signal is default high so if I connect a serial signal to d8 the esp will not boot. But using it for the rfm cs line should work, since cs won't be high during boot.
I'll need to experiment some more, or move to a Pro Mini which has more pins.
@emc2 using D8 for CSN/NSS and D2 for serial works! Thanks a lot for pointing me in the right direction.
Yes I only needed #define MY_RF69_SPI_CS D8
Glad to see it worked for you!
I did not pay attention that we had an official wiring esp8266 / RFM yet, but It seems there is actually a mistake on the website, the table says NSS -> D2 but on the schematic it's using D8. Maybe D8 is default and you had some issues on that if you were using D2 without #define MY_RF69_SPI_CS D2 ?
I'm personally using D2 for IRQ so maybe by switching things around you can get even more usable pins!
@emc2 Seems like I spoke too soon. I am able to initialize the RFM69 with D8 for CS, but the radio never signals the esp that a packet has been sent so it just hangs on the first send
We did not have a wiring guide for RFM69+ESP8266 until about two weeks ago, when I created one I used D2 when I verified the connections, so that's what the guide said until a few minuted ago. Since using D8 frees up D2, I changed the picture but I have changed it back now since I am unable to get it working.
Just to try, if not present, do you mind adding to you sketch
@emc2 it is already defined.
#ifdef ARDUINO_ARCH_ESP8266 #error ARDUINO_ARCH_ESP8266 is defined #endif
error: #error ARDUINO_ARCH_ESP8266 is defined
so defining it again should not make a difference, right?
It works now, using D8 for CS. I think I had some loose-fitting wires.
I have updated connecting the radio to use D8 instead of D2. With D2 being more flexible, it is better to have that pin unused.
Yes if it's already there no need to redefine it, seems it's only missing when in gateway mode. It may be a RFM96 issue then, if you have a RFM69 lying around you may want to try if it works with it, I had it working and some others too with NSS on D8 and IRQ on D2, so something may behave differently.
Guess we posted at the same time, good to see it's working for you too.
@emc2 you. Thanks a lot for helping me! Tomorrow I can carry my GPS node in my backpack and map out radio coverage
I'm interested to see how it goes and how a GPS module can be used.
As for the official wiring diagram, eventually consider using D2 as the default IRQ pin on it, this way it's consistent with nRF24 wiring (and can even reuse the same picture), and many people used it this way mostly since this https://forum.mysensors.org/topic/3061/solved-esp8266-gateway-with-rfm69-wdt-issues/4 post.
@emc2 I am actually not using a rfm69, but a rfm96 LoRa node. It has the same pinout.
Initial tests on my bike showed 750m range in my area, which mainly consists of 5-6 stories tall brick buildnings so definitely not line of sight. With a gps I'll be able to map coverage in more detail.
@mfalkvidd right, I was thinking of updating RFM69 wiring diagrams on https://www.mysensors.org/view/171#rfm69-&-esp8266 , but for how the radio module go I was interested in the rfm96 range / reliability to see how it goes.
Anyway I will look for futures updates on the forum.