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.
#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 NoneCreates 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
| Type | Name | Description |
|---|---|---|
uint8_t | mode | INKPLATE_1BIT or INKPLATE_3BIT. |
display.begin()returns voidInitializes the library and the display. Call it once, at the start of `setup()`.
ReturnsNothing.
display.clearDisplay()returns voidClears the frame buffer in memory. It does not change what the panel shows until you call `display()`.
ReturnsNothing.
display.display(bool _leaveOn = 0)returns voidDoes 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
| Type | Name | Description |
|---|---|---|
bool | _leaveOn | Keeps the panel supply on after the update when true. Defaults to 0. |
display.setTextSize(uint8_t s)returns voidScales text by an integer factor. The base font is 5 x 7 pixels.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
uint8_t | s | Scale factor. |
display.setTextColor(uint16_t c, uint16_t bg)returns voidSets the text color and the background color behind the text.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
uint16_t | c | Text color, for example BLACK. |
uint16_t | bg | Background color, for example WHITE. |
display.readTemperature()returns int8_tReads 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 boolDraws a one-bit-per-pixel bitmap array from memory.
Returns`true` if the bitmap drew.
Parameters
| Type | Name | Description |
|---|---|---|
const uint8_t * | buf | The bitmap array. |
int | x | Left position in pixels. |
int | y | Top position in pixels. |
int16_t | w | Bitmap width in pixels. |
int16_t | h | Bitmap height in pixels. |
uint8_t | c | Color of the set pixels, for example BLACK. Defaults to 1. |
uint8_t | bg | Background value. Defaults to 0xFF. |
display.setCursor(int16_t x, int16_t y)returns voidSets where the next `print()` starts, in pixels from the top left corner.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
int16_t | x | Horizontal position in pixels. |
int16_t | y | Vertical position in pixels. |
display.print(value)returns size_tPrints 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
| Type | Name | Description |
|---|---|---|
text, number or char | value | What to print. |
int | second argument (optional) | Decimal places for a float, or the base for an integer, for example DEC. |
delay(unsigned long ms)returns voidArduino function that pauses the sketch.
ReturnsNothing.
Parameters
| Type | Name | Description |
|---|---|---|
unsigned long | ms | Time 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.