Code Monkey home page Code Monkey logo

m5stack-ruuvitag's Introduction

M5Stack Core2 and RuuviTag

This is a sketch for the M5Core2 microcontroller that reads the temperature, humidity, pressure, and battery voltage from a RuuviTag Bluetooth Low Energy device and displays them on the M5Core2's screen. The sketch uses the Arduino FreeRTOS library to create and manage multiple tasks.

The sketch begins by including necessary libraries and initializing some variables. It includes several custom fonts that are used to display text on the screen. It also defines a struct for storing data from the RuuviTag, and another struct for storing power consumption and battery information from the M5Core2.

The sketch then creates a BLEScan object for scanning for RuuviTags. It defines a callback function that is called when a RuuviTag is found. The callback function decodes the RuuviTag's raw data and stores the temperature, humidity, pressure, and battery voltage in the struct defined earlier.

The sketch defines five tasks:

  • task1 is responsible for handling touchscreen input and waking up the screen when necessary.
  • task2 is responsible for scanning for RuuviTags. It starts a scan every 180 seconds and calls the callback function defined earlier when a RuuviTag is found.
  • task3 is responsible for drawing a graph of temperature data and displaying the current temperature, humidity, pressure, and power consumption on the screen. It uses the data stored in the struct defined earlier and saves the temperature data in an array for graphing.
  • task4 is responsible for monitoring the battery voltage and adjusting the screen voltage accordingly. If the battery voltage falls below a certain threshold, the screen voltage is lowered to conserve power. If the battery voltage falls below another threshold, the screen is put to sleep to conserve even more power.
  • task5 is responsible for monitoring power consumption and battery capacity. It updates the struct defined earlier with this information.

Finally, the setup() function initializes the M5Core2 and sets up the BLE scan. It then creates the five tasks defined earlier and sets them to run on different cores of the microcontroller. It also displays an image on the screen for 5 seconds before clearing the screen to start displaying the temperature data.

Useful links:

Product Image

m5stack-ruuvitag's People

Contributors

jrajaniemi avatar

Watchers

 avatar

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.