ESP32CAM & I/O with 74HC595 or MCP23S08?

Annex for ESP32
Post Reply
lyizb
Posts: 93
Joined: Fri Feb 12, 2021 8:23 pm
Has thanked: 36 times
Been thanked: 23 times

ESP32CAM & I/O with 74HC595 or MCP23S08?

Post by lyizb »

Is it possible to expand the I/O for the ESP32CAM with an SPI PDIP MCP23S08 or 74HC595?

The circuit diagrams I have seen are too blurry for me to tell whether the MISO, MOSI, and CLK pins are among the ones which are brought out on the ESP32CAM: GPIO0-4 and 12-16.

Which pins are used for the SPI SD card?

Where are the pin usages described? I know the online help indicates that only 12 is free, plus Tx (GPIO1) and Rx (GPIO3), with GPIO4 used for the LED.

On the ESP32 Dev Kit pinout diagram, GPIO12-14 are MISO, MOSI, and CLK respectively, but that usage would seem incompatible with GPIO12 being free.

Does the ESP32CAM Annex firmware support another SPI device?

Failing that, can the Tx and Rx pins be used for an I2C connection to an MCP23008 (and does the firmware support I2C)?
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: ESP32CAM & I/O with 74HC595 or MCP23S08?

Post by cicciocb »

Hi Lizby,
the I2C is supported and you can define any pin with the command

Code: [Local Link Removed for Guests]

I2C.SETUP sda_pin, scl_pin
For the SPI, I think that it should be available using the pins

Code: [Local Link Removed for Guests]

		MOSI_pin = 15;
		MISO_pin = 2;
		SCLK_pin = 14;
		SDCARD_CS_pin = 13;
The SPI should be available only if the SDCARD is enabled but I cannot confirm as I never tested.

If you want use serial expanders using the SPI or the I2C, there are some examples in the help

cicciocb
lyizb
Posts: 93
Joined: Fri Feb 12, 2021 8:23 pm
Has thanked: 36 times
Been thanked: 23 times

Re: ESP32CAM & I/O with 74HC595 or MCP23S08?

Post by lyizb »

Thank you very much. So for the ESP32CAM, I should be able to use the Tx and Rx pins for I2C with I2C.SETUP 1,3 and then have pin 12 available for a DS18B20? That's the minimum I need. I'll test that with the MCP23008 I have.

Or for SPI, I could use pin 12 for CS for the MCP23S08 and have TX and RX available for general I/O use? I don't have the MCP23S08, but will order several.

I have used the MCP23017 modules with Annex with a D1 Mini, so I have code examples. And I've seen the example with the MCP23S17.

Thanks again. Annex is a wonderful product, and it deserves more widespread use than it appears to be getting.
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: ESP32CAM & I/O with 74HC595 or MCP23S08?

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Fri May 20, 2022 12:38 pm Thank you very much. So for the ESP32CAM, I should be able to use the Tx and Rx pins for I2C with I2C.SETUP 1,3 and then have pin 12 available for a DS18B20? That's the minimum I need. I'll test that with the MCP23008 I have.

Or for SPI, I could use pin 12 for CS for the MCP23S08 and have TX and RX available for general I/O use? I don't have the MCP23S08, but will order several.

I have used the MCP23017 modules with Annex with a D1 Mini, so I have code examples. And I've seen the example with the MCP23S17.

Thanks again. Annex is a wonderful product, and it deserves more widespread use than it appears to be getting.
Yes, you can use the SPI with the MCS23S08 or S17 but I suggest to use the I2C as you mention.
I tried to integrate directly the support for the MCP23017 but it is so simple to interface that I gave up every time I tried.

edit:
Do not forget that, if you don't use the SDCARD, all the related pins can be freely used
lyizb
Posts: 93
Joined: Fri Feb 12, 2021 8:23 pm
Has thanked: 36 times
Been thanked: 23 times

Re: ESP32CAM & I/O with 74HC595 or MCP23S08?

Post by lyizb »

Thanks. Is the SD card needed for taking pictures? I plan to email them immediately, so there's no great need for long-time storage.
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: ESP32CAM & I/O with 74HC595 or MCP23S08?

Post by cicciocb »

No, the pictures can be stored in the internal disk
lyizb
Posts: 93
Joined: Fri Feb 12, 2021 8:23 pm
Has thanked: 36 times
Been thanked: 23 times

Re: ESP32CAM & I/O with 74HC595 or MCP23S08?

Post by lyizb »

Excellent, thank you. That gives me more I/Os that I can use.

So as I see it, pins 1-4 and 12-15 are accounted for. What are pins 0 and 16 used for?
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: ESP32CAM & I/O with 74HC595 or MCP23S08?

Post by cicciocb »

Gpio 0 is used to put the module in programming mode and pin 16 and 17 are used by the PSRAM.
These pins should not be used
lyizb
Posts: 93
Joined: Fri Feb 12, 2021 8:23 pm
Has thanked: 36 times
Been thanked: 23 times

Re: ESP32CAM & I/O with 74HC595 or MCP23S08?

Post by lyizb »

I've used this CH340 module to flash the ESP32CAM with the Arduino flash program: https://www.aliexpress.com/item/1005001900359624.html

However, I haven't been able to flash Annex or to use the Annex flashing software to check the ESP32CAM parameters (so I don't know if its 8MB PSRAM, though it was advertised as such). Connecting the Annex serial terminal shows that the Arduino program is running when I press and release the reset button on the CH340 module, so I'm connected to the right serial port.

Is there something I need to do to get the Annex flashing software to see the ESP32CAM with this module?
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: ESP32CAM & I/O with 74HC595 or MCP23S08?

Post by cicciocb »

No, you can flash AnnexCAM in the same was you do with Annex.
Do not forget to put the GPIO0 on gnd before and then supply the module (it must start with GPIO0 to GND)
Post Reply