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
Can someone give me an advice?
Thanks a lot
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.
@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
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
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
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
Yes, the e-ink is specified for 0-40°C as standard so actually more or less for indoor usage
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 PJ