Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By Samighi11
#24878 Thank you for your help. I was able to isolate the programming part and simply use PCF8574s to run my LEDs. it was a lot simpler that way and didn't require multiple ESP modules.

I used GPIO4 and 5 (similar to Arduino) for I2C and PCF8574s. I have pull ups on GPIO0 and RESET with buttons to ground, so I can hold GPIO0 to gnd, then REST, then release GPIO0. that allows me to program it. Once programmed, I don't bother to re-use GPIO0,2,15, and leave them in their state. I am currently using a ESP8266 12, but I can test with 03 and 01 as needed later.

I used the i2c scanner code as is with slight modification. And I was able to run two PCF8574s successfully.

Code: Select all// --------------------------------------
// i2c_scanner
//
// Version 1
// This program (or code that looks like it)
// can be found in many places.
// For example on the Arduino.cc forum.
// The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
// Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26 2013
// V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
// by Arduino.cc user Krodal.
// Changes by louarnold removed.
// Scanning addresses changed from 0...127 to 1...119,
// according to the i2c scanner by Nick Gammon
// http://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
// As version 4, but address scans now to 127.
// A sensor seems to use address 120.
//
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#include <Wire.h>



void setup()
{
Wire.begin(4, 5);

Serial.begin(9600);
Serial.println("\nI2C Scanner");
}


void loop()
{
byte error, address;
int nDevices;

Serial.println("Scanning...");

nDevices = 0;
for(address = 1; address < 127; address++ )
{
// 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)
{
Serial.print("I2C device found at address 0x");
if (address<16)
Serial.print("0");
Serial.print(address,HEX);
Serial.println(" !");
{
 
  //Wire.beginTransmission(32);     //Begin the transmission to PCF8574
    for (int i = 0;i<255;i++) {
  Wire.beginTransmission(address);
  Wire.write(i);         
  Wire.endTransmission();                           //Send the data to PCF8574
      Serial.println(i);
      delay(100);
    }

Wire.endTransmission();   
Wire.beginTransmission(address);
   Wire.write(0);   
   Wire.endTransmission();
}

nDevices++;
}
else if (error==4)
{
Serial.print("Unknow error at address 0x");
if (address<16)
Serial.print("0");
Serial.println(address,HEX);
}
}
if (nDevices == 0)
Serial.println("No I2C devices found\n");
else
Serial.println("done\n");

delay(1000); // wait 5 seconds for next scan
}
User avatar
By Samighi11
#25518 I wanted to add that MCP23017 works great as well. I have reduced the foot print to be simply GPIO15 and GPIO2 to be set to (Low and High) repsectively and permantely, I grind the GPIO0 PIN then ground RESET for a second (just manually using a breadboard). Using just wire.h, I am able to flash the ESP8266 -12. Using GPI4O and GPIO5, i am able to talk to the 23017 perfectly. I have not tested it for speed, but the code is minimal and works.

the only different that should be noted between this and PCF8574 is that you need to force the 23017 pins to output (0 value) and the code is a bit different. However it works well.

I have soldered the ESP-12 and the 23017 to a board. I used RX,TX,VCC,GND from a FTDI programmer (so they are soldered to dupont wires). this makes it easy to program or power without much effort. I plug to a USB cube to power or to the Mac to program.

If anyone would like a picture or demo, please let me know. As always, love the help I get on from this group.

(Next project is to use DTR, CTS to automatically set the GPIO and Reset for Programming??)