Is it possible to control the relays using only ESP32 and firmware?
I’ve been looking at examples online and some other forum answers but I’m not sure if I need to use some other interface for i2c communication.
I’ve been loading MCP23008 examples to the ESP32 but keep getting :
MCP23008 Disconnected!
My ideal solution would be just to be able to load some arduino sketch to the ESP32 and be able to interact with the MCP23008 GPIOs.
Thanks in advance and sorry if my question has an obvious/simple answer.
So far I have tried using the default pins for the i2c connection and also using the 18,19 gpios, but keep getting the “MCP23008 Disconnected!” message.
I have not done any wiring, I just took the product that includes the ESP32, plugged it in and uploaded this code:
Would you happen to know what am I doing wrong?
Your help is very much appreciated.
mcp.begin();
// The address can be changed making the option of connecting multiple devices
mcp.getAddr_MCP23008(MCP23008_DEFAULT_ADDRESS); // 0x20
mcp.pinMode(4, OUTPUT); // Pin 0 and Output Mode
}
void loop(void)
{
byte error;
int8_t address;
address = mcp.mcp_i2cAddress;
// The i2c_scanner uses the return value of
// the Write.endTransmisstion to see if
// a device did acknowledge to the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
uint8_t result;
Serial.println("Getting Relay Response from MCP23008");
Serial.println(" ");
delay(500);
mcp.digitalWrite(4, HIGH);
Serial.println("Turning Relay '5' ON");
Serial.println(" ");
delay(500);
mcp.digitalWrite(4, LOW);
Serial.println("Turning Relay '5' OFF");
Serial.println(" ");
Serial.println(" *************************** ");
Serial.println(" ");
}
else
{
Serial.println("MCP23008 Disconnected!");
Serial.println(" ");
Serial.println(" ************ ");
Serial.println(" ");
}
delay(1000);