@ -0,0 +1,11 @@
|
||||
Here is information about the CubeSatSim Lite vB3 hardware
|
||||
|
||||
|
||||
cubesat-sim-lite_0.3_gerbers.zip -- All gerber files used to fabricate PCBs
|
||||
|
||||
cubesat-sim-lite-0.3_schematic.pdf -- Schematic
|
||||
|
||||
cubesat-sim-lite-0.3.mnb
|
||||
|
||||
cubesat-sim-lite-0.3.mnb
|
||||
|
||||
@ -0,0 +1,18 @@
|
||||
C1 17.08 24.17 270 1pF C0603
|
||||
C2 17.08 22.75 270 1pF C0603
|
||||
C3 20.69 23.41 180 20pF C0603
|
||||
C4 22.14 23.41 180 20pF C0603
|
||||
D1 48.34 5.26 270 GREEN LED-0603
|
||||
D2 9.00 5.37 270 BLUE LED-0603
|
||||
E1 3.18 17.57 270 ANT-916-CHP-T XDCR_ANT-916-CHP-T
|
||||
L1 11.15 23.50 180 30nH L0603
|
||||
L2 14.12 22.73 180 13nH L0603
|
||||
L3 19.27 23.41 270 1.5nH L0603
|
||||
L4 19.27 20.46 270 1.5nH L0603
|
||||
L5 11.14 22.05 180 DNI/30nH L0603
|
||||
R2 46.76 25.88 270 DNI/1K R0603
|
||||
R6 50.58 25.88 270 DNI/1K R0603
|
||||
R11 48.36 8.27 270 3.3K 0603-RES
|
||||
R12 9.00 8.75 270 3.3K 0603-RES
|
||||
S1 56.04 6.43 270 DTSM-6 DTSM-6
|
||||
S2 16.87 6.41 270 DTSM-6 DTSM-6
|
||||
|
After Width: | Height: | Size: 1.4 MiB |
@ -0,0 +1,37 @@
|
||||
Here is information about the CubeSatSim v1.1 hardware
|
||||
|
||||
NOTE: The change between v1.0 and v1.1 is changing the BPF to a LPF. Only the SMD components change - all the rest are identical
|
||||
|
||||
There are files for the main board, battery board, and STEM payload board of these types:
|
||||
|
||||
* cubesatsim-main-1.1_gerbers.zip -- All gerber files used to fabricate PCBs
|
||||
|
||||
* cubesatsim-main-1.1_schematic.pdf -- Schematic
|
||||
|
||||
* cubesatsim-main-1.1_pcb.png -- View of board
|
||||
|
||||
* cubesatsim-main-1.1_board_fill.png -- View of board with fill
|
||||
|
||||
* cubesatsim-main-1.1_topPCB.png -- Top view of PCB generated by gerbers
|
||||
|
||||
* cubesatsim-main-1.1_bottomPCB.png -- Bottom view of PCB generated by gerbers
|
||||
|
||||
* cubesatsim-main-1.1_tNames.pdf -- Top outline of components
|
||||
|
||||
* cubesatsim-main-1.1_bNames.pdf -- Bottom outline of components
|
||||
|
||||
* cubesatsim-main-1.1.mnt -- top SMD component placement data
|
||||
|
||||
* cubesatsim-main-1.0.mnb -- bottom SMD component placement data
|
||||
|
||||
* cubesatsim-main-1.0_bom.csv.txt -- Bill of Materials in CSV format
|
||||
|
||||
|
||||
I use PCBWay to fabricate PCBs https://pcbway.com
|
||||
|
||||
Board sets are available on the AMSAT Store:
|
||||
https://www.amsat.org/product/amsat-cubesatsim-pcb/
|
||||
|
||||
Bill of materials https://CubeSatSim.org/bom
|
||||
|
||||
Instructions https://CubeSatSim.org/wiki
|
||||
@ -0,0 +1,6 @@
|
||||
JP4 38.30 64.49 180 JUMPER-SMT_2_NO_SILK SMT-JUMPER_2_NO_SILK
|
||||
JP5 44.68 64.36 180 JUMPER-SMT_2_NO_SILK SMT-JUMPER_2_NO_SILK
|
||||
JP17 11.25 36.42 90 JUMPER-SMT_2_NC_TRACE_SILK SMT-JUMPER_2_NC_TRACE_SILK
|
||||
JP18 13.61 36.42 270 JUMPER-SMT_2_NO_SILK SMT-JUMPER_2_NO_SILK
|
||||
JP19 6.99 36.42 90 JUMPER-SMT_2_NC_TRACE_SILK SMT-JUMPER_2_NC_TRACE_SILK
|
||||
JP20 4.47 36.42 270 JUMPER-SMT_2_NO_SILK SMT-JUMPER_2_NO_SILK
|
||||
@ -0,0 +1 @@
|
||||
J4 32.55 74.23 0 CONN_20X2 2X20
|
||||
@ -0,0 +1,25 @@
|
||||
"Qty";"Value";"Device";"Package";"Parts";"Description";"PROD_ID";
|
||||
"12";"";"M01NOSILK-KIT";"1X01NS-KIT";"JP1, JP2, JP3, JP6, JP7, JP8, JP9, JP10, JP11, JP14, JP15, JP16";"Header 1";"";
|
||||
"3";"100nF";"CAPPTH";"CAP-PTH-SMALL";"C1, C2, C3";"Capacitor";"";
|
||||
"3";"10K";"RESISTORPTH-1/4W-VERT";"AXIAL-0.1";"R9, R10, R11";"Resistor";"";
|
||||
"1";"1N4148";"DIODE-D-2.5";"D-2.5";"D4";"DIODE";"";
|
||||
"3";"1N5817";"DIODE-D-2.5";"D-2.5";"D1, D2, D3";"DIODE";"";
|
||||
"2";"1x20 female header";"M20NOSILK";"1X20_NOSILK";"J6, J7";"1x20 .1" header";"";
|
||||
"2";"4.7k";"RESISTORPTH-1/4W-VERT";"AXIAL-0.1";"R1, R2";"Resistor";"";
|
||||
"2";"470";"RESISTORPTH-1/4W-VERT";"AXIAL-0.1";"R3, R4";"Resistor";"";
|
||||
"1";"BME280";"M04NO_SILK_ALL_ROUND";"1X04_NO_SILK_ALL_ROUND";"JP21";"Header 4";"";
|
||||
"1";"Blue 5mm";"LED3MM";"LED3MM";"LED2";"LED";"";
|
||||
"1";"CONN_20X2";"CONN_20X2";"2X20";"J4";"Multi connection point. Often used as Generic Header-pin footprint for 0.1 inch spaced/style header connections";"";
|
||||
"1";"DNI-100";"RESISTORPTH-1/4W-VERT";"AXIAL-0.1";"R6";"Resistor";"";
|
||||
"1";"DNI-1k";"RESISTORPTH-1/4W-VERT";"AXIAL-0.1";"R5";"Resistor";"";
|
||||
"2";"DNI-1x2 pin header";"CONN_021X02_NO_SILK";"1X02_NO_SILK";"J1, J2";"Multi connection point. Often used as Generic Header-pin footprint for 0.1 inch spaced/style header connections";"";
|
||||
"2";"DNI-1x3 pin header with jumper";"M031X03_NO_SILK";"1X03_NO_SILK";"JP12, JP13";"Header 3";"";
|
||||
"1";"DNI-1x4 pin header";"CONN_041X04_NO_SILK";"1X04_NO_SILK";"J3";"Multi connection point. Often used as Generic Header-pin footprint for 0.1 inch spaced/style header connections";"CONN-09696";
|
||||
"2";"DNI-4k";"RESISTORPTH-1/4W-VERT";"AXIAL-0.1";"R7, R8";"Resistor";"";
|
||||
"1";"DNI-Blue 5mm";"LED3MM";"LED3MM";"LED4";"LED";"";
|
||||
"1";"DNI-Green 5mm";"LED3MM";"LED3MM";"LED3";"LED";"";
|
||||
"1";"Green 5mm";"LED3MM";"LED3MM";"LED1";"LED";"";
|
||||
"2";"JUMPER-SMT_2_NC_TRACE_SILK";"JUMPER-SMT_2_NC_TRACE_SILK";"SMT-JUMPER_2_NC_TRACE_SILK";"JP17, JP19";"Normally closed trace jumper";"";
|
||||
"4";"JUMPER-SMT_2_NO_SILK";"JUMPER-SMT_2_NO_SILK";"SMT-JUMPER_2_NO_SILK";"JP4, JP5, JP18, JP20";"Normally open jumper";"";
|
||||
"1";"MPU6050";"M08NO_SILK_FEMALE_PTH";"1X08_NO_SILK";"J5";"Header 8";"CONN-08438";
|
||||
"1";"Sparkfun Pro Micro 3.3V 8MHz";"SPARKFUN_PRO_MICRO";"SPARKFUN_PRO_MICRO";"U1";"SparkFun Pro Micro";"";
|
||||
|
After Width: | Height: | Size: 552 KiB |
|
After Width: | Height: | Size: 1.9 MiB |
|
After Width: | Height: | Size: 1.9 MiB |
|
After Width: | Height: | Size: 640 KiB |
@ -0,0 +1,5 @@
|
||||
"Qty";"Value";"Device";"Package";"Parts";"Description";"DESCRIPTION";"DIGI-KEY_PART_NUMBER";"MF";"MP";"PACKAGE";"PURCHASE-URL";
|
||||
"2";"";"CONN_01PTH_NO_SILK_KIT";"1X01NS_KIT";"J1, J2";"Single connection point. Often used as Generic Header-pin footprint for 0.1 inch spaced/style header connections";"";"";"";"";"";"";
|
||||
"1";"AA battery holder BH3AA-PC";"BH3AA-PC";"BAT_BH3AA-PC";"BT1";"Holder Batt 3-Aa Cells Pc Mount";" Battery Holder (Open) AA 3 Cell PC Pin ";"BH3AA-PC-ND";"MPD";"BH3AAPC";"None";"https://pricing.snapeda.com/search/part/BH3AAPC/?ref=eda";
|
||||
"1";"CONN_20X2";"CONN_20X2";"2X20";"J3";"Multi connection point. Often used as Generic Header-pin footprint for 0.1 inch spaced/style header connections";"";"";"";"";"";"";
|
||||
"1";"Micro JST";"M02JST-PTH-VERT";"JST-2-PTH-VERT";"J4";"Standard 2-pin 0.1" header. Use with";"";"";"";"";"";"";
|
||||
|
After Width: | Height: | Size: 125 KiB |
|
After Width: | Height: | Size: 287 KiB |
@ -0,0 +1 @@
|
||||
JP3 11.99 33.49 90 VDD-EN SMT-JUMPER_2_NC_TRACE_SILK
|
||||
@ -0,0 +1,6 @@
|
||||
C1 10.62 75.12 0 18pF C0603
|
||||
C2 15.01 75.12 0 16pF C0603
|
||||
J1 32.55 66.61 0 CONN_20X2 2X20
|
||||
L1 12.83 74.37 180 13nH L0603
|
||||
R2 47.96 59.89 0 DNI-1k R0603
|
||||
R6 55.98 59.79 0 DNI-1k R0603
|
||||
@ -0,0 +1,30 @@
|
||||
"Qty";"Value";"Device";"Package";"Parts";"Description";"MPN";"VALUE";
|
||||
"1";"";"CN3085-MODULE";"CN3085-MODULE";"U6";"";"";"";
|
||||
"1";"100";"RESISTORPTH-1/4W-VERT-KIT";"AXIAL-0.1EZ";"R12";"Resistor";"";"";
|
||||
"1";"13nH";"SMD-FERRITE-CHIP-120-OHM-500MA(0603)";"L0603";"L1";"303030001";"BLM18AG121SN1D";"120";
|
||||
"1";"16pF";"CERAMIC-10PF-50V-5%-NPO(0603)";"C0603";"C2";"302010097";"";"10pf";
|
||||
"1";"18pF";"CERAMIC-10PF-50V-5%-NPO(0603)";"C0603";"C1";"302010097";"";"10pf";
|
||||
"1";"1K";"RESISTORPTH-1/4W-VERT-KIT";"AXIAL-0.1EZ";"R1";"Resistor";"";"";
|
||||
"7";"1N5817";"DIODE-D-2.5";"D-2.5";"D1, D2, D3, D4, D5, D6, D7";"DIODE";"";"";
|
||||
"1";"1V-5V Boost 5V Regulator";"USB-BOOST";"USB-BOOST";"U7";"";"";"";
|
||||
"1";"1k";"RESISTORPTH-1/4W-VERT-KIT";"AXIAL-0.1EZ";"R11";"Resistor";"";"";
|
||||
"1";"220";"RESISTORPTH-1/4W-VERT-KIT";"AXIAL-0.1EZ";"R13";"Resistor";"";"";
|
||||
"2";"4.7k";"RESISTORPTH-1/4W-VERT-KIT";"AXIAL-0.1EZ";"R3, R4";"Resistor";"";"";
|
||||
"1";"5V1 Zener 1W";"ZENER-DIODEZD-2.5";"ZDIO-2.5";"D8";"Z-Diode";"";"";
|
||||
"1";"Blue 5mm";"LED3MM";"LED3MM";"LED2";"LED";"";"";
|
||||
"1";"CFP2-2RC4-AW";"SWITCH-DPDTOS";"OS";"S1";"DPDT Version of the COM-00597";"";"";
|
||||
"1";"CONN_20X2";"CONN_20X2";"2X20";"J1";"Multi connection point. Often used as Generic Header-pin footprint for 0.1 inch spaced/style header connections";"";"";
|
||||
"2";"DNI-0R";"RESISTORPTH-1/4W-VERT-KIT";"AXIAL-0.1EZ";"R9, R10";"Resistor";"";"";
|
||||
"1";"DNI-1K";"RESISTORPTH-1/4W-VERT-KIT";"AXIAL-0.1EZ";"R5";"Resistor";"";"";
|
||||
"2";"DNI-1k";"R-EU_R0603";"R0603";"R2, R6";"RESISTOR, European symbol";"";"";
|
||||
"2";"DNI-4.7k";"RESISTORPTH-1/4W-VERT-KIT";"AXIAL-0.1EZ";"R7, R8";"Resistor";"";"";
|
||||
"1";"DNI-5V1 Zener 1W";"ZENER-DIODEZD-2.5";"ZDIO-2.5";"D9";"Z-Diode";"";"";
|
||||
"1";"Green 5mm";"LED3MM";"LED3MM";"LED1";"LED";"";"";
|
||||
"8";"INA219 purple board";"INA219";"INA219";"U1, U2, U3, U4, U5, U8, U9, U10";"";"";"";
|
||||
"8";"Micro JST";"M02JST-PTH-VERT";"JST-2-PTH-VERT";"JP1, JP2, JP4, JP5, JP6, JP7, JP8, JP10";"Standard 2-pin 0.1" header. Use with";"";"";
|
||||
"1";"PTCPTH";"PTCPTH";"PTC";"F1";"Resettable Fuse PTC";"";"";
|
||||
"1";"Red 5mm";"LED3MM";"LED3MM";"LED3";"LED";"";"";
|
||||
"1";"SC1464-ND";"PG203J";"PG203J";"X1";"MIC/HEADPHONE JACK";"";"";
|
||||
"1";"SMA-VERT";"SMA-VERT";"SMA-VERT";"X11";"";"";"";
|
||||
"1";"VDD-EN";"JUMPER-SMT_2_NC_TRACE_SILK";"SMT-JUMPER_2_NC_TRACE_SILK";"JP3";"Normally closed trace jumper";"";"";
|
||||
"1";"micro USB breakout board";"M05NO_SILK";"1X05_NO_SILK";"JP9";"Header 5";"";"";
|
||||
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 536 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 686 KiB |
@ -0,0 +1,359 @@
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <MPU6050_tockn.h>
|
||||
#include <EEPROM.h>
|
||||
#include "Adafruit_SI1145.h"
|
||||
#include <Adafruit_LIS3MDL.h>
|
||||
|
||||
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||
|
||||
Adafruit_BME280 bme;
|
||||
MPU6050 mpu6050(Wire);
|
||||
Adafruit_SI1145 uv = Adafruit_SI1145();
|
||||
Adafruit_LIS3MDL lis3mdl;
|
||||
|
||||
long timer = 0;
|
||||
int bmePresent;
|
||||
int uvPresent;
|
||||
int magPresent;
|
||||
int RXLED = 17; // The RX LED has a defined Arduino pin
|
||||
int greenLED = 9;
|
||||
int blueLED = 8;
|
||||
void eeprom_word_write(int addr, int val);
|
||||
short eeprom_word_read(int addr);
|
||||
int first_time = true;
|
||||
int first_read = true;
|
||||
float T2 = 26.3; // Temperature data point 1
|
||||
float R2 = 167; // Reading data point 1
|
||||
float T1 = 2; // Temperature data point 2
|
||||
float R1 = 179; // Reading data point 2
|
||||
int sensorValue;
|
||||
float Temp;
|
||||
float rest;
|
||||
float magRaw = 0;
|
||||
float magRawAbs = 0;
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600); // Serial Monitor for testing
|
||||
|
||||
Serial1.begin(115200); // Pi UART faster speed
|
||||
|
||||
Serial.println("Starting!");
|
||||
|
||||
blink_setup();
|
||||
|
||||
blink(500);
|
||||
delay(250);
|
||||
blink(500);
|
||||
delay(250);
|
||||
led_set(greenLED, HIGH);
|
||||
delay(250);
|
||||
led_set(greenLED, LOW);
|
||||
led_set(blueLED, HIGH);
|
||||
delay(250);
|
||||
led_set(blueLED, LOW);
|
||||
|
||||
if (bme.begin(0x76)) {
|
||||
bmePresent = 1;
|
||||
} else {
|
||||
Serial.println("BME280 sensor fault");
|
||||
bmePresent = 0;
|
||||
}
|
||||
|
||||
if (! uv.begin()) {
|
||||
Serial.println("Si1145 sensor fault");
|
||||
uvPresent = 0;
|
||||
} else {
|
||||
uvPresent = 1;
|
||||
}
|
||||
|
||||
if (! lis3mdl.begin_I2C()) {
|
||||
Serial.println("LIS3MDL sensor fault");
|
||||
magPresent = 0;
|
||||
} else {
|
||||
magPresent = 1;
|
||||
}
|
||||
|
||||
mpu6050.begin();
|
||||
|
||||
if (eeprom_word_read(0) == 0xA07)
|
||||
{
|
||||
Serial.println("Reading gyro offsets from EEPROM\n");
|
||||
|
||||
float xOffset = ((float)eeprom_word_read(1)) / 100.0;
|
||||
float yOffset = ((float)eeprom_word_read(2)) / 100.0;
|
||||
float zOffset = ((float)eeprom_word_read(3)) / 100.0;
|
||||
|
||||
Serial.println(xOffset, DEC);
|
||||
Serial.println(yOffset, DEC);
|
||||
Serial.println(zOffset, DEC);
|
||||
|
||||
mpu6050.setGyroOffsets(xOffset, yOffset, zOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.println("Calculating gyro offsets and storing in EEPROM\n");
|
||||
|
||||
mpu6050.calcGyroOffsets(true);
|
||||
|
||||
eeprom_word_write(0, 0xA07);
|
||||
eeprom_word_write(1, (int)(mpu6050.getGyroXoffset() * 100.0) + 0.5);
|
||||
eeprom_word_write(2, (int)(mpu6050.getGyroYoffset() * 100.0) + 0.5);
|
||||
eeprom_word_write(3, (int)(mpu6050.getGyroZoffset() * 100.0) + 0.5);
|
||||
|
||||
Serial.println(eeprom_word_read(0), HEX);
|
||||
Serial.println(((float)eeprom_word_read(1)) / 100.0, DEC);
|
||||
Serial.println(((float)eeprom_word_read(2)) / 100.0, DEC);
|
||||
Serial.println(((float)eeprom_word_read(3)) / 100.0, DEC);
|
||||
}
|
||||
pinMode(greenLED, OUTPUT);
|
||||
pinMode(blueLED, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if ((Serial.available() > 0) || first_time == true) {
|
||||
blink(50);
|
||||
char result = Serial.read();
|
||||
|
||||
if (result == 'R') {
|
||||
Serial.println("OK");
|
||||
delay(100);
|
||||
first_time = true;
|
||||
setup();
|
||||
}
|
||||
else if (result == 'C') {
|
||||
Serial.println("Clearing stored gyro offsets in EEPROM\n");
|
||||
eeprom_word_write(0, 0x00);
|
||||
first_time = true;
|
||||
setup();
|
||||
}
|
||||
if ((result == '?') || first_time == true)
|
||||
{
|
||||
first_time = false;
|
||||
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.print(mpu6050.getGyroZ());
|
||||
|
||||
Serial.print(" ");
|
||||
Serial.print(mpu6050.getAccX());
|
||||
Serial.print(" ");
|
||||
Serial.print(mpu6050.getAccY());
|
||||
Serial.print(" ");
|
||||
Serial.print(mpu6050.getAccZ());
|
||||
|
||||
sensorValue = analogRead(A3);
|
||||
Temp = T1 + (sensorValue - R1) * ((T2 - T1) / (R2 - R1));
|
||||
|
||||
Serial.print(" XS ");
|
||||
Serial.print(Temp);
|
||||
Serial.print(" ");
|
||||
if (uvPresent) {
|
||||
Serial.print(uv.readVisible());
|
||||
Serial.print(" ");
|
||||
Serial.print(uv.readIR());
|
||||
Serial.print(" ");
|
||||
} else
|
||||
{
|
||||
Serial.print("0.0 0.0 ");
|
||||
}
|
||||
if (magPresent) {
|
||||
lis3mdl.read();
|
||||
magRaw = (((lis3mdl.x + lis3mdl.y + lis3mdl.z) / 3));
|
||||
magAbs = abs(magRaw);
|
||||
Serial.println(magAbs);
|
||||
} else
|
||||
{
|
||||
Serial.println("0.0");
|
||||
}
|
||||
|
||||
float rotation = sqrt(mpu6050.getGyroX() * mpu6050.getGyroX() + mpu6050.getGyroY() * mpu6050.getGyroY() + mpu6050.getGyroZ() * mpu6050.getGyroZ());
|
||||
float acceleration = sqrt(mpu6050.getAccX() * mpu6050.getAccX() + mpu6050.getAccY() * mpu6050.getAccY() + mpu6050.getAccZ() * mpu6050.getAccZ());
|
||||
|
||||
if (acceleration > 1.2)
|
||||
led_set(greenLED, HIGH);
|
||||
else
|
||||
led_set(greenLED, LOW);
|
||||
|
||||
if (rotation > 5)
|
||||
led_set(blueLED, HIGH);
|
||||
else
|
||||
led_set(blueLED, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
if (Serial1.available() > 0) {
|
||||
|
||||
blink(50);
|
||||
char result = Serial1.read();
|
||||
|
||||
if (result == 'R') {
|
||||
Serial1.println("OK");
|
||||
delay(100);
|
||||
first_read = true;
|
||||
setup();
|
||||
}
|
||||
|
||||
if (result == '?')
|
||||
{
|
||||
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.print(mpu6050.getGyroZ());
|
||||
|
||||
Serial1.print(" ");
|
||||
Serial1.print(mpu6050.getAccX());
|
||||
Serial1.print(" ");
|
||||
Serial1.print(mpu6050.getAccY());
|
||||
Serial1.print(" ");
|
||||
Serial1.print(mpu6050.getAccZ());
|
||||
|
||||
sensorValue = analogRead(A3);
|
||||
Temp = T1 + (sensorValue - R1) * ((T2 - T1) / (R2 - R1));
|
||||
|
||||
Serial1.print(" XS ");
|
||||
Serial1.print(Temp);
|
||||
Serial1.print(" ");
|
||||
if (uvPresent) {
|
||||
Serial1.print(uv.readVisible());
|
||||
Serial1.print(" ");
|
||||
Serial1.print(uv.readIR());
|
||||
Serial1.print(" ");
|
||||
} else
|
||||
{
|
||||
Serial1.print("0.0 0.0 ");
|
||||
}
|
||||
if (magPresent) {
|
||||
lis3mdl.read();
|
||||
magRaw = (((lis3mdl.x + lis3mdl.y + lis3mdl.z) / 3));
|
||||
magAbs = abs(magRaw);
|
||||
Serial1.println(magAbs);
|
||||
} else
|
||||
{
|
||||
Serial1.println("0.0");
|
||||
}
|
||||
|
||||
|
||||
float rotation = sqrt(mpu6050.getGyroX() * mpu6050.getGyroX() + mpu6050.getGyroY() * mpu6050.getGyroY() + mpu6050.getGyroZ() * mpu6050.getGyroZ());
|
||||
float acceleration = sqrt(mpu6050.getAccX() * mpu6050.getAccX() + mpu6050.getAccY() * mpu6050.getAccY() + mpu6050.getAccZ() * mpu6050.getAccZ());
|
||||
|
||||
if (first_read == true) {
|
||||
first_read = false;
|
||||
rest = acceleration;
|
||||
}
|
||||
|
||||
if (acceleration > 1.2 * rest)
|
||||
led_set(greenLED, HIGH);
|
||||
else
|
||||
led_set(greenLED, LOW);
|
||||
|
||||
if (rotation > 5)
|
||||
led_set(blueLED, HIGH);
|
||||
else
|
||||
led_set(blueLED, LOW);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void eeprom_word_write(int addr, int val)
|
||||
{
|
||||
EEPROM.write(addr * 2, lowByte(val));
|
||||
EEPROM.write(addr * 2 + 1, highByte(val));
|
||||
}
|
||||
|
||||
short eeprom_word_read(int addr)
|
||||
{
|
||||
return ((EEPROM.read(addr * 2 + 1) << 8) | EEPROM.read(addr * 2));
|
||||
}
|
||||
|
||||
void blink_setup()
|
||||
{
|
||||
#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4)
|
||||
// initialize digital pin PB1 as an output.
|
||||
pinMode(PC13, OUTPUT);
|
||||
pinMode(PB9, OUTPUT);
|
||||
pinMode(PB8, OUTPUT);
|
||||
#endif
|
||||
|
||||
#if defined __AVR_ATmega32U4__
|
||||
pinMode(RXLED, OUTPUT); // Set RX LED as an output
|
||||
// TX LED is set as an output behind the scenes
|
||||
pinMode(greenLED, OUTPUT);
|
||||
pinMode(blueLED, OUTPUT);
|
||||
#endif
|
||||
}
|
||||
|
||||
void blink(int length)
|
||||
{
|
||||
#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4)
|
||||
digitalWrite(PC13, LOW); // turn the LED on (HIGH is the voltage level)
|
||||
#endif
|
||||
|
||||
#if defined __AVR_ATmega32U4__
|
||||
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
|
||||
#endif
|
||||
|
||||
delay(length); // wait for a lenth of time
|
||||
|
||||
#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4)
|
||||
digitalWrite(PC13, HIGH); // turn the LED off by making the voltage LOW
|
||||
#endif
|
||||
|
||||
#if defined __AVR_ATmega32U4__
|
||||
digitalWrite(RXLED, HIGH); // set the RX LED OFF
|
||||
TXLED0; //TX LED macro to turn LED ON
|
||||
#endif
|
||||
}
|
||||
|
||||
void led_set(int ledPin, bool state)
|
||||
{
|
||||
#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4)
|
||||
if (ledPin == greenLED)
|
||||
digitalWrite(PB9, state);
|
||||
else if (ledPin == blueLED)
|
||||
digitalWrite(PB8, state);
|
||||
#endif
|
||||
|
||||
#if defined __AVR_ATmega32U4__
|
||||
digitalWrite(ledPin, state);
|
||||
#endif
|
||||
}
|
||||