Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

Can't get BME280 example app to work

jameselseyjameselsey Melbourne, Australia

Trying to play with a BME280 and ESP32

I've cloned https://github.com/mongoose-os-apps/example-arduino-adafruit-bme280-c

Set pins in my mos.yml:

config_schema:
  - ["debug.level", 3]
  - ["i2c.enable", true]
  - ["i2c.debug", true]
  - ["i2c.sda_gpio", 4]
  - ["i2c.scl_gpio", 5]

The deployed using mos build --platform esp32 && mos flash && mos console

And see this:

[Feb  2 23:04:40.598] mgos_init2           example-arduino-adafruit-bme280-c 1.0 (20180202-120226/???)
[Feb  2 23:04:40.598] mgos_init2           Mongoose OS 2018020212 (20180202-120226/???)
[Feb  2 23:04:40.598] mgos_init2           CPU: 160 MHz, RAM: 318084 total, 279700 free
[Feb  2 23:04:40.598] mgos_hal_freertos_pr ESP-IDF v3.0-rc1-r1
[Feb  2 23:04:40.604] mgos_hal_freertos_pr Boot partition: app_0; flash: 4M
[Feb  2 23:04:40.615] mgos_vfs_dev_open    esp32part ({"label": "fs_0", "subtype": 130}) -> 0x3ffbb4ec
[Feb  2 23:04:40.624] mgos_vfs_mount       Mount SPIFFS @ / (dev 0x3ffbb4ec, opts {"encr": false}) -> 0x3ffbb430
[Feb  2 23:04:40.728] mgos_vfs_mount       /: size 233681, used: 19578, free: 214103
[Feb  2 23:04:40.806] mgos_sys_config_init MAC: 30AEA438CDD4
[Feb  2 23:04:40.811] mgos_sys_config_init WDT: 30 seconds
[Feb  2 23:04:40.817] mgos_deps_init       init arduino_compat...
[Feb  2 23:04:40.824] Arduino Adafruit_BME280 library simple example
[Feb  2 23:04:40.915] Guru Meditation Error: Core  0 panic'ed (LoadProhibited)
[Feb  2 23:04:40.915] . Exception was unhandled.
[Feb  2 23:04:40.915] Register dump:
[Feb  2 23:04:40.915] PC      : 0x40125f11  PS      : 0x00060830  A0      : 0x800fbedd  A1      : 0x3ffbaa60
[Feb  2 23:04:40.915] A2      : 0x00000001  A3      : 0x00000076  A4      : 0x00000001  A5      : 0x3ffae8d8
[Feb  2 23:04:40.915] A6      : 0x00000000  A7      : 0x00000000  A8      : 0x3ffb2aec  A9      : 0x00000000
[Feb  2 23:04:40.916] A10     : 0x3ffb2af3  A11     : 0x00000076  A12     : 0x00000001  A13     : 0x00000001
[Feb  2 23:04:40.916] A14     : 0x00000001  A15     : 0x00000000  SAR     : 0x00000009  EXCCAUSE: 0x0000001c
[Feb  2 23:04:40.916] EXCVADDR: 0x00000000  LBEG    : 0x40083825  LEND    : 0x4008382f  LCOUNT  : 0x00000000
[Feb  2 23:04:40.916]
[Feb  2 23:04:40.916] Backtrace: 0x40125f11 0x400fbeda 0x400fc246 0x400fa8d0 0x400fa9cb 0x400fa978 0x400efbe5 0x400efa13 0x40082ce0
[Feb  2 23:04:40.916] --- BEGIN CORE DUMP ---
[Feb  2 23:04:40.916] {"arch": "ESP32", "cause":28,
[Feb  2 23:04:40.916] "REGS": {"addr": 1073425412, "data": "
[Feb  2 23:04:40.916] EV8SQN2+D4Bgqvs/AQAAAHYAAAABAAAA2Oj6PwAAAAAAAAAA7Cr7PwAAAADzKvs/dgAAAAEAAAABAAAAAQAAAAAAAADvvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd7vvq3e776t3u++rd4lOAhALzgIQAAAAAAJAAAAAAAAAAEAAADvvq3e776t3iAIBgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"},
[Feb  2 23:04:41.005] "DRAM": {"addr": 1073405952, "data": "
[Feb  2 23:04:41.005] 0heIIVdqBwjX7QesAxEm6QAAAACYNAhAAAAAAAAAAACECPs/hAj7PwAAAAAAAAAAqcT5P6nE+T8BAAAAAAAAAEoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABKAAAA
[Feb  2 23:04:41.005] AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACYu/s/7Lv7PwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIy5+z/kJPs/hLv7PzC7+z8AAAAA
[Feb  2 23:04:41.005] xOD6P2wvAECILwBApC8AQMwvAEAAMABALDAAQEQwAEA8PgBAYDAAQLgwAED4MABALDEAQKQxAECMNABAHDUAQGQ1AECUNQBA0DUAQLQ2AECYPwBAHEAAQBA3AEA0NwBA

Then it just continues to print junk. Is there anything else I need to do? Readme just says flash it and go.

I notice theres an issue already raised for this by someone else on the github page:
https://github.com/mongoose-os-apps/example-arduino-adafruit-bme280-c/issues/1

Any ideas?

Thanks

Comments

  • nliviunliviu Romania

    This is related to https://forum.mongoose-os.com/discussion/1948/arduino-compat-starts-before-dependencies-are-initialized

    Modify your main.cpp to make it a Mongoose OS application:

    #include <mgos.h>
    #include <Adafruit_BME280.h>
    
    #define SENSOR_ADDR 0x76
    
    static Adafruit_BME280 *s_bme = nullptr;
    
    //void setup(void)
    //{
    //    printf("Arduino Adafruit_BME280 library simple example\n");
    
    // Initialize Adafruit_BME280 library
    //    s_bme = new Adafruit_BME280();
    
    // Initialize sensor
    //    if (!s_bme->begin(SENSOR_ADDR)) {
    //        printf("Can't find a sensor\n");
    //        while (true) delay(1000);
    //    }
    //}
    
    /*
    void loop(void)
    {
        delay(2000);
        printf("Temperature: %.2f *C\n", s_bme->readTemperature());
        printf("Humidity: %.2f %%RH\n", s_bme->readHumidity());
        printf("Pressure: %.2f kPa\n\n", s_bme->readPressure() / 1000.0);
    }
     */
    
    void readTimerCB(void *arg)
    {
        (void) arg;
        printf("Temperature: %.2f *C\n", s_bme->readTemperature());
        printf("Humidity: %.2f %%RH\n", s_bme->readHumidity());
        printf("Pressure: %.2f kPa\n\n", s_bme->readPressure() / 1000.0);
    }
    
    enum mgos_app_init_result mgos_app_init(void)
    {
        // Initialize Adafruit_BME280 library
        s_bme = new Adafruit_BME280();
    
        // Initialize sensor
        if (!s_bme->begin(SENSOR_ADDR)) {
            printf("Can't find a sensor\n");
            return MGOS_APP_INIT_ERROR;
        }
    
        mgos_set_timer(2000, 1, readTimerCB, NULL);
    
        return MGOS_APP_INIT_SUCCESS;
    }
    
Sign In or Register to comment.