Commit 6907273e authored by Ondřej Kučera's avatar Ondřej Kučera

added FW

parent 3d413240
#include <Wire.h>
#include <Adafruit_INA219.h>
Adafruit_INA219 ina219;
#define Serial SerialUSB
// the setup function runs once
void setup(void)
{
Serial.begin(115200);
while(!Serial);
SerialUSB.println("CANSAT kit INA219 test started.");
ina219.begin();
}
// the loop function runs over and over again forever
void loop(void)
{
float napeti_shunt = 0;
float napeti_bus = 0;
float proud_mA = 0;
float napeti_load = 0;
napeti_shunt = ina219.getShuntVoltage_mV();
napeti_bus = ina219.getBusVoltage_V();
proud_mA = ina219.getCurrent_mA();
napeti_load = napeti_bus + (napeti_shunt / 1000);
Serial.print("Bus Voltage: " + (string) napeti_bus);
Serial.println(" V");
Serial.print("Shunt Voltage: ");
Serial.print(napeti_shunt);
Serial.println(" mV");
Serial.print("Load Voltage: ");
Serial.print(napeti_load);
Serial.println(" V");
Serial.print("Current: ");
Serial.print(proud_mA);
Serial.println(" mA");
Serial.println("");
delay(2000);
}
// 31 TX LED
// 30
// 26
// 25 RX LED
// 13 D LED
#define D PIN_LED_13
// TX SHOULD BE D31
#define TXLED PIN_LED_TXL// RX SHOULD BE D25
#define RXLED PIN_LED_RXL
#define Serial SerialUSBvoid
setup() {
pinMode(D, OUTPUT);
pinMode(TXLED, OUTPUT);
pinMode(RXLED, OUTPUT);
Serial.begin(9600);
while(!Serial);
Serial.println("LED test.");
}
void loop()
{
digitalWrite(D, HIGH);
digitalWrite(TXLED, HIGH);
digitalWrite(RXLED, HIGH);
delay(1000);
digitalWrite(D, LOW);
digitalWrite(TXLED, LOW);
digitalWrite(RXLED, HIGH);
}
\ No newline at end of file
#define Serial SerialUSB
// Variables setting
int d13_led = 42;
int tx_led = 31;
int rx_led = 30;
int m_led = 36;
// number of ms between led ON and OFF
int ms_delay = 1000;
// the setup function runs once
void setup() {
Serial.begin(9600);
while(!Serial);
Serial.println("CANSAT kit LED test started.");
pinMode(d13_led, OUTPUT);
pinMode(tx_led, OUTPUT);
pinMode(rx_led, OUTPUT);
pinMode(m_led, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(d13_led, HIGH);
digitalWrite(tx_led, HIGH);
digitalWrite(rx_led, HIGH);
digitalWrite(m_led, HIGH);
delay(ms_delay);
digitalWrite(d13_led, LOW);
digitalWrite(tx_led, LOW);
digitalWrite(rx_led, LOW);
digitalWrite(m_led, LOW);
delay(ms_delay);
}
/***************************************************************************
This is a library for the BMP280 humidity, temperature & pressure sensor
Designed specifically to work with the Adafruit BMEP280 Breakout
----> http://www.adafruit.com/products/2651
These sensors use I2C or SPI to communicate, 2 or 4 pins are required
to interface.
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
***************************************************************************/
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP280.h>
#define BMP_SCK 13
#define BMP_MISO 12
#define BMP_MOSI 11
#define BMP_CS 10
Adafruit_BMP280 bme; // I2C
//Adafruit_BMP280 bme(BMP_CS); // hardware SPI
//Adafruit_BMP280 bme(BMP_CS, BMP_MOSI, BMP_MISO, BMP_SCK);
void setup() {
SerialUSB.begin(9600);
SerialUSB.println(F("BMP280 test"));
if (!bme.begin()) {
SerialUSB.println("Could not find a valid BMP280 sensor, check wiring!");
while (1);
}
}
void loop() {
SerialUSB.print("Temperature = ");
SerialUSB.print(bme.readTemperature());
SerialUSB.println(" *C");
SerialUSB.print("Pressure = ");
SerialUSB.print(bme.readPressure());
SerialUSB.println(" Pa");
SerialUSB.print("Approx altitude = ");
SerialUSB.print(bme.readAltitude(1013.25)); // this should be adjusted to your local forcase
SerialUSB.println(" m");
SerialUSB.println();
delay(2000);
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment