Dtynin
Dtynin
Why Isn't My OLED Screen Updating with Pressure Readings on AVR128DA48?
Hey guys, I'm trying to display real-time pressure readings on an OLED screen using I2C in my AVR128DA48-based pressure monitoring project. However, the OLED screen does not update as expected. the I2C wiring and connection to the OLED screen are quite cool, and I also ensured that the pressure readings were valid and correctly formatted. Yet, I'm still encountering the OLED screen failing to display any pressure readings. What might be causing this issue, and how can I ensure that the OLED screen updates correctly with real-time pressure values? this is my code instructions:
#include <zephyr.h>
#include <device.h>
#include <drivers/i2c.h>
#include <drivers/sensor.h>
#include <display/cfb.h>

#define OLED_I2C_DEV "I2C_0"

void main(void)
{
const struct device *oled_dev = device_get_binding(OLED_I2C_DEV);
struct sensor_value pressure;

if (oled_dev == NULL) {
printk("Failed to bind to OLED I2C device\n");
return;
}

const struct device *bmp280 = device_get_binding(DT_LABEL(DT_INST(0, bosch_bmp280)));

while (1) {
sensor_sample_fetch(bmp280);
sensor_channel_get(bmp280, SENSOR_CHAN_PRESS, &pressure);

char buffer[20];
snprintf(buffer, sizeof(buffer), "Pressure: %d kPa", pressure.val1);
cfb_print(oled_dev, buffer, 0, 0);

cfb_framebuffer_finalize(oled_dev);
k_sleep(K_SECONDS(2));
}
}
#include <zephyr.h>
#include <device.h>
#include <drivers/i2c.h>
#include <drivers/sensor.h>
#include <display/cfb.h>

#define OLED_I2C_DEV "I2C_0"

void main(void)
{
const struct device *oled_dev = device_get_binding(OLED_I2C_DEV);
struct sensor_value pressure;

if (oled_dev == NULL) {
printk("Failed to bind to OLED I2C device\n");
return;
}

const struct device *bmp280 = device_get_binding(DT_LABEL(DT_INST(0, bosch_bmp280)));

while (1) {
sensor_sample_fetch(bmp280);
sensor_channel_get(bmp280, SENSOR_CHAN_PRESS, &pressure);

char buffer[20];
snprintf(buffer, sizeof(buffer), "Pressure: %d kPa", pressure.val1);
cfb_print(oled_dev, buffer, 0, 0);

cfb_framebuffer_finalize(oled_dev);
k_sleep(K_SECONDS(2));
}
}
3 replies