I’m trying to connect a LCD via i2c to the Particle Core (and tried it on Photon) but am unable to make it work.
I’ve tried 3 screens (though there might be something faulty), but testing it on a PI and it works. I trying all sorts of stuff, including a different power supply (for the 5v).
I don’t know what else to do. I’m down to the library not working correctly.
My code is pretty straight forward:
/*********************
Example code for the Adafruit RGB Character LCD Shield and Library
This code displays text on the shield, and also reads the buttons on the keypad.
When a button is pressed, the backlight changes color.
**********************/
// include the library code:
//#include <Wire.h>
#include "Adafruit_RGBLCDShield/Adafruit_MCP23017.h"
#include "Adafruit_RGBLCDShield/Adafruit_RGBLCDShield.h"
// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can't use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
void setup() {
// Debugging output
Serial.begin(9600);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.clear();
Spark.publish("loaded", "true");
int time = millis();
lcd.print("Hello, world!");
time = millis() - time;
Spark.publish("process/time", String(time) );
Serial.print("Took "); Serial.print(time); Serial.println(" ms");
lcd.setBacklight(WHITE);
}
void loop() {
lcd.print(millis()/1000);
Serial.println(millis()/1000);
delay(1000);
}
I am still looking for a way to get that basic 16x2 LCD to work on a Photon with I2C. Something about the firmware version not being up-to-date with the IDE because the HAL something.
I’ve tried powering it with many different things but mostly powering it off the MacBook Pro USB port.
I’ve also tried to power it from a YwRobot stright to the Vin pin.
As well as I tired using a Spark Core to run the same code but it still didn’t work
Here is a potentially dumb question, but it caused a similar problem for me. Have you updated your Photon to 0.3.4 yet? Prior to that, I found that neither D0 nor D1 worked and I was having similar issues. The easy test is to throw an LED (and a resistor) on D0 and D1 and turn them on and off and see what happens.
Prior to the update, D0 and D1 would never go high and so my display never worked. Once I upgraded, the two pins behaved normally as did my OLED display.
I’m not sure how to check what version I’m using and I wasn’t able to find great docs on how to update it. However I’ve tried it with a Spark Core and I’ve updated it yesterday.
Is there a great place to read on how to upgrade the Photon?
@anlek, I believe @JL_678 mean Photon system firmware version 0.4.3rc2 which you can find here. It address some of the I2C issues though Particle is testing a new fix.
Ok, I’ve updated it but still no go
Could there be something different in the PI vs the Photon (or Core)?
Could the library for the LCD/Board be messing something up? I mean display Pi plate is using the correct chipset.
I think the next step is to grab an Arduino and try to make the screen work with it. If it works, then I will have to assume the library code for the screen is messed up.
I’ll report back once I have some time to play with it.
So I had some time to play with an Arduino and I have it fully running with the following code:
#include <Wire.h>
#include <Adafruit_RGBLCDShield.h>
#define OFF 0x0
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
lcd.begin(16, 2);
lcd.clear();
int time = millis();
lcd.print("Hello, world!");
lcd.setBacklight(RED);
time = millis() - time;
Serial.print("Took "); Serial.print(time); Serial.println(" ms");
}
void loop() {
lcd.clear();
lcd.print(millis()/1000);
Serial.println(millis()/1000);
delay(1000);
}
I’ve pasted the code into build.particle.io and tweak the require statement to say #include "Adafruit_RGBLCDShield/Adafruit_RGBLCDShield.h" and everything compiled fine, however nothing works
I’ve also just updated to firmware 0.4.4-rc.2 and still nothing.
My understanding is that the firmware 0.4.4-rc.2 does NOT have the I2C fixes in it but that 0.4.4-4c.3 will. That should be available in a day or so according to a post by BDub.
I should say that outside the pullup resistor, I did get corrupted communications from the photon after a few seconds (to a few minutes). Upgrading to firmware 0.4.4-rc3 seems to have fixed the issue completely!