Hello world,
I have been working on this piece of code for the receiving end arduino which is an atmega328p using nRF24L01 transceivers. I had it sending and receiving pieces of data, adding more as I go along with testing inbetween. However, this error started popping up and for the life of me I dont know what it means.I Have no gone into or change anything in the SPI.h library, so I am unsure what might be causing it.
Here is the error message:
Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino Nano, ATmega328P"
In file included from C:\Users\justi\Desktop\BMP280 Receiv Test - Copy\bmp280test\bmp280test.ino:3:0:
C:\Users\justi\Documents\ArduinoData\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src/SPI.h:72:1: error: expected unqualified-id before 'class'
class SPISettings {
^
C:\Users\justi\Documents\ArduinoData\packages\arduino\hardware\avr\1.6.21\libraries\SPI\src/SPI.h:72:1: error: expected constructor, destructor, or type conversion before 'class'
exit status 1
Error compiling for board Arduino Nano.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Here is my code:
*****************************************************
//TRANSCEIVER SETUP
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const uint64_t pipeIn = 0xE8E8F0F0E1LL;
//const NRF24L01_EnableFeatureDynPL();
RF24 radio(9, 10);
struct MyData {
float readTemperature;
float readPressure;
float readAltitude;
float readSatellites;
float readLatitude;
float readLongitude;
//long readDate;
//long readTime;
float readSpeed;
};
MyData data;
void resetData() {
data.readTemperature = 0;
data.readPressure = 0;
data.readAltitude = 0;
data.readSatellites = 0;
data.readLatitude = 0;
data.readLongitude = 0;
// data.readDate = 0;
// data.readTime = 0;
data.readSpeed = 0;
}
//*************************************************
//LCD SETUP
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int button = 8;
boolean state = HIGH;
int reading;
boolean previous;
long time = 0;
long debounce = 200;
void setup() {
Serial.begin(9600);
radio.begin();
// radio.enableDynamicPayloads();
radio.setAutoAck(false);
radio.setDataRate(RF24_250KBPS);
radio.openReadingPipe(1,pipeIn);
radio.startListening();
Serial.println(F("BMP280 test"));
//LCD**********************************************
pinMode(button, INPUT);
lcd.begin(20, 4);
}
void loop() {
Serial.println(F("Waiting to receive"));
resetData();
while ( !radio.available() ) {
// do nothing
}
radio.read(&data, sizeof(MyData));
Serial.print("Temperature = ");
Serial.print(data.readTemperature);
Serial.println(" *C");
Serial.print("Pressure = ");
Serial.print(data.readPressure);
Serial.println(" Pa");
Serial.print("Approx altitude = ");
Serial.print(data.readAltitude);
Serial.println(" m");
Serial.println();
Serial.println(data.readSatellites);
//LCD
Serial.println(state);
reading = digitalRead(button);
if (reading == LOW && previous == HIGH) {
delay(10);
if (digitalRead(button) == LOW) state = !state;
}
previous = reading;
if (state == HIGH) {
lcd.setCursor(0, 0);
lcd.print("Longitude:");
lcd.setCursor(10, 0);
lcd.print(" #########");
lcd.setCursor(0, 1);
lcd.print("Latitude:");
lcd.setCursor(9, 1);
lcd.print(" #########");
lcd.setCursor(0, 2);
lcd.print("Altitude:");
lcd.setCursor(9, 2);
lcd.print(data.readAltitude);
lcd.print("m");
lcd.setCursor(0, 3);
lcd.print("Satellites:");
lcd.setCursor(11, 3);
lcd.print(" #");
}
if (state == LOW) {
lcd.setCursor(0, 0);
lcd.print("Temperature:");
lcd.setCursor(12, 0);
lcd.print(data.readTemperature);
lcd.setCursor(0, 1);
lcd.print("Pressure:");
lcd.setCursor(9, 1);
lcd.print(data.readPressure);
lcd.setCursor(0, 2);
lcd.print("Time:");
lcd.setCursor(5, 2);
lcd.print(" ########");
lcd.setCursor(0, 3);
lcd.print("Date:");
lcd.setCursor(5, 3);
lcd.print(" ##########");
}
}
This was compiling fine until I added the bits about satellite, latitude, longitude, and speed data that is being received from a transmitter. However, I tried removing them and going back to what worked before but the error persists. Any guidance would be appreciated, thank you