• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Esp32 cam module i2c & other i/o

dr pepper

Well-Known Member
Most Helpful Member
I got an Aithinker Esp32 camera module to play with.
The camera works fairly well.
I wanted to add a webcam to one of my webpages, I got the camera to work, and the webpage to serve Ok, the page serves & jsons work fine.
But now I'm finding it tricky getting an external i2c working, the cam already uses i2c, however the Esp32 has 2 i2c modules.
I found some info, the wire lib already supports using 2 i2c's at once, I tried this but I odnt even get the pins to change state.
I can supply some code if anyones interested.
These seem to be failry new & unused as yet.
One thing I did fond the cam uses espressifs (or lolin) own webserver lib, however if you dont want to use the cam you can use the libs from the esp8266 and run a server or whatever you want, seems to work fine, and a little quicker.
 

dr pepper

Well-Known Member
Most Helpful Member
I made some progress.
The new version of wire supports 2 i2c channels.
You can have wire(), and wire1().
You can specify any pins for clock & dat on either i2c channels.
So you can go:
Wire1(12,13,100000) for dat on pin 12, & clock on pin 13 at 100khz frequency, channel 0 is left as it was defined & you now have a second i2c channel, channel 1.
I am trying this with an i2c light sensor, I had to go into the .cpp library file for the sensor and change all the Wire. entries to Wire1. so that the library will use the correct i2c channel.
My code compiles & programs, however the extra load of the light sensor is causing the chip to repeatedly reset on power up, so I need to try it on a better power supply when I get yam, hopefully it'll work now.
 

dr pepper

Well-Known Member
Most Helpful Member
Sussed it.
It was stupid, or maybe I am.
The cam module software was I think written by one of espresifs engineers, I think the code is written so that it takes up the I2c module every time the camera takes a frame, ie the I2c instance is created, a frame taken, then the resources are released (destructed), this means the I2C module is available for use when the cam isnt operating.
In short all you have to do is declare an instance using Wire(), a-la:
Wire (15, 16);
Which works and defines the I2c clock & data pins as 15 & 16, why didnt I htink of that first, doh.
 

Latest threads

EE World Online Articles

Loading

 
Top