/*
qbcan CanSat example.
This sketch reads temperature and pressure data and sends it to the Ground station
*/
//Include the required libraries
#include <qbcan.h>
#include <Wire.h>
#include <SPI.h>
//Pressure sensor object
BMP180 bmp;
//Radio Parameters
#define NODEID 2 //unique for each node on same network
#define NETWORKID 100 //the same on all nodes that talk to each other
#define GATEWAYID 1 //Receiving node
#define ENCRYPTKEY "sampleEncryptKey" //exactly the same 16 characters/bytes on all nodes!
const TempGradient = -0,0065;
const StartPressure = 1019;
const StartTemp = 283,15;
const StartAltitude = 10;
const GasConstant = 287,06;
const GravAcceleration = 9,81;
//Radio object
char payload[50];
RFM69 radio;
void setup()
{
//Initialize serial connection for debugging
Serial.begin(9600);
Serial.println("REBOOT");
// Initialize pressure sensor.
if (bmp.begin())
Serial.println("BMP180 init success");
else
{
//In case of error let user know of the problem
Serial.println("BMP180 init fail (disconnected?)\n\n");
while(1); // Pause forever.
}
//Initialize radio
radio.initialize(FREQUENCY,NODEID,NETWORKID);
radio.setHighPower(); //To use the high power capabilities of the RFM69HW
radio.encrypt(ENCRYPTKEY);
Serial.println("Transmitting at 433 Mhz");
}
void loop()
{
double T,P;
// Get a new pressure reading:
bmp.getData(T,P);
long Temp = (T,2);
long Pressure = (P,2);
//Display data
Serial.print("Absolute pressure: ");
Serial.print(P,2);
Serial.println(" mb.");
Serial.print("Temperature: ");
Serial.print(T,2);
Serial.println(" deg C.");
// Calculate Altitude
Altitude = (StartTemp/TempGradient)*(pow((Pressure/StartPressure),(-TempGradient*GasConstant/GravAcceleration))-1)+ StartAltitude
// Display Altitude
Serial.print("Altitude: ");
Serial.print(Altitude);
Serial.println(" meters high");
//Send Data
sprintf(payload,"T: %d C, P: %d mb.",(int)T,(int)P);
Serial.println(payload);
radio.send(GATEWAYID, payload, 50);
Serial.println("Send complete");
delay(500);
}
There are the following errors:
Arduino: 1.8.1 (Windows 10), Board:"SparkFun Pro Micro, ATmega32U4 (5V, 16 MHz)"
CanSat_-_With_Altitude_V1:22: error: 'TempGradient' does not name a type
const TempGradient = -0,0065;
^
CanSat_-_With_Altitude_V1:23: error: 'StartPressure' does not name a type
const StartPressure = 1019;
^
CanSat_-_With_Altitude_V1:24: error: 'StartTemp' does not name a type
const StartTemp = 283,15;
^
CanSat_-_With_Altitude_V1:25: error: 'StartAltitude' does not name a type
const StartAltitude = 10;
^
CanSat_-_With_Altitude_V1:26: error: 'GasConstant' does not name a type
const GasConstant = 287,06;
^
CanSat_-_With_Altitude_V1:27: error: 'GravAcceleration' does not name a type
const GravAcceleration = 9,81;
^
C:\Users\Lars\Desktop\Cansat\Code\CanSat_-_With_Altitude_V1\CanSat_-_With_Altitude_V1.ino: In function 'void loop()':
CanSat_-_With_Altitude_V1:77: error: 'Altitude' was not declared in this scope
Altitude = (StartTemp/TempGradient)*(pow((Pressure/StartPressure),(-TempGradient*GasConstant/GravAcceleration))-1)+ StartAltitude
^
CanSat_-_With_Altitude_V1:77: error: 'StartTemp' was not declared in this scope
Altitude = (StartTemp/TempGradient)*(pow((Pressure/StartPressure),(-TempGradient*GasConstant/GravAcceleration))-1)+ StartAltitude
^
CanSat_-_With_Altitude_V1:77: error: 'TempGradient' was not declared in this scope
Altitude = (StartTemp/TempGradient)*(pow((Pressure/StartPressure),(-TempGradient*GasConstant/GravAcceleration))-1)+ StartAltitude
^
CanSat_-_With_Altitude_V1:77: error: 'StartPressure' was not declared in this scope
Altitude = (StartTemp/TempGradient)*(pow((Pressure/StartPressure),(-TempGradient*GasConstant/GravAcceleration))-1)+ StartAltitude
^
CanSat_-_With_Altitude_V1:77: error: 'GasConstant' was not declared in this scope
Altitude = (StartTemp/TempGradient)*(pow((Pressure/StartPressure),(-TempGradient*GasConstant/GravAcceleration))-1)+ StartAltitude
^
CanSat_-_With_Altitude_V1:77: error: 'GravAcceleration' was not declared in this scope
Altitude = (StartTemp/TempGradient)*(pow((Pressure/StartPressure),(-TempGradient*GasConstant/GravAcceleration))-1)+ StartAltitude
^
CanSat_-_With_Altitude_V1:77: error: 'StartAltitude' was not declared in this scope
Altitude = (StartTemp/TempGradient)*(pow((Pressure/StartPressure),(-TempGradient*GasConstant/GravAcceleration))-1)+ StartAltitude
^
exit status 1
'TempGradient' does not name a type
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I don't understand why the constants don't work and why the Altitude calculation doesn't also.
Please help, I don't know people irl who understand Arduino.