So I’m using an esp8266 to transmit an i2c message to my Photon. Unfortunately, when I tested it the Photon did not receive the message, after swapping around wires for a bit I tried receiving the message with the same code on my Arduino UNO and it worked. Here’s my setup, I have the SDA and SCL pulled via a 4.7k resistor to 3.3v and the SDA line is going into D0 and SCL to D1.
Well, If It did send 0x00 then the string would be terminated when I tested it on my Arduino. I don’t think it’s the problem here, as far as I can see, the receiveEvent function never gets called on the Photon.
Update
I have tried sending the transmission using an Arduino with the same 4.7k resistors and the Photon is still not calling the receiveEvent function.
OK, the following code works for me! First the transmitter sending one incrementing byte to address 8 and blinking the D7 LED to show that it is sending:
Hmm, I see you got is working. I’ll post some picture of the photon setup and my working Arduino setup. Maybe you can shed some light on what I’m doing wrong. Sorry about the bad lighting if it’s not good enough, I can find some more light and take better ones.
Oh, and by the way, this is the data being printed to the serial monitor on the Arduino with the code in the original post. This is exactly what I wanted.
{"sensor":0,"state":0}
{"sensor":0,"state":1}
You seem to be showing the case where the Photon is the slave in the first 3 photos (that’s great) but then the UNO swapped in for the Photon also as slave. Where is the master?
Your wiring is not easy to follow–I would try having just three wires between master and slave: SDA, SCL and GND.
Where does the multicolor ribbon cable with SDA and SCL off to the right? To the master?
Yeah sorry about that I have taken some new pictures. Indeed the ribbon cable goes off to the master, Which is an esp8266 being used as a “Gateway” for my wifi mesh network of esp8266 powered garage door sensors. I have simplified the cables down to a Red SDA wire, Orange SCL wire, and a Yellow GND wire. After the red and orange wire come off the ribbon cable they are in pulled to 3.3v and they head off to white and blue jumpers that go to D0 and D1 respectively.
They rest of the wires on the original picture was just the 3.3v regulator as the esp8266 only accept 3.3v.
I have also just tested the Photon as a slave with an Arduino UNO as the master, with the same 4.7k resistors and that didn’t even work. This one has really stumped me.
My pullups are connected to 3.3v in the part of the breadboard my hand was covering up which contained a 3.3v regulator. If you go look at the original pictures, you can kinda see how that regulator is hooked to the power rail on the breadboard. Unfortunately, I don’t have two Photons and my FTDI cable broke that I used to program the esp8266s but I have a new one coming tomorrow so, I’ll try that when it arrives. Anyway, I have to get off for the night so I won’t reply until the morning.
Looks like @bko has you well covered. Something to note which shouldn’t really matter much, you mentioned 4.7k ohm pullups and I’m pretty sure I see 10k ohm pull ups in your pictures. They should work, but maybe try 4.7k or even 2.2k ohm.
You are correct, I measured those pull-ups and indeed they were 10k. So I took those out and got some real 4.7k resistors (I made sure to measure them), but these still didn’t work. I also tried the pull-ups as 2.2k (confirmed by my multimeter), but those didn’t work either. I also tried those two pull-up values with the Arduino UNO and they worked perfectly.
I would clean up your wiring as @bko suggested, and use as little jumpers as possible. That should be a quick process.
Also check your jumpers and make sure they are not open inside the black rubber part. That style of jumper has the wire soldered to a pin, and they are notorious for breaking and opening inside the rubber part. The rubber part will hold the wire and pin seemingly connected, but they are deceiving.
I have rebuilt it again with no jumpers and simplified as much as possible. The reason I’m using the ribbon cable to go from my ESP8266 to the Photon is that the ESP8266 pins don’t fit on the breadboard. This setup still doesn’t work. I’ll attach some pictures of this re-organized setup. Later today I will try this with @bko receive code on the Photon and the transmit code on the ESP8266 running https://github.com/esp8266/Arduino which is what I was already using.
@peekay123 It is not on both ends of the wires. Those are not two different Photons, It’s just two pictures from slightly different angles. Sorry for the confusion.