Coder Social home page Coder Social logo

ulp-bme280's Introduction

ULP I2C BME280 component

Implementation of ESP-32 ULP I2C component which reads a sensor (BME-280) over I2C and wakes up the main processor after a significant change of the measured values. It measures Temperature, Pressure and Humidity.

Using

To use this include its directory as a component in your application. Change CMakeLists.txt to require the component e.g.:

idf_component_register(
    SRCS "main.c"
    INCLUDE_DIRS ""
    REQUIRES ulp_bme280
)

Include ulp.hpp and use its functions. Example:

#include "esp_sleep.h"
#include "ulp.hpp"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"

extern "C" {
   void app_main(void);   
}

void app_main(void)
{
   esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
   if (cause != ESP_SLEEP_WAKEUP_ULP) {
      
      printf("First start - initializing ULP\n");
      setup();
   } else {
      float temperature = 0.0, pressure = 0.0, humidity = 0.0;
      unsigned int temp_count = 0;
      get_temp_pressure(temperature,pressure,humidity,temp_count);
  
      printf("Temp count: %u\n", temp_count);
      printf("Temp: %.2f C\n", temperature);
      printf("Pres: %.2f hPa\n", pressure);
      printf("Hum: %.2f %%RH\n", humidity);
   }
   
   start_ulp();
   printf("Entering deep sleep\n\n");
   vTaskDelay(20);
   esp_deep_sleep_start();

}

You may want to change scl and sda pin in ulp.cpp.

Details

The Ultra Low Power co-processor is programmed to read the BME280 sensor every 20 seconds. It checks if temperature has changed by more than ~0.25 deg C or pressure has changed by more than ~0.39 hPa. If so, it wakes up the main processor.

I2C bit banged support

Note that this example uses a bit-banged I2C implementation, because the hardware ULP I2C support cannot read 16 bit values.

Credits

Modified from https://github.com/tomtor/ulp-i2c and https://github.com/xlfe/ulp-i2c

ulp-bme280's People

Contributors

dominicd avatar tomtor avatar xlfe avatar

Watchers

 avatar

ulp-bme280's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.