have you verified the I2C address?
Hi.
Yep, the spec says 0x27 but I have also tried 0x3F as some seem to use that. I only have the display connected to my photon - nothing else.
do you know how to verify with I2C scanner?
// --------------------------------------
// i2c_scanner
//
// http://playground.arduino.cc/Main/I2cScanner
//
// 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 <application.h>
//#include <Wire.h>
void setup()
{
Wire.begin();
Serial.begin(9600);
delay(10000);
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(" !");
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(5000); // wait 5 seconds for next scan
}
Iāll give that a try and report back this evening. Thanks!
How have you connected your pull-ups?
BTW:
The I2C interface is documented here
https://docs.particle.io/reference/firmware/photon/#wire-i2c-
so
SDA ⦠D0
SCL ⦠D1
@ScruffR Independent 5K1 resistors from +5V to D0 and D1
I ran the scanner (well an updated version of it - as listed below to use Particle.publish() as I donāt have a serial rigged up at the moment). Iām afraid it didnāt t find anything.
Iām a bit mystified here⦠probably because I know the square root of not much about I2C - but anyway, there are only two lines SCL and SDA (which is all my display has) so surely that just means clock out and data out? Or do they go bi-directional in some clever way I donāt understand? Unless they do, how would this detection thing work - if itās output only?
Yeah, I should go read up on I2Cā¦
Thanks guysā¦
// --------------------------------------
// i2c_scanner
//
// http://playground.arduino.cc/Main/I2cScanner
//
// 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.
//
// Version 6, Feb 18th 2017
// By Photon user Alan T.
// Use publish instead of Serial.print so can see msgs in cloud
// also allows easier output formatting using sprintf
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//
#include <application.h>
//#include <Wire.h>
char publishBuffer[80];
void setup()
{
Wire.begin();
sprintf(publishBuffer,"I2C Scanner: Beginning...\n");
publishTheBuffer();
delay(10000);
}
void loop()
{
byte error, address;
int nDevices;
sprintf(publishBuffer,"Scanning...\n");
publishTheBuffer();
nDevices = 0;
for(address = 1; address < 127; address++ )
{
sprintf(publishBuffer,"Now scanning address %00x \n",address);
publishTheBuffer();
// The i2c_scanner uses the return value of
// the Wire.endTransmisstion to see if
// a device did acknowledge from the address.
Wire.beginTransmission(address);
error = Wire.endTransmission();
if (error == 0)
{
sprintf(publishBuffer,"I2C device found at address %00x \n",address);
publishTheBuffer();
nDevices++;
}
else if (error==4)
{
sprintf(publishBuffer,"Unknown error at address %00x \n",address);
publishTheBuffer();
}
// Wait for a while so as not to flood the publish channel...
delay(1100);
}
sprintf(publishBuffer,"Number of I2C devices found = %00d\n", nDevices);
publishTheBuffer();
delay(5000); // wait 5 seconds before repeating
}
void publishTheBuffer() {
Particle.publish("I2C Scanner",publishBuffer,10,PRIVATE);
}
Since you are not getting an address, that makes me suspect that your connections are not correct.
Mind posting a photo of your rig, along with the pull-up resistor values?
Okay so 1 photo shows the mini breadboard with the Photon (powered from a USB mains brick). On teh right you can see the two wires coming in from the +5V DC supply (positive on the right neg on the left - via a screw connector block. You can see the positive lead from that go to the +rail, from which the 5k1 resistors are pulling up D0 and D1. The ground from the external DC goes to the ground terminal on the Photon - as does the ground from the display.
The other Photo shows the display connections with the coloured wires coming in from the breadboard. Just looking at this macro lens photo now, I am wondering about those Ax PCB markings⦠as you saw in the eBay link it clearly says that the device is set for address 0x27 - but now I am wonderingā¦
Thanks again.
Best regards
Alan T.
Actually this one is the same board and they say it defaults to address 0x3F unless you change it with the Ax jumpers. In any case it wasnāt found in the scan of all addresses so thatās probably a red herring.
it all looks OK.
Iām OCD so I would push the connectors all the way up onto the I2C backpack to make sure I had a good connection.
Also, your I2C backpack may already have pull-up resistors so adding 5K along with that may be a problem (particularly since you are working with 3V3 logic pins. so you can try removing the pull-ups and either testing you sketch or scanning for an I2C address. They are 5V tolerant so worry not.
Finally⦠and forgive me i this sounds pedantic, you turned the potentiometer on the backpack to make sure that it isnāt already displaying? iāve been burned by that, so I feel I have to ask!
good luck.
That D1 pull-up does not look like a 5K1 resistor.
That looks more like 100Ohm (brown black brown)
I'd also remove that contraption with the yellow and orange wires and just power the Photon via USB and the display off Vin & GND.
@BulldogLowell, the I2C HIGH level is only provided by the pull-up level and (commonly) not by the GPIO pins.
So when the pull-ups go to 5V the HIGH level will be 5V the master and slave just pull the level to LOW and (commonly) let go of it to let the resistors pull back to HIGH.
But the 100Ohm might be much to strong for the clock pin to get a clean LOW.
@AlanSparkMan, 100Ohm @5V are even exceeding the 25mA max current limit for GPIOs by the factor 2.
The pin would have to sink 50mA which might even damage the pin (or already has).
they do look different from one another!
Good catch @ScruffR! youāre quite right that WAS a 100 ohm resistor not a 5K1. I have now replaced it and got rid of the external supply so that itās all off the USB supply - but the problem remains the same
he scanner code still finds nothing (I assume I havenāt screwed up that code in any way - I only changed out all those Serial.prints for publishes - the logic remains the same?). In any case if I use the āclock.inoā code as obtained via the IDE it doesnāt display (tried 0x27 and 0x3F as the address).
Wound up the display pot @BulldogLowell and all I see is some random blocks which never change or clear (as per photo) - presume random power up chars?
New photos attached.
Seen my edit above?
You may have to check whether D1 is still intact.
Odder and odderā¦!
I wrote a test program
void setup() {
pinMode(D0,OUTPUT);
}
void loop() {
digitalWrite(D0,HIGH);
delay(3000);
digitalWrite(D0,LOW);
delay(3000);
}
and when I run it on D0 I see a steady 2.06V
When I run it on D1 I see it alternate between about 2.9 and <1V
so seems like D0 is cooked, not as one would expect D1. Perhaps I had the resistors on the other way round earlier on and it cooked it then I did try removing them at one stageā¦
Anyway, I have another photon, I will try that now.
Thanks a million guysā¦
Yep, that did it. All OKAY now! The clock example works.
Looks like I bricked both those pins on the previous Photon board
On the replacement photon I ran that same code and D0 and D1 cycled between about 3.13 and 0.6 volts - so even D1 on the old board was not really working like it should have.
Also, in case its of any use to anyone, these boards actually do respond to address 0X3F and NOT 0x27 as stated by the vendor (an eBay vendor giving out defective technical information about a product? I wish that was a rarityā¦!!)
Anyway, thank you both for your time and help - I would not have got there without you.
Best regards
Alan T
PostScript: Out of curiosity I tried it without the pull-ups. Ironically, it worked fine - so I never needed to fit pull-ups anyway
I guess my original problem was that I believed the 0x27 was the address and when it didnāt work, I tried the resistors rather than a different address - and it all went downhill from there⦠oh well, live and learn! Onward and upward