Using SPI with AI thinker ESP-32-cam

Secretmapper
Posts: 1
Joined: Mon Apr 29, 2019 7:31 am

Using SPI with AI thinker ESP-32-cam

Postby Secretmapper » Mon Apr 29, 2019 7:34 am

Does anyone know how to use SPI with ESP-32 cam? I'm currently integrating an RFID reader with the esp-32 cam.

I have a PIN diagram here:
https://www.seeedstudio.site/media/cata ... 32cam3.jpg)

but it doesn't have the data for the SPI pins like the one I have for my other devboard here:
https://www.shenzhen2u.com/NodeMCU-32S

I did find a table for the SPI pins from the Espressif docs, but since the VSPI pins aren't in the esp32-cam, I ended up using HSPI, but it doesn't seem to work.

https://docs.espressif.com/projects/esp ... aster.html

I found a schematic diagram, but unfortunately I can't read schematics since I come from a software engineering background:
https://github.com/SeeedDocument/forum_ ... M_V1.6.pdf

However, I did try to read it to the best of my ability, and I think the top right part (P1, P2) correspond to the header pins of the devboard. Incidentally, none of them are SDA, etc. (like shown in the esp32 module standalone of the left).

Does that mean I can't use it if the header pins don't have it and it's being used by the sdcard? The blurb for the devboard says it supports SPI, but I'm not sure how to use the SPI lines if it's not exposed as a header pin.

mbueno0
Posts: 1
Joined: Sat Apr 18, 2020 3:50 pm

Re: Using SPI with AI thinker ESP-32-cam

Postby mbueno0 » Sat Apr 18, 2020 3:54 pm

Did you ever happen to find a solution to your problem:
Using SPI with AI thinker ESP-32-cam
??

Thanks! :)

rgenius
Posts: 1
Joined: Tue Apr 16, 2024 7:53 pm

Re: Using SPI with AI thinker ESP-32-cam

Postby rgenius » Tue Apr 16, 2024 8:03 pm

It's works for me:

Code: Select all

#include <SPI.h>
#include <MFRC522.h>


#define MISO_PIN        12
#define MOSI_PIN        13
#define SCK_PIN         14
#define SS_PIN          15
#define RST_PIN         16


MFRC522 mfrc522(SS_PIN, RST_PIN);  // Create MFRC522 instance

void setup() {
	delay(2000);
	Serial.begin(115200);		// Initialize serial communications with the PC
	while (!Serial);		// Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)

	// void SPIClass::begin(sck, miso, mosi, ss)
	SPI.begin(SCK_PIN, MISO_PIN, MOSI_PIN, SS_PIN);			// Init SPI bus
	mfrc522.PCD_Init();		// Init MFRC522
	delay(40);				// Optional delay. Some board do need more time after init to be ready, see Readme
	mfrc522.PCD_DumpVersionToSerial();	// Show details of PCD - MFRC522 Card Reader details
	Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks..."));
}

void loop() {
	// Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle.
	if ( ! mfrc522.PICC_IsNewCardPresent()) {
		return;
	}

	// Select one of the cards
	if ( ! mfrc522.PICC_ReadCardSerial()) {
		return;
	}

	// Dump debug info about the card; PICC_HaltA() is automatically called
	mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
It's all about forced initialization of the SPI bus with the given pins:

Code: Select all

// void SPIClass::begin(sck, miso, mosi, ss)
SPI.begin(SCK_PIN, MISO_PIN, MOSI_PIN, SS_PIN);			// Init SPI bus
--
I hope it helps someone 8-)

Who is online

Users browsing this forum: No registered users and 114 guests