Sunday 17 July 2016

Particle Photon: Attaching a display screen

I've been looking into using a Photon as a small monitoring display. Given it's ability to gather sensor data and connect to the internet for remote data, I thought this could be useful for things like monitoring plants or even production traffic at work.

I picked a cheap and cheerful little screen to play around with as I thought there was quite a high chance of burning it out or doing something stupid. I went for a 2.2" LCD display with micro SD card built in from Adafruit. Here it is hooked up to the Photon running a graphics demo program.




The screen comes mounted on a breakout board with a strip of header pins to mount on the connectors along the bottom. I soldered the header strip into the connectors as shown below. This made it easy to plug into a breadboard to use for prototyping.

solder the header strip onto the breakout board

You will need 8 jumper cables to connect the Photon to the screen. There are specific pins you need to use for hardware SPI (detailed here). The connections needed, from left to right are:

  • SCK   - A3
  • MISO - A4
  • MOSI - A5
  • CS      - A2
  • RST   - A0
  • D/C    - A1
  • VIN   - 3V3
  • GND - GND

The 2.2" display wired up to the photon


Thankfully Adafruit has provided a few libraries you can use to perform functions on the screen like draw lines, load images and write text. These libraries have been ported to work with particle devices and are available here -> (Adafruit_mfGFX_IDE, Adafruit_ILI9341) Both of these libraries are available in the Particle Build IDE to be imported into your project.

The demo running in the video is the example file that comes with the Adafruit_ILI9341 library. To get it working for yourself:

  1. Create a new App in the IDE
  2. Include library ADAFRUIT_MFGFX
  3. Include library ADAFRUIT_ILI9341
  4. Copy the contents of testgfx.ino from ADAFRUIT_ILI9341 into your App main file
  5. Verify the program
  6. Choose your target device
  7. Flash
Note: I couldn't compile the test program due to some errors in Adafruit_ILI9341.h around the pinLO and pinHI declarations. After some digging I found a post on the community forum detailing the update required to fix the compilation errors. I have forked the Adafruit_ILI9341 library and applied these fixes and it compiles fine now. If you want to use my fork in the IDE go to the 'Libraries' tab and choose 'Contribute Library'. You can add the github repo here and it will be available for you to use privately. I am not going to submit it as a public library as I've submitted the change as a pull request to the official library, but until it is merged this is a workaround.