XIAO BLE nRF52840 Initialization of LCD consumes 0,9mA

Hi,
I would like to make a small thermometer with LCD display (OPEN-SMART 1.8).
Without the display the board with code consumes ca 40uA but as soon I initialize the display the consumption of the board itself raises to ca 900uA (without display consumption).

I tried to disable the SPI com with code provided from GitHub Copilot but it makes no difference.
I use the U8g2 lib and HW SPI.

//setup
void setup() {
  display.init();
  pinMode(pin_backlight, OUTPUT);
  pinMode(rtc_interrupt, INPUT_PULLUP);
  pinMode(buttonPin, INPUT_PULLDOWN);
  pinMode(VBAT_ENABLE, OUTPUT);
  digitalWrite(VBAT_ENABLE, LOW);
  digitalWrite(pin_backlight, HIGH);
  

  sht4.begin();
  rtc.begin();
  //rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  if (rtc.lostPower()) {
    // Set the RTC to the date & time this sketch was compiled
    rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
  }
  attachInterrupt(digitalPinToInterrupt(buttonPin), toggleDisplay, RISING);
  
  // Configure RTC interrupt
  rtc.writeSqwPinMode(DS3231_OFF); // Disable square wave output
  rtc.disable32K();
  attachInterrupt(digitalPinToInterrupt(rtc_interrupt), rtcISR, FALLING);
  sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
  sd_power_mode_set(NRF_POWER_MODE_LOWPWR);
}


U8G2_ST7567_OS12864_F_4W_HW_SPI u8g2(U8G2_R2, ...); 
//after calling this consumption raises
void Display::init() {
  u8g2.begin();
  u8g2.setFont(u8g2_font_ncenB14_tr);
  u8g2.setContrast(0);
  u8g2.clear();
}

#define SPI_INSTANCE NRF_SPI0
#define SPI_SCK_PIN  D8
#define SPI_MOSI_PIN D10
#define SPI_MISO_PIN D9
#define SPI_SS_PIN   D1

void stopSPI() {
    // Disable the SPI instance
    nrf_spi_disable(SPI_INSTANCE);
    // Set the SPI pins to a safe state (e.g., input with no pull)
    nrf_gpio_cfg_input(SPI_SCK_PIN, NRF_GPIO_PIN_NOPULL);
    nrf_gpio_cfg_input(SPI_MOSI_PIN, NRF_GPIO_PIN_NOPULL);
    nrf_gpio_cfg_input(SPI_MISO_PIN, NRF_GPIO_PIN_NOPULL);
    nrf_gpio_cfg_input(SPI_SS_PIN, NRF_GPIO_PIN_NOPULL);
}

I would like to keep the display on (with last data) but to turn back the consumption of XIAO to 40uA :slight_smile:
Can someone give me an advice?
Thanks a lot

i think u8g2 has a command to turn off the display

Does the screen uses I²C? If so, check the pull-up resistors, especially if the thermometer uses the same bus and comes with its own resistors.

Hi there,

Are you using the BACK Light? That will munch through some power fast. Try the E-ink no power and the last Update stays on the screen until the next wake a update. I like that. Looks like it’s on always but no.

HTH
GL :slight_smile: PJ :v:

@cgwaltney
As I write below, I want to keep the display ON :wink:

@reivilo
Display has only 4-Wire SPI

@PJ_Glasso
I was also thinking about e-ink, but most of them are for use between 0-40°C and that is somehow limiting for a thermometer :slight_smile:
Another way would be a low power TFT, but those are hard to buy (in dimmensions that man want)

I found the solution if someone is ever interested :upside_down_face:
Xiao BLE uses SPIM3 as default on those pins and nrf52840 can have several issues disabeling the SPI instance.
At the end with usage of the code below I can use the display and turn on the SPI only at update, which saves me >545uA.

The code is a composition from various threads from internet and it can to disable the SPIM3 instance

void stopSPI3();
int i = 0;

void setup() {
  u8g2.begin(); // consumption of xiao ca 550uA
  u8g2.setContrast(0);
  u8g2.setFont(u8g2_font_ncenB14_tr);
}

void loop() {
  u8g2.initInterface(); //reinitialization of the Display, without losing the data on the screen, consumption of xiao ca 550uA
  u8g2.setCursor(0, 20);
  u8g2.print(i);
  u8g2.sendBuffer();
  delay(3000); 
  stopSPI3(); // consumption of xiao drops to 3uA
  delay(3000);
  i++;
}

void stopSPI3() {
    //SPIM stop transaction
    *(volatile uint32_t *)0x4002F014 = 1;
    //SPIM enable
    *(volatile uint32_t *)0x4002F500 = 1;
    //SPIM disable
    *(volatile uint32_t *)0x4002F500 = 0;
    *(volatile uint32_t *)0x4002F004 = 1;
    //SPIM turn off and on after disable
    *(volatile uint32_t *)0x4002FFFC = 0;
    *(volatile uint32_t *)0x4002FFFC;
    *(volatile uint32_t *)0x4002FFFC = 1;
}

here are also variants of other SPIM instances if needed

void stopSPI0() {
    *(volatile uint32_t *)0x40003014 = 1;
    *(volatile uint32_t *)0x40003500 = 1;
    *(volatile uint32_t *)0x40003500 = 0;
    *(volatile uint32_t *)0x40003004 = 1;
    *(volatile uint32_t *)0x40003FFC = 0;
    *(volatile uint32_t *)0x40003FFC;
    *(volatile uint32_t *)0x40003FFC = 1;
}

void stopSPI1() {
    *(volatile uint32_t *)0x40004014 = 1;
    *(volatile uint32_t *)0x40004500 = 1;
    *(volatile uint32_t *)0x40004500 = 0;
    *(volatile uint32_t *)0x40004004 = 1;
    *(volatile uint32_t *)0x40004FFC = 0;
    *(volatile uint32_t *)0x40004FFC;
    *(volatile uint32_t *)0x40004FFC = 1;
}

void stopSPI2() {
    *(volatile uint32_t *)0x40023014 = 1;
    *(volatile uint32_t *)0x40023500 = 1;
    *(volatile uint32_t *)0x40023500 = 0;
    *(volatile uint32_t *)0x40023004 = 1;
    *(volatile uint32_t *)0x40023FFC = 0;
    *(volatile uint32_t *)0x40023FFC;
    *(volatile uint32_t *)0x40023FFC = 1;
}
1 Like

what is the purpose of keeping it on all the time… the epaper will take time to update and i am not an expert but low temp would probably be bad for it because it uses suspended ink in a fluid and all fluids will freeze at some temp

because it is a thermometer! so I want to know the temperature when I look at it :smiley:
Yes, the e-ink is specified for 0-40°C as standard so actually more or less for indoor usage

that is why you write the code to know when you are there and wake up and then go back to sleep if you want to save battery

Hi there,
So E-ink remote display, send the updates over BLE , whenever you pick up the e-ink unit stays on
for a while, retime thermometer NO, not a good use case if the value is unstable. otherwise you could say if the delta is greater than 1 degree then turn-on display or update e-ink. Displays when on chew through power so.
GL :slight_smile: PJ
:v:

1 Like

There are e-paper displays operating at -15°C to +60°C.

See for example the Pervasive Disolays 2.06″ supported by the Arduino library Pervasive Displays Library Suite. The EPD Pico Kit (EPDK-266) Is a self-contained kit.

it never gets below 0C or above 100 C where i live