commit
e17ae7ab4c
@ -0,0 +1,126 @@
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <MPU6050_tockn.h>
|
||||
|
||||
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||
|
||||
//#define TESTING // Define to test on Serial Monitor
|
||||
|
||||
Adafruit_BME280 bme;
|
||||
MPU6050 mpu6050(Wire);
|
||||
|
||||
int counter = 0;
|
||||
int RXLED = 17; // The RX LED has a defined Arduino pin
|
||||
long timer = 0;
|
||||
int bmePresent;
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600); // Serial Monitor for testing
|
||||
|
||||
Serial1.begin(9600); // Pi UART
|
||||
|
||||
Serial.println("Starting!");
|
||||
|
||||
digitalWrite(RXLED, LOW); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
delay(50); // wait for a second
|
||||
digitalWrite(RXLED, HIGH); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
|
||||
if (bme.begin(0x76)) {
|
||||
bmePresent = 1;
|
||||
} else {
|
||||
Serial.println("Could not find a valid BME280 sensor, check wiring!");
|
||||
bmePresent = 0;
|
||||
}
|
||||
|
||||
mpu6050.begin();
|
||||
mpu6050.calcGyroOffsets(true);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
#ifdef TESTING
|
||||
if (Serial.available() > 0) {
|
||||
digitalWrite(RXLED, LOW); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
delay(50); // wait for a second
|
||||
digitalWrite(RXLED, HIGH); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
char result = Serial.read();
|
||||
// Serial.println(result);
|
||||
|
||||
if (result == 'R') {
|
||||
Serial.println("OK");
|
||||
delay(500);
|
||||
setup();
|
||||
}
|
||||
if (bmePresent) {
|
||||
Serial.print("OK BME280 ");
|
||||
Serial.print(bme.readTemperature());
|
||||
Serial.print(" ");
|
||||
Serial.print(bme.readPressure() / 100.0F);
|
||||
Serial.print(" ");
|
||||
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
Serial.print(" ");
|
||||
Serial.print(bme.readHumidity());
|
||||
} else
|
||||
{
|
||||
Serial.print("OK BME280 0.0 0.0 0.0 0.0");
|
||||
}
|
||||
mpu6050.update();
|
||||
|
||||
Serial.print(" MPU6050 ");
|
||||
Serial.print(mpu6050.getGyroX());
|
||||
Serial.print(" ");
|
||||
Serial.print(mpu6050.getGyroY());
|
||||
Serial.print(" ");
|
||||
Serial.println(mpu6050.getGyroZ());
|
||||
|
||||
// Serial1.println(counter++);
|
||||
}
|
||||
#else
|
||||
if (Serial1.available() > 0) {
|
||||
digitalWrite(RXLED, LOW); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
delay(50); // wait for a second
|
||||
digitalWrite(RXLED, HIGH); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
char result = Serial1.read();
|
||||
// Serial1.println(result);
|
||||
|
||||
if (result == 'R') {
|
||||
Serial1.println("OK");
|
||||
delay(500);
|
||||
setup();
|
||||
}
|
||||
if (bmePresent) {
|
||||
Serial1.print("OK BME280 ");
|
||||
Serial1.print(bme.readTemperature());
|
||||
Serial1.print(" ");
|
||||
Serial1.print(bme.readPressure() / 100.0F);
|
||||
Serial1.print(" ");
|
||||
Serial1.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
Serial1.print(" ");
|
||||
Serial1.print(bme.readHumidity());
|
||||
} else
|
||||
{
|
||||
Serial1.print("OK BME280 0.0 0.0 0.0 0.0");
|
||||
}
|
||||
mpu6050.update();
|
||||
|
||||
Serial1.print(" MPU6050 ");
|
||||
Serial1.print(mpu6050.getGyroX());
|
||||
Serial1.print(" ");
|
||||
Serial1.print(mpu6050.getGyroY());
|
||||
Serial1.print(" ");
|
||||
Serial1.println(mpu6050.getGyroZ());
|
||||
|
||||
// Serial1.println(counter++);
|
||||
}
|
||||
#endif
|
||||
|
||||
delay(100);
|
||||
}
|
||||
@ -0,0 +1,120 @@
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <MPU6050_tockn.h>
|
||||
|
||||
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||
|
||||
//#define TESTING // Define to test on Serial Monitor
|
||||
|
||||
Adafruit_BME280 bme;
|
||||
MPU6050 mpu6050(Wire);
|
||||
|
||||
int counter = 0;
|
||||
long timer = 0;
|
||||
int bmePresent;
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600); // Serial Monitor for testing
|
||||
|
||||
Serial1.begin(9600); // Pi UART
|
||||
|
||||
Serial.println("Starting!");
|
||||
|
||||
pinMode(PC13, OUTPUT);
|
||||
digitalWrite(PC13, LOW); // turn the LED on
|
||||
delay(50); // wait for a second
|
||||
digitalWrite(PC13, HIGH); // turn the LED off
|
||||
|
||||
if (bme.begin(0x76)) {
|
||||
bmePresent = 1;
|
||||
} else {
|
||||
Serial.println("Could not find a valid BME280 sensor, check wiring!");
|
||||
bmePresent = 0;
|
||||
}
|
||||
|
||||
mpu6050.begin();
|
||||
mpu6050.calcGyroOffsets(true);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
#ifdef TESTING
|
||||
if (Serial.available() > 0) {
|
||||
digitalWrite(PC13, LOW); // turn the LED on
|
||||
delay(50); // wait for a second
|
||||
digitalWrite(PC13, HIGH); // turn the LED off
|
||||
char result = Serial.read();
|
||||
// Serial.println(result);
|
||||
|
||||
if (result == 'R') {
|
||||
Serial.println("OK");
|
||||
delay(500);
|
||||
setup();
|
||||
}
|
||||
if (bmePresent) {
|
||||
Serial.print("OK BME280 ");
|
||||
Serial.print(bme.readTemperature());
|
||||
Serial.print(" ");
|
||||
Serial.print(bme.readPressure() / 100.0F);
|
||||
Serial.print(" ");
|
||||
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
Serial.print(" ");
|
||||
Serial.print(bme.readHumidity());
|
||||
} else
|
||||
{
|
||||
Serial.print("OK BME280 0.0 0.0 0.0 0.0");
|
||||
}
|
||||
mpu6050.update();
|
||||
|
||||
Serial.print(" MPU6050 ");
|
||||
Serial.print(mpu6050.getGyroX());
|
||||
Serial.print(" ");
|
||||
Serial.print(mpu6050.getGyroY());
|
||||
Serial.print(" ");
|
||||
Serial.println(mpu6050.getGyroZ());
|
||||
|
||||
// Serial1.println(counter++);
|
||||
}
|
||||
#else
|
||||
if (Serial1.available() > 0) {
|
||||
digitalWrite(PC13, LOW); // turn the LED on
|
||||
delay(50); // wait for a second
|
||||
digitalWrite(PC13, HIGH); // turn the LED off
|
||||
char result = Serial1.read();
|
||||
// Serial1.println(result);
|
||||
|
||||
if (result == 'R') {
|
||||
Serial1.println("OK");
|
||||
delay(500);
|
||||
setup();
|
||||
}
|
||||
if (bmePresent) {
|
||||
Serial1.print("OK BME280 ");
|
||||
Serial1.print(bme.readTemperature());
|
||||
Serial1.print(" ");
|
||||
Serial1.print(bme.readPressure() / 100.0F);
|
||||
Serial1.print(" ");
|
||||
Serial1.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
Serial1.print(" ");
|
||||
Serial1.print(bme.readHumidity());
|
||||
} else
|
||||
{
|
||||
Serial1.print("OK BME280 0.0 0.0 0.0 0.0");
|
||||
}
|
||||
mpu6050.update();
|
||||
|
||||
Serial1.print(" MPU6050 ");
|
||||
Serial1.print(mpu6050.getGyroX());
|
||||
Serial1.print(" ");
|
||||
Serial1.print(mpu6050.getGyroY());
|
||||
Serial1.print(" ");
|
||||
Serial1.println(mpu6050.getGyroZ());
|
||||
|
||||
// Serial1.println(counter++);
|
||||
}
|
||||
#endif
|
||||
|
||||
delay(100);
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||
|
||||
//#define TESTING // Define to test on Serial Monitor
|
||||
|
||||
Adafruit_BME280 bme;
|
||||
int counter = 0;
|
||||
int RXLED = 17; // The RX LED has a defined Arduino pin
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600); // Serial Monitor for testing
|
||||
|
||||
Serial1.begin(9600); // Pi UART
|
||||
|
||||
Serial.println("Starting!");
|
||||
|
||||
|
||||
digitalWrite(RXLED, LOW); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
delay(50); // wait for a second
|
||||
digitalWrite(RXLED, HIGH); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
|
||||
if (!bme.begin(0x76)) {
|
||||
Serial.println("Could not find a valid BME280 sensor, check wiring!");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
#ifdef TESTING
|
||||
if (Serial.available() > 0) {
|
||||
digitalWrite(RXLED, LOW); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
delay(50); // wait for a second
|
||||
digitalWrite(RXLED, HIGH); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
char result = Serial.read();
|
||||
// Serial1.println(result);
|
||||
Serial.print("OK BME280 ");
|
||||
Serial.print(bme.readTemperature());
|
||||
Serial.print(" ");
|
||||
Serial.print(bme.readPressure() / 100.0F);
|
||||
Serial.print(" ");
|
||||
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
Serial.print(" ");
|
||||
Serial.println(bme.readHumidity());
|
||||
|
||||
// Serial1.println(counter++);
|
||||
}
|
||||
#else
|
||||
if (Serial1.available() > 0) {
|
||||
digitalWrite(RXLED, LOW); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
delay(50); // wait for a second
|
||||
digitalWrite(RXLED, HIGH); // set the RX LED ON
|
||||
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
|
||||
char result = Serial1.read();
|
||||
// Serial1.println(result);
|
||||
// Serial1.println("OK ");
|
||||
/**/
|
||||
Serial1.print("OK BME280 ");
|
||||
Serial1.print(bme.readTemperature());
|
||||
Serial1.print(" ");
|
||||
Serial1.print(bme.readPressure() / 100.0F);
|
||||
Serial1.print(" ");
|
||||
Serial1.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
Serial1.print(" ");
|
||||
Serial1.println(bme.readHumidity());
|
||||
/**/
|
||||
// Serial1.println(counter++);
|
||||
}
|
||||
#endif
|
||||
|
||||
delay(100);
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
/*
|
||||
Blink
|
||||
Turns on an LED on for one second, then off for one second, repeatedly.
|
||||
Most Arduinos have an on-board LED you can control. On the Uno and
|
||||
Leonardo, it is attached to digital pin 13. If you're unsure what
|
||||
pin the on-board LED is connected to on your Arduino model, check
|
||||
the documentation at http://arduino.cc
|
||||
This example code is in the public domain.
|
||||
modified 8 May 2014
|
||||
by Scott Fitzgerald
|
||||
|
||||
Modified by Roger Clark. www.rogerclark.net for Maple mini 25th April 2015 , where the LED is on PC13
|
||||
|
||||
Added CubeSatSim Payload tests by Alan Johnston, KU2Y
|
||||
|
||||
*/
|
||||
|
||||
int sensorValue = 0;
|
||||
int D9 = 9;
|
||||
int D8 = 8;
|
||||
|
||||
// the setup function runs once when you press reset or power the board
|
||||
void setup() {
|
||||
// initialize digital pin PB1 as an output.
|
||||
pinMode(D9, OUTPUT);
|
||||
pinMode(D8, OUTPUT);
|
||||
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
// the loop function runs over and over again forever
|
||||
void loop() {
|
||||
digitalWrite(D9, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
digitalWrite(D8, LOW); // turn the LED on (HIGH is the voltage level)
|
||||
delay(1000); // wait for a second
|
||||
digitalWrite(D9, LOW); // turn the LED off by making the voltage LOW
|
||||
digitalWrite(D8, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
delay(1000); // wait for a second
|
||||
|
||||
sensorValue = analogRead(A0);
|
||||
Serial.println(sensorValue);
|
||||
sensorValue = analogRead(A1);
|
||||
Serial.println(sensorValue);
|
||||
sensorValue = analogRead(A2);
|
||||
Serial.println(sensorValue);
|
||||
}
|
||||
@ -0,0 +1,50 @@
|
||||
/*
|
||||
Blink
|
||||
Turns on an LED on for one second, then off for one second, repeatedly.
|
||||
|
||||
Most Arduinos have an on-board LED you can control. On the Uno and
|
||||
Leonardo, it is attached to digital pin 13. If you're unsure what
|
||||
pin the on-board LED is connected to on your Arduino model, check
|
||||
the documentation at http://arduino.cc
|
||||
|
||||
This example code is in the public domain.
|
||||
|
||||
modified 8 May 2014
|
||||
by Scott Fitzgerald
|
||||
|
||||
Modified by Roger Clark. www.rogerclark.net for Maple mini 25th April 2015 , where the LED is on PC13
|
||||
|
||||
Added CubeSatSim Payload tests by Alan Johnston, KU2Y
|
||||
|
||||
*/
|
||||
|
||||
int sensorValue = 0;
|
||||
|
||||
// the setup function runs once when you press reset or power the board
|
||||
void setup() {
|
||||
// initialize digital pin PB1 as an output.
|
||||
pinMode(PB9, OUTPUT);
|
||||
pinMode(PB8, OUTPUT);
|
||||
pinMode(PA0, INPUT_ANALOG);
|
||||
pinMode(PA1, INPUT_ANALOG);
|
||||
pinMode(PA2, INPUT_ANALOG);
|
||||
|
||||
Serial.begin(9600);
|
||||
}
|
||||
|
||||
// the loop function runs over and over again forever
|
||||
void loop() {
|
||||
digitalWrite(PB9, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
digitalWrite(PB8, LOW); // turn the LED on (HIGH is the voltage level)
|
||||
delay(1000); // wait for a second
|
||||
digitalWrite(PB9, LOW); // turn the LED off by making the voltage LOW
|
||||
digitalWrite(PB8, HIGH); // turn the LED on (HIGH is the voltage level)
|
||||
delay(1000); // wait for a second
|
||||
|
||||
sensorValue = analogRead(PA0);
|
||||
Serial.println(sensorValue);
|
||||
sensorValue = analogRead(PA1);
|
||||
Serial.println(sensorValue);
|
||||
sensorValue = analogRead(PA2);
|
||||
Serial.println(sensorValue);
|
||||
}
|
||||
@ -1,89 +1,37 @@
|
||||
/***************************************************************************
|
||||
This is a library for the BME280 humidity, temperature & pressure sensor
|
||||
|
||||
Designed specifically to work with the Adafruit BME280 Breakout
|
||||
----> http://www.adafruit.com/products/2650
|
||||
|
||||
These sensors use I2C or SPI to communicate, 2 or 4 pins are required
|
||||
to interface. The device's I2C address is either 0x76 or 0x77.
|
||||
|
||||
Adafruit invests time and resources providing this open source code,
|
||||
please support Adafruit andopen-source hardware by purchasing products
|
||||
from Adafruit!
|
||||
|
||||
Written by Limor Fried & Kevin Townsend for Adafruit Industries.
|
||||
BSD license, all text above must be included in any redistribution
|
||||
See the LICENSE file for details.
|
||||
***************************************************************************/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
|
||||
#define BME_SCK 13
|
||||
#define BME_MISO 12
|
||||
#define BME_MOSI 11
|
||||
#define BME_CS 10
|
||||
|
||||
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||
|
||||
Adafruit_BME280 bme; // I2C
|
||||
//Adafruit_BME280 bme(BME_CS); // hardware SPI
|
||||
//Adafruit_BME280 bme(BME_CS, BME_MOSI, BME_MISO, BME_SCK); // software SPI
|
||||
|
||||
unsigned long delayTime;
|
||||
Adafruit_BME280 bme;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while(!Serial); // time to get serial running
|
||||
Serial.println(F("BME280 test"));
|
||||
|
||||
unsigned status;
|
||||
Serial.begin(9600);
|
||||
|
||||
// default settings
|
||||
// (you can also pass in a Wire library object like &Wire2)
|
||||
status = bme.begin();
|
||||
if (!status) {
|
||||
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
|
||||
Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
|
||||
Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
|
||||
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
|
||||
Serial.print(" ID of 0x60 represents a BME 280.\n");
|
||||
Serial.print(" ID of 0x61 represents a BME 680.\n");
|
||||
while (1);
|
||||
}
|
||||
|
||||
Serial.println("-- Default Test --");
|
||||
delayTime = 1000;
|
||||
|
||||
Serial.println();
|
||||
if (!bme.begin(0x76)) {
|
||||
Serial.println("Could not find a valid BME280 sensor, check wiring!");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
printValues();
|
||||
delay(delayTime);
|
||||
}
|
||||
|
||||
|
||||
void printValues() {
|
||||
Serial.print("Temperature = ");
|
||||
Serial.print(bme.readTemperature());
|
||||
Serial.println(" *C");
|
||||
|
||||
Serial.print("Pressure = ");
|
||||
Serial.print("Temperature = ");
|
||||
Serial.print(bme.readTemperature());
|
||||
Serial.println("*C");
|
||||
|
||||
Serial.print(bme.readPressure() / 100.0F);
|
||||
Serial.println(" hPa");
|
||||
Serial.print("Pressure = ");
|
||||
Serial.print(bme.readPressure() / 100.0F);
|
||||
Serial.println("hPa");
|
||||
|
||||
Serial.print("Approx. Altitude = ");
|
||||
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
Serial.println(" m");
|
||||
Serial.print("Approx. Altitude = ");
|
||||
Serial.print(bme.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
Serial.println("m");
|
||||
|
||||
Serial.print("Humidity = ");
|
||||
Serial.print(bme.readHumidity());
|
||||
Serial.println(" %");
|
||||
Serial.print("Humidity = ");
|
||||
Serial.print(bme.readHumidity());
|
||||
Serial.println("%");
|
||||
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
Loading…
Reference in new issue