Using the ST7735 1.8″ Color TFT Display with Arduino

Hi guys, welcome to today’s tutorial. Today, we will look on how to use the 1.8″ ST7735  colored TFT display with Arduino. The past few tutorials have been focused on how to use the Nokia 5110 LCD display extensively but there will be a time when we will need to use a colored display or something bigger with additional features, that’s where the 1.8″ ST7735 TFT display comes in.

1.8″ Colored TFT Display

The ST7735 TFT display is a 1.8″ display with a resolution of 128×160 pixels and can display a wide range of colors ( full 18-bit color, 262,144 shades!). The display uses the SPI protocol for communication and has its own pixel-addressable frame buffer which means it can be used with all kinds of microcontroller and you only need 4 i/o pins. To complement the display, it also comes with an SD card slot on which colored bitmaps can be loaded and easily displayed on the screen.

Other features of the display include:

  • 1.8″ diagonal LCD TFT display
  • 128×160 resolution, 18-bit (262,144) color
  • 4 or 5 wire SPI digital interface
  • Built-in microSD slot – uses 2 more digital lines
  • 5V compatible! Use with 3.3V or 5V logic
  • Onboard 3.3V @ 150mA LDO regulator
  • 2 white LED backlight, a transistor connected so you can PWM dim the backlight
  • 1×10 header for easy breadboarding
  • 4 x 0.9″/2mm mounting holes in corners
  • Overall dimensions: 1.35″ x 2.2″ x 0.25″ (34mm x 56mm x 6.5mm)
  • Current draw is based on LED backlight usage: with full backlight draw is ~50mA

The goal of this tutorial is to demonstrate the abilities of the TFT to display images and text in different colors and some animation.

Required Components

The following components are needed for this tutorial:

  1. ST7735 Color TFT display 
  2. Cheap Arduino Uno
  3. Small Breadboard
  4.  Wires

As usual, the exact components used for this tutorial can be bought by following the link attached to each of the components above.

Schematics

The schematics for this project is fairly easy as the only thing we will be connecting to the Arduino is the display. Connect the display to the Arduino as shown in the schematics below.

Schematics

Due to variation in display pin out from different manufacturers and for clarity, the pin connection between the Arduino and the TFT display is mapped out below:

1.8″ TFT – Arduino

LED - 3.3v
SCK - D13
SDA - D11
DC - D9
Reset - D8
CS - D10
GND - GND
VCC - 5v

Double check the connection to be sure everything is as it should be. All good? now we can proceed to the code.

Code

We will use two libraries from Adafruit to help us easily communicate with the LCD. The libraries include the Adafruit GFX library which can be downloaded here and the Adafruit ST7735 Library which can be downloaded here.

We will use two example sketches to demonstrate the use of the ST7735 TFT display. The first example is the lightweight TFT Display text example sketch from the Adafruit TFT examples. It can be accessed by going to examples -> TFT -> Arduino -> TFTDisplaytext. This example displays the analog value of pin A0 on the display. It is one of the easiest examples that can be used to demonstrate the ability of this display.

Displaying values from Arduino pin A0

The second example is the graphics test example from the more capable and heavier Adafruit ST7735 Arduino library. I will explain this particular example as it features the use of the display for diverse purposes including the display of text and “animated” graphics. With the Adafruit ST7735 library installed, this example can be accessed by going to examples -> Adafruit ST7735 library -> graphics test.

To briefly explain the example,

The first thing, as usual, is to include the libraries to be used after which we declare the pins on the Arduino to which our LCD pins are connected to. We also make a slight change to the code setting reset pin as pin 8 and DC pin as pin 9 to match our schematics.

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>


// For the breakout, you can use any 2 or 3 pins
// These pins will also work for the 1.8" TFT shield
#define TFT_CS     10
#define TFT_RST    8  // you can also connect this to the Arduino reset
                      // in which case, set this #define pin to 0!
#define TFT_DC     9

Next, we create an object of the library with the pins to which the LCD is connected on the Arduino as parameters. There are two options for this, feel free to choose the most preferred.

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,  TFT_DC, TFT_RST);

// Option 2: use any pins but a little slower!
#define TFT_SCLK 13   // set these to be whatever pins you like!
#define TFT_MOSI 11   // set these to be whatever pins you like!
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);

Next, we move to the void setup function where we initialize the screen and call different test functions to display certain texts or images.  These functions can be edited to display what you want based on your project needs.

void setup(void) {
  Serial.begin(9600);
  Serial.print("Hello! ST7735 TFT Test");

  // Use this initializer if you're using a 1.8" TFT
  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab

  // Use this initializer (uncomment) if you're using a 1.44" TFT
  //tft.initR(INITR_144GREENTAB);   // initialize a ST7735S chip, black tab

  Serial.println("Initialized");

  uint16_t time = millis();
  tft.fillScreen(ST7735_BLACK);
  time = millis() - time;

  Serial.println(time, DEC);
  delay(500);

  // large block of text
  tft.fillScreen(ST7735_BLACK);
  testdrawtext("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. ", ST7735_WHITE);
  delay(1000);

  // tft print function!
  tftPrintTest();
  delay(4000);

  // a single pixel
  tft.drawPixel(tft.width()/2, tft.height()/2, ST7735_GREEN);
  delay(500);

  // line draw test
  testlines(ST7735_YELLOW);
  delay(500);

  // optimized lines
  testfastlines(ST7735_RED, ST7735_BLUE);
  delay(500);

  testdrawrects(ST7735_GREEN);
  delay(500);

  testfillrects(ST7735_YELLOW, ST7735_MAGENTA);
  delay(500);

  tft.fillScreen(ST7735_BLACK);
  testfillcircles(10, ST7735_BLUE);
  testdrawcircles(10, ST7735_WHITE);
  delay(500);

  testroundrects();
  delay(500);

  testtriangles();
  delay(500);

  mediabuttons();
  delay(500);

  Serial.println("done");
  delay(1000);
}

Next, is the void loop function. The void loop function for this project basically inverts the display after 500 ms.

void loop() {
tft.invertDisplay(true);
delay(500);
tft.invertDisplay(false);
delay(500);
}

All the functions called under the void setup function, perform different functions, some draw lines, some, boxes and text with different font, color and size and they can all be edited to do what your project needs.

The complete code for this is available under the libraries example on the Arduino IDE. Don’t forget to change the DC and the RESET pin configuration in the code to match the schematics.

Demo

Uploading the code to the Arduino board brings a flash of different shapes and text with different colors on the display. I captured one and its shown in the image below.

Demo

Cool right?

That’s it for this tutorial guys, what interesting thing are you going to build with this display? Let’s get the conversation started. Feel free to reach me via the comment section if you have any questions as regards this project.

Till next time!

You can watch the video of this tutorial on youtube here.

Laser Beam Wireless Smartphone Chargers: The Next Big Thing

Cellphone chargers have been in existence for years and have grown from one stage to another. It started with the mobile phone traditional charger which had a USB interface, a DC converter, and a charging plug and now has expanded to a close-range inductive wireless charging. The commonly used inductive wireless charging is nice but limited, it still requires close contact with the charging pad making it offer little or no advantage to cable-based chargers. We have seen some potential long-range wireless chargers especially those from the PowerSpot, which in theory could charge up to 80 feet away. Among those technologies, charging with a laser beam is a possibility the research team from the University of Washington is evaluating.

Researchers from the UW’s (University of Washington), Paul G. Allen School of Computer Science & Engineering, have designed a laser system that can remotely charge your smartphones as quickly as a standard USB cable. They have embedded essential safety features which include a metal, flat-plate heat sink on the smartphone to dissipate excess heat from the laser, as well as a reflector based system to turn off the laser if a person tries to get in the way of the charging beam.

Shyam Gollakota, an associate professor at the UW’s Paul G. Allen School of Computer Science & Engineering said “We have designed, constructed and tested this laser-based charging system with a rapid-response safety mechanism, which ensures that the laser emitter will terminate the charging beam before a person comes into the path of the laser”. Continue reading “Laser Beam Wireless Smartphone Chargers: The Next Big Thing”

IBM just unveiled the ‘world’s smallest computer’

by @ theverge.com

The computer is 1mm x 1mm, smaller than a grain of fancy salt, and apparently costs less than ten cents to manufacture. To be clear, the picture above is a set of 64 motherboards, each of which hold two of this tiny computer.

IBM claims the computer has the power of an x86 chip from 1990. That puts it exactly on the edge of enough power to run the original Doom (the original README.TXT for Doom says a 386 processor and 4MB of RAM is the minimum). Hopefully IBM will be more forthcoming with benchmarks in the next five years, and I’m looking forward to repurposing this chip’s LED as a one pixel display.

Introducing Project Fin: a board for fleet owners

Introducing Project Fin, a carrier board designed for the Raspberry Pi Compute Module 3 Lite.

It’s a carrier board that can run all the software that the Raspberry Pi can run, hardened for field deployment use cases, and adding some of the things we’ve seen our users needing the most. It includes 8/16/32/64 GB of on-board eMMC depending on the model, has dual-band connectivity for both 2.4 and 5GHz WiFi networks, can take an external antenna for WiFi and Bluetooth, and can accept power input from 6v to 30v (or 5v if you power through the HAT) via industrial power connectors.

It also comes with two special features. The first is a microcontroller that has its own Bluetooth radio and can operate without the Compute Module being turned on. This enables the Fin to perform well in real-time and low-power scenarios. The Compute Module, along with its interfaces, can be programmatically shut down and spawned back up via the microcontroller, which can access the RTC chip when the Compute Module is OFF for time-based operations. In addition, the Fin has a mini PCI express slot, which can be used to connect peripherals such as cellular modems. The Fin also has a SIM card slot to make it even easier to connect a cellular modem.

[source]

Powering Batteries With Protons – A Potential Disruption in the Energy Industry

Climate Change have been a crucial factor taken into consideration by the Australian researchers from Royal Melbourne Institute of Technology before creating the first rechargeable proton battery. After considering all available options about cost and availability of the materials needed, the researchers in Melbourne decided to make a proton battery to meet up with the alarming increase of energy needs in the world.

Proton Battery

Lead researcher Professor John Andrews says, “Our latest advance is a crucial step towards cheap, sustainable proton batteries that can help meet our future energy needs without further damaging our already fragile environment. As the world moves towards inherently variable renewable energy to reduce greenhouse emissions and tackle climate change, requirements for electrical energy storage will be gargantuan”. The proton battery is one among many potential contributors towards meeting this enormous demand for energy storage. Powering batteries with protons has the potential to be more economical than using lithium ions, which are made from scarce resources. Carbon, which is the primary resource used in our proton battery, is abundant and cheap compared to both metal hydrogen storage alloys and the lithium needed for rechargeable lithium-ion batteries.

Here’s how the battery works; During charging, protons generated during water splitting in a reversible fuel cell are conducted through the cell membrane and directly bond with the storage material with the aid of electrons supplied by the applied voltage, without forming hydrogen gas. In electricity supply mode, this process is reversed. Hydrogen atoms released from the storage lose an electron to become protons once again. These protons then pass back through the cell membrane where they combine with oxygen and electrons from the external circuit to reform water. In simpler terms, carbon in the electrode bonds with the protons produced whenever water is split via the power supply’s electrons. Those protons pass through the reversible fuel cell again to form water as it mixes with oxygen and then generates power.

According to Andrews, “Future work will now focus on further improving performance and energy density through the use of atomically-thin layered carbon-based materials such as graphene, with the target of a proton battery that is truly competitive with lithium-ion batteries firmly in sight.” With the kind of progress made, it might not be now, however, lithium-ion batteries might be put out of the market in the nearest future.

The team is looking to improve their research, ameliorate the battery’s performance, and exploit other better materials like graphene to further put this proton battery to its fullest potential. Developments like will be needed if we are going to create sustainable future especially with the ever rising cost and demand of Energy.

One thing is sure, the Energy Industry is going to be disrupted now or in the future, and this proton battery innovation could just be one of the potential ways.

Program Pi, BeagleBone and Other Linux SBCs On The Arduino Create Platform

We have seen the massive ecosystem the Arduino has built and established over the last few years and this has made developing with Arduino quite leisurely. It is way easier to solve a programming issue or hardware issue with Arduino unlike other hardware boards mostly due to its community.  Arduino Create is an online platform by the Arduino Team that simplifies building a project as a whole, without having to switch between many different tools to manage the aspects of whatever you are making.

Arduino Create

Arduino Create is excellent especially for people already used to build stuff with Arduino boards, but what about the likes of Raspberry Pi, BeagleBones, and other makers board? The Arduino boards are great, especially the famous Arduino Uno, but this board still have it’s limitations too. The Raspberry Pi/BeagleBone on the other hand could take some task that the 16MHz Arduino Uno will never dream of doing, but this will also require makers and developers to begin learning new hardware (could be daunting for beginners). But this is changing now, as Massimo Banzi, CTO, and Arduino co-founder announced an expansion of Arduino Create to support Arm boards which will provide optimized support for the Raspberry Pi and BeagleBone boards.

Arduino Create now integrates Raspberry Pi, Beaglebone and other Linux based SBCs ─ all with IoT in mind. The introduction of ARM boards (Raspberry Pi, BeagleBone, AAEON® UP² board, and Custom ARM boards) follows the vision of the Arduino’s goal for the Create platform. A vision to build a full featured IoT development platform for developing IoT (Internet of Things) devices quicker, faster, and easier than ever before, intended for Makers, Engineers or Professional Developers. Arduino Creates brings the Arduino framework and libraries to all these SBCs, officially, changing the development game in a big way.

“With this release, Arduino extends its reach into edge computing, enabling anybody with Arduino programming experience to manage and develop complex multi-architecture IoT applications on gateways,” stated Massimo Banzi in a press release. “This is an important step forward in democratizing access to the professional Internet of Things.”

Raspberry Pi and other Linux based ARM boards can now leverage the community surrounding the Arduino Create Platform that offers support for step-by-step guides, examples, code, schematics and even projects. Although the SBC support is brand new, resources surrounding SBCs is sure to grow, in short time. Import from or sharing with the community is easy too.

Multiple Arduino programs can run simultaneously on a Linux-based board and interact and communicate with each other, leveraging the capabilities provided by the new Arduino Connector. Moreover, IoT devices can be managed and updated remotely, independently from where they are located.

Getting started with Arduino Create for the Linux SBCs is quite easy and straightforward. One merely connect the Raspberry Pi, or whatever SBC of choice to a computer and connect it to the cloud via Arduino Connect or via USB using the Arduino Plugin (This will make possible the communication between the USB ports on your PC and your Arm®-based Platform.). To start developing, upload sketches (programs) from the browser to the SBC. No need to install anything to get the code to compile, everything is up-to-date. This may become a standard way to develop on these platforms.

Arduino Create currently works with any board that runs Debian OS; a case for the Raspberry Rasbian, which is a Debian OS. To get started building with the Arduino Create for your ARM-based boards, visit the Arduino Create site, and click on the Getting Started while setting the board of your choice.

How to make precision measurements on a nanopower budget

Gen Vansteeg @ ti.com discuss about precision measurement for nanopower scale using OPAMPs.

Heightened accuracy and speed in an operational amplifier (op amp) has a direct relationship with the magnitude of its power consumption. Decreasing the current consumption decreases the gain bandwidth; conversely, decreasing the offset voltage increases the current consumption.

Many such interactions between op amp electrical characteristics influence one another. With the increasing need for low power consumption in applications like wireless sensing nodes, the Internet of Things (IoT) and building automation, understanding these trade-offs has become vital to ensure optimal end-equipment performance with the lowest possible power consumption. In the first installment of this two-part blog post series, I’ll describe some of the power-to-performance trade-offs of DC gain in precision nanopower op amps.

How to make precision measurements on a nanopower budget – [Link]

HDC2010 – Low Power Humidity and Temperature Sensor

The HDC2010 is an integrated humidity and temperature sensor that provides high accuracy measurements with very low power consumption, in an ultra-compact WLCSP (Wafer Level Chip Scale Package). The sensing element of the HDC2010 is placed on the bottom part of the device, which makes the HDC2010 more robust against dirt, dust, and other environmental contaminants. The capacitive-based sensor includes new integrated digital features and a heating element to dissipate condensation and moisture. The HDC2010 digital features include programmable interrupt thresholds to provide alerts/system wakeups without requiring a microcontroller to be continuously monitoring the system. This, combined with programmable sampling intervals, low inherent power consumption, and support for 1.8V supply voltage, make the HDC2010 well suited for battery-operated systems.

[via]

USB Adaptive Charger (2.7A per port) with Wattmeter

A 10.8A, 4 port USB charger with a wattmeter and adaptive intelligent charging.

It works by taking any DC input between 7V to 17V, from an AC/DC adapter or car adapter. It can be used anywhere with wall outlets, car power ports, lead-acid batteries, DC-output solar panels, and lithium-ion battery packs (2S, 3S, and 4S).

It then drops the voltage down to 5V and intelligently adapts to match the maximum current the device being charged would accept. We believe it is the most powerful 4-port USB charger at 10.8A. No device is throttled when every port is in use.

USB Adaptive Charger (2.7A per port) with Wattmeter – [Link]

TPS61092 Boost Converter on Test Bench

luckyresistor.me tests his TPS61092 boost converter with a thermal camera and shares the results.

For my current project I searched for a good boost power converter which is able to deliver continuous 400mA power for various sensors.

There are an endless number of good boost converters around, but not many can be hand soldered to a board. I would really like to see some like the TPS61092 with SOIC or similar packages. The biggest problem seems to be the heat transport, why most chips have to be mounted flat on the board.

TPS61092 Boost Converter on Test Bench – [Link]

TOP PCB Companies