@kaydend, stereo!! Can you confirm that those are 3.3K ohm resistors? Do you have a picture of your whole setup?
@peekay123 currently they are 2.2k resistors because someone suggested I try them earlier. I can change them to 3.3k if you think it will make a difference. Iāll post a picture of my whole setup
When things donāt go well for me (after Mr. Pullup spanks me) I look at the power.
how much power do you have on that rig?
the photon and the ESP can each draw over 250mA at startup
perhaps you can try to 1) put a big cap on the power rail or 2) bump the power to the rig?
@BulldogLowell Iām kinda new to his whole electronics thing, so like what would be a good size cap for this? Also, it is starting up just fine but the I2C thing just aināt working
@kaydend, do you have a common ground between the Photon and esp?
Yes, the yellow pin in connected to the Photons GND and the ESPs GND
So the issue is that you are trying to use Particle.publish in the Slaveās onReceive handler. And IIRC the interrupts are disabled after that handler is called, so your Photon will lock up if you try to publish within the handler. If you comment out that line of code things will probably work.
And other thoughts I had firstā¦ but probably wonāt matter now.
Hi @kaydend, thanks for taking the time to rewire things. I wonder if the slave address is shifted? Can you change the Master code to use Slave address 0, then update the Slave to use 0 as well. Then no shift in address will cause an issue if there is one. Some devices interpret the numbers you use as 7-bit addresses and other may use 8-bit.
Also Iād like to see if you can run the exact example in the Docs and see if you have better luck with that, since I know your Arduino doesnāt have Particle.publish()
#define SLAVE
// #define MASTER
#ifdef MASTER
void setup() {
Wire.begin(); // join i2c bus as master
}
byte x = 0;
void loop() {
Wire.beginTransmission(0); // transmit to slave device #0
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
x++;
delay(1000);
}
#endif
#ifdef SLAVE
void receiveEvent(int howMany) {
while(1 < Wire.available()) { // loop through all but the last
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}
void setup() {
Wire.begin(0); // join i2c bus with address #0
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
}
void loop() {
delay(100);
}
#endif
Yep, that was it. I donāt how to thank you, This has been stressing me out for a week. I just got my Photon 3 ish weeks ago and so far I have had the best experience with it out of all my IOT type devices. Keep up the good work
Also maybe thatās should be put on docs
Thanks for the reminder! Just added these notes to the onReceive/onRequest handlers:
Note: This handler will lock up the device if System calls such as Particle.publish() are made within, due to interrupts being disabled for atomic operations during this handler. Do not overload this handler with extra function calls other than what is immediately required to receive/send I2C data. Post process outside of this handler.