0

I can't seem to integrate an nRF module to my nodeMCU. I just want to verify my code but an error message keeps popping up

Below is the sketch:

#include <SPI_Class.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <ESP8266WiFi.h>
#define PIN_CE D4
#define PIN_CSN D3
RF24 radio(PIN_CE, PIN_CSN);

struct package{
  int id = 1;
  int location = 1;
  char timeStamp = "date/time"
};

typedef struct package Package;
Package data;

public int data1=data.id;
public int data2=data.location;
public char data3=data.timeStamp;

byte  address[][6] = "00001"

const char* ssid = "Jino";
const char* pass = "myinternet";

char server[] = "cdgresearch.000webhostapp.com";

WiFiClient client;

int led = 2;

void setup() {
  Serial.begin(9600);
  WiFi.begin(ssid,pass);
  pinMode(led,OUTPUT);
  digitalWrite(led, HIGH);
  delay(500);
  Serial.println("Connecting to: ");
  Serial.println(ssid);
  Serial.print("Connecting");
  while(WiFi.status() != WL_CONNECTED)
  {

    delay(1000);
    Serial.print(".");
  }

  delay(300);
  digitalWrite(led, LOW);
  Serial.println();
  Serial.println("Successfully connected to the network");
  Serial.print("NodeMCU IP Address: ");
  Serial.println(WiFi.localIP());

  delay(1000);

  radio.begin();
  radio.setChannel(115);
  radio.setPALevel(RF24_PA_LOW);
  radio.openWritingPipe(address[0]);
  delay(1000);
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(9000);
  sendData();
}

void sendData(){
  Serial.println("Sending Data...");
  delay(1000);
  if (client.connect(server, 80)){
    WiFi.printDiag(Serial);
    Serial.println("Connected to server");
    client.print("GET /tag2.php?");
    client.print("incoming=Id ");
    client.print(data1);
    client.print("&incoming2=Loc");
    client.print(data2);
    client.println(" HTTP/1.1");
    client.println("Host: cdgresearch.000webhostapp.com");
    client.println("Connection: close");
    client.println();
    Serial.println();

    while(client.connected()){
      while(client.available()){
        Serial.write(client.read());
       }
      }
    radio.write(&data,sizeof(data));

    Serial.print("\nPackage: ");
    Serial.println(data1);
    Serial.print("Location: ")
    Serial.println(data2)
    Serial.println(data3)
    data1+=1;
    data2+=1;
    delay(1000);

  }

  else{
    Serial.println("Failed to Connect to server...");
    }

  client.stop();
  Serial.println("Disconnected from Server");
  while(client.status()!=0){
    delay (10);
   }
  }

and this error comes up in the console: enter image description here

even if I use the #include, still this pops out enter image description here

  • The library you're currently using probably doesn't support ESP8266, try using github.com/nRF24/RF24. Just as a preemptive measure to avoid issues: 1. Make sure you decouple the 3.3V output - an 1000uF electrolytic capacitor - to GND and + to 3.3V. 2. Do not use ribbon cables, duponts should be okay, soldered is best. 3. When in high noise environment (electric motors etc.) also add a ceramic capacitor to the power rail. – Avamander Oct 24 '18 at 9:56
  • The error is because you don't have that library on your computer. Correct? – MichaelT Oct 25 '18 at 13:26
  • @Avamander I edited the post, still, doesn't seem to work – Jeano Duhaylungsod Oct 29 '18 at 15:48
  • @JeanoDuhaylungsod Use only one of the libraries at once. Open Examples->RF24->PingPair and build on that. – Avamander Oct 29 '18 at 22:24
  • You also have to make sure your ESP8266 core is up to date. Boards manager allows you to do that. – Avamander Oct 29 '18 at 22:24
3

Your error is: .../packages/esp8266/hardware/esp8266/2.4.2/libraries/SPI/src/SPI.h:1:23: fatal error: SPI_Class.h: No such file or directory...

You have some wrong SPI library there. The original folder packages/esp8266/hardware/esp8266/2.4.2/libraries/SPI doesn't contain src subfolder.

1

I can confirm that it's possible to connect the two with TMRH20's RF24 library, which seems to be what you are using (judging by the name of the library). I'm currently building something with those very two components.

Instead, the error is that SPI_Class.h can't be found by the IDE. I can't recognize the name either, but if that is from attempting to include SPI to interface with the NRF24L01, you'd want SPI.h instead.

  • I also tried the #include<SPI.h.> but the same error still pops out – Jeano Duhaylungsod Oct 29 '18 at 15:22
  • Was that after removing the SPI_Class library, or was it still present? Also, have you tried with a fresh standalone non-admin install or with odd libraries removed/disabled? – RDragonrydr Oct 30 '18 at 18:25
  • the spi problem's fine now. but is there a way to get in touch with you? I want you're help with my project because you said you're working with similar hardware. If that's ok with you? – Jeano Duhaylungsod Nov 1 '18 at 2:46
  • I'm glad that I or one of us could help, but I haven't actually gotten that far with this yet. I've gotten one of the test sketches that came with the library working, so I know it's possible, but I haven't done anything else yet. Aside from that, it's for a college project (and I have many other classes at the same time), so I need to devote my time to getting that working and I don't have much time to help with another. – RDragonrydr Nov 1 '18 at 15:07
  • I should mention that in my case, it still only works some fraction of the time and tends to crash on me; I think there's some place in the library that tends to hang when using an ESP8266. I'd love to hear about other peoples' experience; it could also be that my chips are counterfeits... – RDragonrydr Nov 6 at 18:28
1

I reinstalled Arduino IDE and the libraries that I need, it works fine now. It must be because someone used my laptop and installed some rfid libraries which caused some problems in the libraries folders.

Not the answer you're looking for? Browse other questions tagged or ask your own question.