Node mcu connect multiple device on SPI
Posted:
Wed Apr 26, 2017 1:14 am
by death_soldier
Can I connect multiple devices on SPI on node mcu?
Any suggestion ?
Thanks
Re: Node mcu connect multiple device on SPI
Posted:
Wed Apr 26, 2017 1:36 am
by schufti
of course you can. SPI interface generally comes with a "cs" pin.
So pick n gpios to be the "cs" for your n multiple devices and off you go...
Re: Node mcu connect multiple device on SPI
Posted:
Wed Apr 26, 2017 12:55 pm
by alguti2000
Please note that each device will need its own CS line to be connected to a pin. SPI selects the target device by pulling the CS line low.
The ESP8266 is VERY limited in GPIOs, and some of these have special uses, such as GPIO0 and 15 that have to be at a given state during boot. The best way is to add an I/O spander, and use it to control the CS line for many devices.
In my case, I have two devices connected to the SPI bus. However, the SD card will have the CS line high, which I have connected to GPIO15. This caused the ESP-12E to not boot at all. I tried GPIO0, the only other pin available that I have, and that was worst, since the ESP-12E will keep rebooting.
After trial and error, I finally found a solution. I connected the SD card's CS to GPIO15, as normal. But, then I added a BC547 NPN transistor. The base is connected via a diode 1N4148. The collector is connected to GND. Finally, the Emitter is connected back to to GPIO15 via a 10K resistor. Now I can boot the device, without having to disconnect the SD card CS line, first.
Re: Node mcu connect multiple device on SPI
Posted:
Mon Oct 09, 2017 3:56 am
by dgbat2
For GPIO 15 I think you can just use a pull-down resistor to make it low at boot, then you can use it like a normal digital pin. As long as it's connected to GND through a resistor works fine for me.