Coder Social home page Coder Social logo

arduino-sensor-kit's Introduction

Arduino SensorKit Library for RTduino

This documentation contains information about the classes and the usage of Arduino_SensorKit library which is primarily used in the Arduino Sensor Kit. This library is a wrapper for other libraries such as

This library has contained above libraries.

Classes

Including the library

  #include "Arduino_SensorKit.h"

  void setup(){}
  void loop(){}

OLED

Using the Grove - OLED Display 0.96 inch

Initializing the driver

Init the display driver

  void setup(){
    Oled.begin();
  }
  void loop(){}

Printing "hello world"

#include "Arduino_SensorKit.h"

void setup() {
  Oled.begin();
  Oled.setFlipMode(1);  //Rotate it
}

void loop() {
  Oled.setFont(u8x8_font_chroma48medium8_r);
  Oled.drawString(0,0,"Hello World!");
  Oled.refreshDisplay();
  delay(1000);
}

Printing values

  Oled.print(value);

Accelerometer

Using the Grove - 3-Axis Digital Accelerometer (±1.5g)

Initializing the sensor

Initialize the sensor

  void setup(){
    Accelerometer.begin();
  }
  void loop(){}

Reading the Acceleration X

  #include "Arduino_SensorKit.h"
  
  float acceleration;

  void setup(){
    Accelerometer.begin();
  }

  void loop(){
    Serial.begin(9600);
    acceleration = Accelerometer.readX();
    Serial.println(acceleration);
}

Reading the coordinate values

  #include "Arduino_SensorKit.h"

  float x,y,z;        // Values for the readings

  setup(){
    Serial.begin(9600);
    Accelerometer.begin();
  }

  loop{
    x = Accelerometer.readX();
    y = Accelerometer.readY();
    z = Accelerometer.readZ();

    Serial.print("X axis: "); Serial.println(x);
    Serial.print("Y axis: "); Serial.println(y);
    Serial.print("Z axis: "); Serial.println(z);
  }

Check if the sensor has reads available

Return if the sensor its good to give the data

  #include "Arduino_SensorKit.h"

  float x,y,z;        // Values for the readings

  setup(){
    Serial.begin(9600);
    Accelerometer.begin();
  }

  loop{
    if(Accelerometer.available()){
      x = Accelerometer.readX();
      Serial.print("X axis: "); Serial.println(x);
    }
  }

Pressure

Using the Grove Barometer Sensor (BMP280) The Pressure sensor can get temperature, pressure and altitude

Initializing the sensor

Initialize the sensor

   void setup(){
    Pressure.begin();
  }
  void loop(){}

Reading the Temperature values

  #include "Arduino_SensorKit.h"

  float temperature;        // Value for the reading

  setup(){
    Serial.begin(9600);
    Pressure.begin();
  }

  loop{
    temperature = Pressure.readTemperature();
    Serial.print("temperature :"); Serial.println(temperature);
    }
  }

Reading the Pressure values

  #include "Arduino_SensorKit.h"

  uint32_t pressure;        // Value for the reading

  setup(){
    Serial.begin(9600);
    Pressure.begin();
  }

  loop{
    pressure = Pressure.readPressure();
    Serial.print("pressure :"); Serial.println(pressure);
    }
  }

Reading the Altitude values

  #include "Arduino_SensorKit.h"

  float altitude;        // Value for the reading

  setup(){
    Serial.begin(9600);
    Presure.begin();
  }

  loop{
    altitude = Pressure.readAltitude();
    Serial.print("altitude :"); Serial.println(altitude);
    }
  }

Environment

Using the Grove - Temperature & Humidity Sensor (DHT11) DHT sensor can read Temperature and Humidity.

DHTPIN

By default, once you include the library it has been set to digital pin 3, it can be changed by adding

#define DHTPIN yourPin

Initializing the sensor

  void setup(){
    Environment.begin();
  }
  void loop(){}

Reading the Temperature values

  #include "Arduino_SensorKit.h"
  
  float temperature;
  
  void setup() {
    Serial.begin(9600);
    Environment.begin();
  }

  void loop() {
    temperature = Environment.readTemperature();
    
    Serial.print("Temperature: ");
    Serial.print(temperature);  //print temperature
  }

Reading the Humidity values

  #include "Arduino_SensorKit.h"

  float humidity;

  void setup() {
    Serial.begin(9600);
    Environment.begin();
  }

  void loop() {
    humidity = Environment.readHumidity();
    Serial.print("Humidity: ");
    Serial.print(humidity);  //print humidity
  }

arduino-sensor-kit's People

Contributors

mysterywolf avatar

Watchers

 avatar

arduino-sensor-kit's Issues

问题

用Keil -O2编译没有问题 -O0编译会报ROM空间不够
Studio -O2 -O0都会出问题,问题在u8g2身上,可能是ROM不够导致的

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.