scargill wrote:
..
I'm having trouble - I have an ESP8266 talking to Arduino.
hi pete, i understand you so , you use
ESP8266 as I2C Master
Arduino as I2C Slave
ok?
scargill wrote:
The ESP can send multiple bytes to the Arduino - no problem -
but I haven't a clue how to get multiple bytes back into the ESP.
so , do this:
you pulse the clk by esp8266 as master to the arduino and read the input on esp8266 sda what the i2c slave arduino send.
scargill wrote:Repeated reads causes the ESP to crash so clearly I'm missing somebut I can't find anything out there - examples of using the SDK code for communications - indeed there aren't even any examples in the SDK.
Anyone familiar with this scenario??
pete, you must study first I2C Master and I2C Slave
there are ACK, NACK, LAST, Status, Start, Stop, ISR SDA, ISR CLK, Master Send, Slave Send..
example here is a I2C Slave
in the follow, there is a I2C Master ( ESP8266 ) and a I2C Slave ( ESP8266 ) ..
read in..
have a look into this threadand
study thisand
here you can watch an exampleI2C Slave is done in the past.
perhabs it helps to understand, how you must code the arduino ( I2C Slave )
that you can read by the Master ( ESP8266 ) from the Slave ( Arduino )
The SDA is the own pin for Master send and for Slave receive
also , for Slave send, and Master receive.
The direction is in the
I2C standard protokol describedhope this helps.
best wishes
rudi

edit:
NONOS: read i2c_master.h
there are all your friends here what you need for read from Arduino,
you must code Arduino in the Arduino IDE as Slave with an address,
and this you send by ESP8266 as I2C Master to the Arduino,
and then you can read by the Master..:
Code: Select all
void i2c_master_gpio_init(void);
void i2c_master_init(void);
void i2c_master_start(void);
void i2c_master_stop(void);
void i2c_master_setAck(uint8 level);
uint8 i2c_master_getAck(void);
uint8 i2c_master_readByte(void);
void i2c_master_writeByte(uint8 wrdata);
bool i2c_master_checkAck(void);
void i2c_master_send_ack(void);
void i2c_master_send_nack(void);
you must study I2C protokoll first, so you see the tree in the jungle what you search for

you start with a start by the master,
that do the sda low and then comes the clk
this is the begin of the protokoll,
"see start condition"
(if you do this with multi masters then you must check before, that bus is free with a check for SDA is high example..)
with a SDA low you signal in the bus, that you are will send data now.
after this , the bus is yours.
next ist the write byte,
you send the 7bit adress and shift in your command , want read << 1 or want write << 0
the slave check this
- address matching
- its a read or write
example a read,
then slave put the bits on at sda on each clk pulse ( 8 bits= 1 byte )
this is done, if the master reads a byte, because only the master can pulse the clk..
so
edit ( for better understanding )
the master read a Byte and on 9. clk cykle gives a ACK or NACK for the LAST
and the slave send data whilest the Master request it
// btw slave code..
/ edit
Code: Select all
LAST = i2c_ArduinoSlave_TxByte(data);
while ( LAST == 0 )
// ACK = 0, NACK = 1
here you go on detailed:
read here, take this:
http://www.ti.com/lit/an/slva704/slva704.pdfand read carefull opendrain config