commit
70eb416ccc
@ -0,0 +1,235 @@
|
||||
import tago
|
||||
import requests
|
||||
import json
|
||||
from datetime import datetime
|
||||
import time
|
||||
|
||||
while (True):
|
||||
|
||||
print("Input telemetry string (or Control-C to exit)")
|
||||
|
||||
# telem_string = input()
|
||||
|
||||
telem_json = requests.get('https://api.aprs.fi/api/get?name=W3YP-11&what=loc&apikey=APIKEY&format=json').json()
|
||||
|
||||
lat = float(telem_json['entries'][0]['lat'])
|
||||
lon = float(telem_json['entries'][0]['lng'])
|
||||
telem_string = telem_json['entries'][0]['comment']
|
||||
times = int(telem_json['entries'][0]['time'])
|
||||
|
||||
|
||||
print(lat)
|
||||
print(lon)
|
||||
print(telem_string)
|
||||
|
||||
chunks = telem_string.split(' ')
|
||||
|
||||
#printchunks = str.split(' ')
|
||||
|
||||
print(chunks)
|
||||
|
||||
temp = 0
|
||||
pressure = 0
|
||||
altitude = 0
|
||||
humidity = 0
|
||||
|
||||
|
||||
timestamp = datetime.utcfromtimestamp(times).strftime('%Y-%m-%d %H:%M:%S')
|
||||
print(timestamp)
|
||||
|
||||
for i in range(len(chunks)):
|
||||
if (chunks[i] == "BME280"):
|
||||
print("Found BME280")
|
||||
temp = chunks[i+1]
|
||||
pressure = chunks[i+2]
|
||||
altitude = chunks[i+3]
|
||||
humidity = chunks[i+4]
|
||||
print(temp)
|
||||
print(humidity)
|
||||
if (chunks[i] == "MPU6050"):
|
||||
print("Found MPU6050")
|
||||
x_rotate = chunks[i+1]
|
||||
y_rotate = chunks[i+2]
|
||||
z_rotate = chunks[i+3]
|
||||
x_accel = chunks[i+4]
|
||||
y_accel = chunks[i+5]
|
||||
z_accel = chunks[i+6]
|
||||
if (chunks[i] == "SGP30"):
|
||||
print("Found SGP30")
|
||||
tvoc = chunks[i+1]
|
||||
e_co2 = chunks[i+2]
|
||||
raw_h2 = chunks[i+3]
|
||||
raw_ethanol= chunks[i+4]
|
||||
|
||||
#print(telem_string)
|
||||
|
||||
|
||||
my_device = tago.Device('a824cdc6-dc87-4c54-a848-41dabb8873ad')
|
||||
|
||||
"""
|
||||
The following code defines the set of data to be sent to TagoIO
|
||||
data fields:
|
||||
- variable name
|
||||
- variable unit
|
||||
- variable value
|
||||
- Optional: desired data timestamp
|
||||
- Optional: lat/long location (associated to your data)
|
||||
"""
|
||||
data = {
|
||||
'variable': 'temperature',
|
||||
'unit' : 'C',
|
||||
'value' : temp,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
#print(data)
|
||||
|
||||
data = {
|
||||
'variable': 'pressure',
|
||||
'unit' : 'kPa',
|
||||
'value' : pressure,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'altitude',
|
||||
'unit' : 'm',
|
||||
'value' : altitude,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'humidity',
|
||||
'unit' : '%',
|
||||
'value' : humidity,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'x_rotate',
|
||||
'unit' : 'dps',
|
||||
'value' : x_rotate,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'y_rotate',
|
||||
'unit' : 'dps',
|
||||
'value' : y_rotate,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'z_rotate',
|
||||
'unit' : 'dps',
|
||||
'value' : z_rotate,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'x_accel',
|
||||
'unit' : 'g',
|
||||
'value' : x_accel,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'y_accel',
|
||||
'unit' : 'g',
|
||||
'value' : y_accel,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'z_accel',
|
||||
'unit' : 'g',
|
||||
'value' : z_accel,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'tvoc',
|
||||
'unit' : 'ppb',
|
||||
'value' : tvoc,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'e_co2',
|
||||
'unit' : 'ppm',
|
||||
'value' : e_co2,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'raw_h2',
|
||||
'unit' : 'raw',
|
||||
'value' : raw_h2,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
'variable': 'raw_ethanol',
|
||||
'unit' : 'raw',
|
||||
'value' : raw_ethanol,
|
||||
'time' : timestamp,
|
||||
'location': {'lat': lat, 'lng': lon}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
data = {
|
||||
"variable": "location",
|
||||
"value": "Villanova University HAB-2",
|
||||
"location": {
|
||||
"lat": lat,
|
||||
"lng": lon
|
||||
}
|
||||
}
|
||||
result = my_device.insert(data)
|
||||
print(result)
|
||||
|
||||
time.sleep(60)
|
||||
@ -0,0 +1,418 @@
|
||||
// code for Pro Micro or STM32 on the CubeSat Simulator STEM Payload board
|
||||
// answers "OK" on the serial port Serial1 when queried by the Pi
|
||||
// includes code by Christy Ammon
|
||||
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Adafruit_BME280.h>
|
||||
#include <Adafruit_SGP30.h>
|
||||
#include <MPU6050_tockn.h>
|
||||
#include <EEPROM.h>
|
||||
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||
|
||||
Adafruit_BME280 bme;
|
||||
Adafruit_SGP30 sgp;
|
||||
MPU6050 mpu6050(Wire);
|
||||
|
||||
long timer = 0;
|
||||
int bmePresent;
|
||||
int RXLED = 17; // The RX LED has a defined Arduino pin
|
||||
int greenLED = 9;
|
||||
int blueLED = 8;
|
||||
int Sensor1 = 0;
|
||||
float Sensor2 = 0;
|
||||
void eeprom_word_write(int addr, int val);
|
||||
short eeprom_word_read(int addr);
|
||||
void blink_setup();
|
||||
void blink(int length);
|
||||
int read_analog();
|
||||
void led_set(int ledPin, bool state);
|
||||
|
||||
int first_time = true;
|
||||
int first_read = true;
|
||||
|
||||
#if defined __AVR_ATmega32U4__
|
||||
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
|
||||
#endif
|
||||
#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4)
|
||||
float T2 = 25; // Temperature data point 1
|
||||
float R2 = 671; // Reading data point 1
|
||||
float T1 = 15.5; // Temperature data point 2
|
||||
float R1 = 695; // Reading data point 2
|
||||
#endif
|
||||
|
||||
int sensorValue;
|
||||
float Temp;
|
||||
float rest;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600); // Serial Monitor for testing
|
||||
|
||||
Serial1.begin(115200); // Pi UART faster speed
|
||||
// Serial1.begin(9600); // 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("Could not find a valid BME280 sensor, check wiring!");
|
||||
bmePresent = 0;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
/**/
|
||||
if (! sgp.begin()){
|
||||
Serial.println("SGP30 sensor not found :(");
|
||||
} else {
|
||||
Serial.print("Found SGP30 serial #");
|
||||
Serial.print(sgp.serialnumber[0], HEX);
|
||||
Serial.print(sgp.serialnumber[1], HEX);
|
||||
Serial.println(sgp.serialnumber[2], HEX);
|
||||
}
|
||||
// If you have a baseline measurement from before you can assign it to start, to 'self-calibrate'
|
||||
//sgp.setIAQBaseline(0x8E68, 0x8F41); // Will vary for each sensor!
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
if (Serial1.available() > 0) {
|
||||
blink(50);
|
||||
char result = Serial1.read();
|
||||
// Serial1.println(result);
|
||||
// Serial1.println("OK");
|
||||
|
||||
// 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 = read_analog();
|
||||
|
||||
// Serial.println(sensorValue);
|
||||
Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1));
|
||||
/*
|
||||
Serial1.print(" XS ");
|
||||
Serial1.print(Temp);
|
||||
Serial1.print(" ");
|
||||
Serial1.println(Sensor2);
|
||||
*/
|
||||
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());
|
||||
// Serial.print(rotation);
|
||||
// Serial.print(" ");
|
||||
// Serial.println(acceleration);
|
||||
|
||||
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);
|
||||
|
||||
//SGP SENSOR DATA
|
||||
if (! sgp.IAQmeasure()) {
|
||||
// Serial.println("SGP 30 Measurement failed");
|
||||
Serial1.print(" SGP30 0 0 ");
|
||||
} else {
|
||||
Serial1.print(" SGP30 ");
|
||||
Serial1.print(sgp.TVOC);
|
||||
Serial1.print(" ");
|
||||
//Serial.print("eCO2 ");
|
||||
Serial1.print(sgp.eCO2);
|
||||
Serial1.print(" ");
|
||||
}
|
||||
if (! sgp.IAQmeasureRaw()) {
|
||||
// Serial.println(" SGP 30 Raw Measurement failed");
|
||||
Serial1.println(" 0 0 ");
|
||||
} else {
|
||||
//Serial.print("Raw H2 ");
|
||||
Serial1.print(sgp.rawH2);
|
||||
Serial1.print(" ");
|
||||
//Serial.print("Raw Ethanol ");
|
||||
Serial1.print(sgp.rawEthanol);
|
||||
Serial1.println(" ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Serial.available() > 0) {
|
||||
blink(50);
|
||||
char result = Serial.read();
|
||||
// Serial.println(result);
|
||||
// Serial.println("OK");
|
||||
// Serial.println(counter++);
|
||||
|
||||
if (result == 'R') {
|
||||
Serial1.println("OK");
|
||||
delay(100);
|
||||
first_read = 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 = read_analog();
|
||||
|
||||
Temp = T1 + (sensorValue - R1) *((T2 - T1)/(R2 - R1));
|
||||
/*
|
||||
Serial.print(" XS ");
|
||||
Serial.print(Temp);
|
||||
Serial.print(" ");
|
||||
Serial.print(Sensor2);
|
||||
Serial.print(" (");
|
||||
Serial.print(sensorValue);
|
||||
Serial.print(")");
|
||||
*/
|
||||
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());
|
||||
// Serial.print(rotation);
|
||||
// Serial.print(" ");
|
||||
// Serial.println(acceleration);
|
||||
|
||||
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);
|
||||
|
||||
//SGP SENSOR DATA
|
||||
if (! sgp.IAQmeasure()) {
|
||||
// Serial.println("SGP 30 Measurement failed");
|
||||
Serial.print(" SGP30 0 0 ");
|
||||
} else {
|
||||
Serial.print(" SGP30 ");
|
||||
Serial.print(sgp.TVOC);
|
||||
Serial.print(" ");
|
||||
//Serial.print("eCO2 ");
|
||||
Serial.print(sgp.eCO2);
|
||||
Serial.print(" ");
|
||||
}
|
||||
if (! sgp.IAQmeasureRaw()) {
|
||||
// Serial.println("SGP 30 Raw Measurement failed");
|
||||
Serial.println("0 0");
|
||||
} else {
|
||||
//Serial.print("Raw H2 ");
|
||||
Serial.print(sgp.rawH2);
|
||||
Serial.print(" ");
|
||||
//Serial.print("Raw Ethanol ");
|
||||
Serial.print(sgp.rawEthanol);
|
||||
Serial.println(" ");
|
||||
|
||||
uint16_t TVOC_base, eCO2_base;
|
||||
if (! sgp.getIAQBaseline(&eCO2_base, &TVOC_base)) {
|
||||
Serial.println("Failed to get baseline readings");
|
||||
}
|
||||
Serial.print("****Baseline values: eCO2: 0x"); Serial.print(eCO2_base, HEX);
|
||||
Serial.print(" & TVOC: 0x"); Serial.println(TVOC_base, HEX);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
int read_analog()
|
||||
{
|
||||
int sensorValue;
|
||||
#if defined __AVR_ATmega32U4__
|
||||
sensorValue = analogRead(A3);
|
||||
#endif
|
||||
#if defined(ARDUINO_ARCH_STM32F0) || defined(ARDUINO_ARCH_STM32F1) || defined(ARDUINO_ARCH_STM32F3) || defined(ARDUINO_ARCH_STM32F4) || defined(ARDUINO_ARCH_STM32L4)
|
||||
sensorValue = analogRead(PA7);
|
||||
#endif
|
||||
return(sensorValue);
|
||||
}
|
||||
Loading…
Reference in new issue