Merge branch 'master' into dev-py

pull/54/head
alanbjohnston 5 years ago committed by GitHub
commit e17ae7ab4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -40,7 +40,7 @@ Use the down arrow key to go down in the file until you find this line:
Add the following two lines under it: (NOTE: there seems to be an issue with the i2c-gpio.dtbo file in the latest kernal. I'm investigating this temporary fix: https://github.com/raspberrypi/firmware/issues/1401. If adding dtoverlay=i2c-gpio in this step causes your Pi not to boot, then you are encountering this issue)
`dtoverlay=i2c-gpio`
`dtoverlay=i2c-gpio,bus=3,i2c_gpio_delay_us=1,i2c_gpio_sda=23,i2c_gpio_scl=24`
`dtoverlay=pi3-miniuart-bt`
@ -78,6 +78,10 @@ you should see two I2C buses:
`i2c-1 i2c-3`
Note, you might see these two I2C buses - this is fine to:
`i2c-1 i2c-11`
Continue the install by typing:
`cd`

@ -106,6 +106,7 @@ int rd = 0;
int nrd;
void write_to_buffer(int i, int symbol, int val);
void write_wave(int i, short int *buffer);
int uart_fd;
int reset_count;
float uptime_sec;
@ -338,7 +339,6 @@ else
if (!ax5043) // don't test if AX5043 is present
{
int uart_fd;
payload = OFF;
if ((uart_fd = serialOpen ("/dev/ttyAMA0", 9600)) >= 0)
@ -348,8 +348,8 @@ else
int i;
for(i = 0; i < 2; i++)
{
serialPutchar (uart_fd, '?');
printf("Querying payload with ?\n");
serialPutchar (uart_fd, 'R');
printf("Querying payload with R to reset\n");
waitTime = millis() + 500;
while ((millis() < waitTime) && (payload != ON))
{
@ -384,6 +384,17 @@ else
tx_freq_hz -= tx_channel * 50000;
if (mode == AFSK)
sleep(10); // delay awaiting CW ID completion
if (transmit == FALSE)
{
fprintf(stderr,"\nNo CubeSatSim Band Pass Filter detected. No transmissions after the CW ID.\n");
fprintf(stderr, " See http://cubesatsim.org/wiki for info about building a CubeSatSim\n\n");
}
while (loop-- != 0)
{
frames_sent++;
@ -640,7 +651,7 @@ for (int j = 0; j < frameCnt; j++)
char header_str2[] = ">CQ:hi hi ";
char header_str4[] = "hi hi ";
char footer_str1[] = "\' > t.txt && echo \'";
char footer_str[] = ">CQ:hi hi ' >> t.txt && gen_packets -o telem.wav t.txt -r 48000 > /dev/null 2>&1 && cat telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.897e3 > /dev/null 2>&1";
char footer_str[] = ">CQ:hi hi ' >> t.txt && gen_packets -o telem.wav t.txt -r 48000 > /dev/null 2>&1 && cat telem.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo /home/pi/rpitx/rpitx -i- -m RF -f 434.9e3 > /dev/null 2>&1";
if (ax5043)
{
@ -681,6 +692,46 @@ for (int j = 0; j < frameCnt; j++)
//printf("Before 1st strcpy\n");
strcat(cw_str2, cw_footer2);
//printf("Before 1st strcpy\n");
// read payload sensor if available
char sensor_payload[500];
if (payload == ON)
{
char c;
unsigned int waitTime;
int i = 0;
serialPutchar (uart_fd, '?');
printf("Querying payload with ?\n");
waitTime = millis() + 500;
int end = FALSE;
while ((millis() < waitTime) && !end)
{
int chars = serialDataAvail (uart_fd);
while ((chars-- > 0) && !end)
{
c = serialGetchar (uart_fd);
// printf ("%c", c);
// fflush(stdout);
if (c != '\n')
{
sensor_payload[i++] = c;
}
else
{
end = TRUE;
}
}
}
// sensor_payload[i++] = '\n';
sensor_payload[i] = '\0';
printf("Payload string: %s", sensor_payload);
strcat(str, sensor_payload); // append to telemetry string for transmission
}
digitalWrite (txLed, txLedOn);
#ifdef DEBUG_LOGGING
printf("Tx LED On\n");
@ -799,6 +850,8 @@ int get_tlm_fox() {
int posXv = 0, negXv = 0, posYv = 0, negYv = 0, posZv = 0, negZv = 0;
int posXi = 0, negXi = 0, posYi = 0, negYi = 0, posZi = 0, negZi = 0;
int head_offset = 0;
// int xAngularVelocity = (-0.69)*(-10)*(-10) + 45.3 * (-10) + 2078, yAngularVelocity = (-0.69)*(-6)*(-6) + 45.3 * (-6) + 2078, zAngularVelocity = (-0.69)*(6)*(6) + 45.3 * (6) + 2078; // XAxisAngularVelocity
int xAngularVelocity = 2078, yAngularVelocity = 2078, zAngularVelocity = 2078; // XAxisAngularVelocity Y and Z set to 0
short int buffer_test[bufLen];
int buffSize;
@ -928,7 +981,6 @@ if (firstTime != ON)
negXv = (int)(voltage[map[MINUS_X]] * 100);
negYv = (int)(voltage[map[MINUS_Y]] * 100);
negZv = (int)(voltage[map[MINUS_Z]] * 100);
batt_c_v = (int)(voltage[map[BAT]] * 100);
battCurr = (int)current[map[BAT]] + 2048;
PSUVoltage = (int)(voltage[map[BUS]] * 100);
@ -938,6 +990,90 @@ if (firstTime != ON)
batteryVoltage = voltage[map[BAT]];
// if (payload == ON)
// STEMBoardFailure = 0;
// read payload sensor if available
char sensor_payload[500];
if (payload == ON)
{
STEMBoardFailure = 0;
char c;
unsigned int waitTime;
int i = 0;
serialPutchar (uart_fd, '?');
printf("Querying payload with ?\n");
waitTime = millis() + 500;
int end = FALSE;
while ((millis() < waitTime) && !end)
{
int chars = serialDataAvail (uart_fd);
while ((chars-- > 0) && !end)
{
c = serialGetchar (uart_fd);
// printf ("%c", c);
// fflush(stdout);
if (c != '\n')
{
sensor_payload[i++] = c;
}
else
{
end = TRUE;
}
}
}
sensor_payload[i++] = ' ';
sensor_payload[i++] = '\n';
sensor_payload[i] = '\0';
printf("Payload string: %s", sensor_payload);
int count1;
char *token;
// char cmdbuffer[1000];
// FILE *file = popen("python3 /home/pi/CubeSatSim/python/voltcurrent.py 1 11", "r");
// fgets(cmdbuffer, 1000, file);
// printf("result: %s\n", cmdbuffer);
// pclose(file);
const char space[2] = " ";
token = strtok(sensor_payload, space);
float gyroX, gyroY, gyroZ;
for (count1 = 0; count1 < 7; count1++) // skipping over BME280 data
{
if (token != NULL)
token = strtok(NULL, space);
}
if (token != NULL)
{
gyroX = atof(token);
printf("gyroX %f ", gyroX);
token = strtok(NULL, space);
}
if (token != NULL)
{
gyroY = atof(token);
printf("gyroY %f ", gyroY);
token = strtok(NULL, space);
}
if (token != NULL)
{
gyroZ = atof(token);
printf("gyroZ %f \n", gyroZ);
}
xAngularVelocity = (-0.69)*(gyroX)*(gyroX) + 45.3 * (gyroX) + 2078;
yAngularVelocity = (-0.69)*(gyroY)*(gyroY) + 45.3 * (gyroY) + 2078;
zAngularVelocity = (-0.69)*(gyroZ)*(gyroZ) + 45.3 * (gyroZ) + 2078;
}
encodeA(b, 0 + head_offset, batt_a_v);
encodeB(b, 1 + head_offset, batt_b_v);
encodeA(b, 3 + head_offset, batt_c_v);
@ -981,6 +1117,10 @@ if (firstTime != ON)
encodeA(b, 39 + head_offset, IHUcpuTemp);
encodeB(b, 40 + head_offset, xAngularVelocity);
encodeA(b, 42 + head_offset, yAngularVelocity);
encodeB(b, 43 + head_offset, zAngularVelocity);
encodeB(b, 51 + head_offset, STEMBoardFailure);
short int data10[headerLen + rsFrames * (rsFrameLen + parityLen)];

@ -1,7 +1,14 @@
//#define TESTING // Uncomment to test code on Serial Monitor
int counter = 0;
int RXLED = 17; // The RX LED has a defined Arduino pin
void setup() {
#ifdef TESTING
Serial.begin(9600);
#endif
Serial1.begin(9600);
digitalWrite(RXLED, LOW); // set the RX LED ON
@ -14,7 +21,20 @@ void setup() {
void loop() {
#ifdef TESTING // ? is sent over Serial Monitor for 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.println("OK");
// Serial1.println(counter++);
}
#else // ? is sent by Pi UART
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
@ -25,6 +45,7 @@ void loop() {
Serial1.println("OK");
// Serial1.println(counter++);
}
#endif
delay(100);
}

@ -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);
}

@ -1,15 +1,21 @@
This code is for the STM32 or Pro Micro acting as a payload to the CubeSatSim.
Code includes:
Code includes (in rough order of testing):
Blink_STM32_PC13.ino and Blink_Pro_Micro.ino The usual Arduino "Hello World" application that blinks the LED for each board.
i2c_scanner.ino A handy utility for scanning the I2C bus that displays the results in the Serial Monitor at 9600 baud. If the sensors are installed and the jumpers set to the correct position, the two sensors should be displayed.
Blink_STM32_PC13.ino and Blink_Pro_Micro.ino The usual Arduino "Hello World" application that blinks the LED for each board.
STEM_Payload_Test_STM32.ino and STEM_Payload_Test_Pro_Micro.ino Blinks the Blue and Green LEDs on the STEM Payload Board and also reads the Temperature and Voltage sensors.
bme280test.ino Displays the results of reading the BME280 sensor: Temperature, Pressure, Altitude, and Humidity and displays on Serial Monitor 9600 baud. Requires the following libraries: Adadruit Unified Sensor (specify version 1.0.3), Adafruit_BME280 (specify version 1.1.0)
GetAllData.ino Displays the results of reading the MPU6050 sensor: Temperature, X, Y, and Z Axes: Acceleration, Gyor (Rotation Rate), and Angle. Requires the following libraries: MPU6050_tockn.
PayloadOK_STM32_PC13.ino and PayloadOK_Pro_Micro.ino This code answers the query from the Raspberry Pi CubeSatSim software over the UART so that the STEM Payload is marked "OK" in the FoxTelem CubeSatSim-FSK Health tab.
Payload_BME280_MPU6050_Pro_Micro.ino and Payload_BME280_MPU6050_STM32.ino This code answers the query from the Raspberry Pi CubeSatSim software over the UART so that the STEM Payload is marked "OK" in the FoxTelem CubeSatSim-FSK Health tab and also replies withe BME280 and MPU6050 sensor data. In FoxTelem, this is displayed as the X, Y, and Z Gyro (dps) and in AFSK mode, it is appended to the telemetry string.
The STM32 can be programmed using the Arduino IDE with the Generic STM32F103C series board and STM32duino bootloader, Maple Mini port.
The Sparkfun Pro Micro can also be programed using the Arduino IDE with the Sparkfun Pro Micro board and AVRISP mkII Programmer.

@ -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);
}

@ -51,14 +51,15 @@ if __name__ == "__main__":
time.sleep(5)
elif (('s' == sys.argv[1]) or ('sstv' in sys.argv[1])):
print("SSTV")
# os.system("(while true; do (sleep 10 && cat /home/pi/CubeSatSim/wav/sstv.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3); done)")
while True:
GPIO.output(txLed, txLedOff);
print("Sleeping")
time.sleep(10)
print("Transmitting SSTV")
GPIO.output(txLed, txLedOn);
os.system("cat /home/pi/CubeSatSim/wav/sstv.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3")
GPIO.output(txLed, txLedOn);
os.system("(while true; do (sleep 5 && cat /home/pi/CubeSatSim/wav/sstv.wav); done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3")
# while True:
# GPIO.output(txLed, txLedOff);
# print("Sleeping")
# time.sleep(10)
# print("Transmitting SSTV")
# GPIO.output(txLed, txLedOn);
# os.system("cat /home/pi/CubeSatSim/wav/sstv.wav | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo rpitx -i- -m RF -f 434.9e3")
elif (('b' == sys.argv[1]) or ('bpsk' in sys.argv[1])):
print("BPSK")
os.system("sudo nc -l 8080 | csdr convert_i16_f | csdr fir_interpolate_cc 2 | csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo /home/pi/rpitx/sendiq -i /dev/stdin -s 96000 -f 434.9e6 -t float")

Loading…
Cancel
Save

Powered by TurnKey Linux.