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);
|
||||||
|
}
|
||||||
Loading…
Reference in new issue