Skip to main content

Read the on-board temperature

What this example shows​

Reading the temperature from the basic sensor inside the TPS65186 e-paper power chip and showing it on the display every 10 seconds. The example header says this sensor is meant for system monitoring and waveform compensation, so it is not a precise thermometer and does not replace an external temperature sensor.

Example code​

Trimmed from the pinned example: only the file header comment is removed. The sketch includes tempSymbol.h, the thermometer picture, from the same example folder, so open the source link below and keep both files together.

Select Board
Inkplate10_Read_Temperature.ino
#if !defined(ARDUINO_INKPLATE10) && !defined(ARDUINO_INKPLATE10V2)
#error \
"Wrong board selection for this example, please select e-radionica Inkplate10 or Soldered Inkplate10 in the boards menu."
#endif

#include "Inkplate.h" //Include Inkplate library to the sketch
#include "tempSymbol.h" //Include .h file that contains byte array for temperature symbol.
// It is in same folder as this sketch. You can even open it (read it) by clicking on tempSymbol.h tab in Arduino IDE
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1-bit mode (BW)

void setup()
{
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
display.clearDisplay(); // Clear frame buffer of display
display.display(); // Put clear image on display
display.setTextSize(2); // Scale text to be two times bigger then original (5x7 px)
display.setTextColor(BLACK, WHITE); // Set text color to black and background color to white
}

void loop()
{
int temperature = display.readTemperature(); // Read temperature from on-board temperature sensor
display.clearDisplay(); // Clear frame buffer of display
display.image.draw(tempSymbol, 100, 100, 38, 79, BLACK); // Draw temperature symbol at position X=100, Y=100
display.setCursor(150, 125);
display.print(temperature, DEC); // Print temperature
display.print('C');
display.display(); // Send everything to display (refresh the screen)
delay(10000); // Wait 10 seconds before new measurement
}

Functions used​

Inkplate(uint8_t mode)returns None

Creates the display object. `INKPLATE_1BIT` is black and white and supports partial updates. `INKPLATE_3BIT` gives 8 levels of grey but only full updates.

ReturnsConstructor; no return value.

Parameters

TypeNameDescription
uint8_tmodeINKPLATE_1BIT or INKPLATE_3BIT.
display.begin()returns void

Initializes the library and the display. Call it once, at the start of `setup()`.

ReturnsNothing.

display.clearDisplay()returns void

Clears the frame buffer in memory. It does not change what the panel shows until you call `display()`.

ReturnsNothing.

display.display(bool _leaveOn = 0)returns void

Does a full refresh: sends the frame buffer to the panel. If `_leaveOn` is true, the panel supply stays on after the refresh, which saves time on the next update.

ReturnsNothing.

Parameters

TypeNameDescription
bool_leaveOnKeeps the panel supply on after the update when true. Defaults to 0.
display.setTextSize(uint8_t s)returns void

Scales text by an integer factor. The base font is 5 x 7 pixels.

ReturnsNothing.

Parameters

TypeNameDescription
uint8_tsScale factor.
display.setTextColor(uint16_t c, uint16_t bg)returns void

Sets the text color and the background color behind the text.

ReturnsNothing.

Parameters

TypeNameDescription
uint16_tcText color, for example BLACK.
uint16_tbgBackground color, for example WHITE.
display.readTemperature()returns int8_t

Reads the temperature from the sensor inside the TPS65186 e-paper power chip.

ReturnsTemperature in degrees Celsius. The library documents a range of -10 to 85 with an accuracy of ±1 from 0 to 50.

display.image.draw(const uint8_t *buf, int x, int y, int16_t w, int16_t h, uint8_t c = 1, uint8_t bg = 0xFF)returns bool

Draws a one-bit-per-pixel bitmap array from memory.

Returns`true` if the bitmap drew.

Parameters

TypeNameDescription
const uint8_t *bufThe bitmap array.
intxLeft position in pixels.
intyTop position in pixels.
int16_twBitmap width in pixels.
int16_thBitmap height in pixels.
uint8_tcColor of the set pixels, for example BLACK. Defaults to 1.
uint8_tbgBackground value. Defaults to 0xFF.
display.setCursor(int16_t x, int16_t y)returns void

Sets where the next `print()` starts, in pixels from the top left corner.

ReturnsNothing.

Parameters

TypeNameDescription
int16_txHorizontal position in pixels.
int16_tyVertical position in pixels.
display.print(value)returns size_t

Prints text or a number at the cursor. The `print` functions come from the Arduino `Print` class that `Adafruit_GFX` builds on. For a number, an optional second argument sets the decimal places of a float or the number base of an integer.

ReturnsNumber of bytes printed.

Parameters

TypeNameDescription
text, number or charvalueWhat to print.
intsecond argument (optional)Decimal places for a float, or the base for an integer, for example DEC.
delay(unsigned long ms)returns void

Arduino function that pauses the sketch.

ReturnsNothing.

Parameters

TypeNameDescription
unsigned longmsTime to wait in milliseconds.

What to expect​

The display shows a thermometer symbol with a whole-number temperature and a C next to it, refreshed every 10 seconds. The library documents a reading range of -10 to 85 degrees Celsius, with an accuracy of ±1 degree from 0 to 50.