Hello a friend of mine gave me 2 of these esp32 wlan mini they call them https://a.co/d/iYZC9VO. They are about the same size as the esp8266 d1 mini.
The problem is I’m trying to add a spi module and looking up the pin out there might be two spi channels. I can’t confirm it and was wondering from the community which pins are for spi?
Yes there should be 2 SPI port available on an ESP32, have a look at this tutorial. It depends a bit on the board which pins are exposed, and i have issues with the default HSPI pins, connect devices to some of the pins causes the esp to crash. But fortunately you can more or less assign any pin to be used for SPI
The ESP32 has multiple SPI channels on board. One is used to read the code from the external memory chip, one is not normally pinned out, and VSPI is the default (Arduino compatible) SPI channel and HSPI is the other free channel. See the ESP32 SPI demo program SPI_Multiple_Buses.
Hello all, thanks for the reply. I’m using the wiznet w5500 module board. I just didn’t know which spi pins do I use? Sense I never used a esp32 before?
Get the data sheet, at least the pinout, for your board.
If you have a scope then you can write test programs and find out which alternate functionality goes to which pin by default. Or find out how to map the internal ports to any pin, using the ESP32 I/O MUX.
that is the default for a w5500, some libraries allow for the alternate HSPI, but i had difficulty finding a way to use the custom pins for it. The commented out section shows how you could use different pins, by creating a pointer to the SPI object, but i can not pass the pointer to the Ethernet object on initialization (like i can with the SD library) The default pins on VSPI are available and have no other default functions so there is actually no reason not to use them.
Now I'm trying to match up the pinout before I can program it on the esp32 board. one pin that I'm confused on it a nINT pin bottom left of that image. Also The n RESET pin. Does that reset pin goes to the reset of the esp32 board?
It is a pin that sends a (LOW ?) pulse in case of an event, i don't think there is any support for it in the library i am using.
I had it like that initially, but it caused some issues in case of a 'soft'- reset. In the end i connected it to a GPIO (output) pin and did a short reset pulse before init()
I found some timing details in this Main thing for me was that i had to actually press reset when i just had it connected to RST on the esp32, although that was in some way good enough, i haven't had to reach for the board since i've added the reset routine.
I have a led connected to GPIO 2 (Active LOW !! VCC->LED->1K->GPIO2. If GPIO 2 is pulled LOW the ESP32 will enter the wrong boot mode, this pulls it up.) On some boards (i just got a 30-pin in) there is a builtin led on that pin.
I used GPIO 21 for reset, but any available output pin would work. There is no pullup on nRST on my module, but the pin should not be floating (ESP32 RST is pulled up) I just sacrificed a GPIO pin.
There is an example i have using Ethernet_Generic Library and EthernetWebserver.h (install both) and you need to modify Server.h as it explains on the github page of the webserver lib.
//#define W5500_RST_PORT 21
//#define ETHERNET_LARGE_BUFFERS
#define W5500_CS 5
#define SPI_FRQ 32000000
#include <WiFi.h>
#include <WebServer.h>
#include <SPI.h>
#include <EthernetWebServer.h>
#include "Ethernet_Generic.h"
// #include <EthernetUdp.h> // not needed yet
const char* ssid = "xxx";
const char* password = "xxxxxxxx";
EthernetWebServer ethernetServer(80);
WebServer wifiServer(80);
const int led = 2;
void handleEthernetRoot() {
ethernetServer.send(200, "text/plain", "Hello from ESP32 Ethernet!");
}
void handleWiFiRoot() {
wifiServer.send(200, "text/plain", "Hello from ESP32 WiFi!");
}
void setup() {
Serial.begin(115200);
delay(100);
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
SPI.setFrequency(SPI_FRQ);
Ethernet.init (W5500_CS);
// start the ethernet connection and the server:
// Use DHCP dynamic IP
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01};
//uint16_t index = millis() % NUMBER_OF_MAC;
// Use Static IP
//IPAddress ip(192, 168, 2, 222);
//Ethernet.begin(mac, ip);
Ethernet.begin(mac);
Serial.println("Currently Used SPI pinout:");
Serial.print("MOSI:");
Serial.println(MOSI);
Serial.print("MISO:");
Serial.println(MISO);
Serial.print("SCK:");
Serial.println(SCK);
Serial.print("CS/SS:");
Serial.println(W5500_CS);
ethernetServer.on("/", handleEthernetRoot);
ethernetServer.begin();
Serial.print("HTTP EthernetWebServer is @ IP : ");
Serial.println(Ethernet.localIP());
wifiServer.on("/", handleWiFiRoot);
wifiServer.begin();
Serial.print("HTTP WiFiWebServer is @ IP : ");
Serial.println(WiFi.localIP());
}
void loop() {
ethernetServer.handleClient();
wifiServer.handleClient();
}