So I am trying to recieve data from a nrf24L01 and then display it on monochrome OLED display. The struggle is I am unable to run both things in the same arduino. it seems like its an easy thing to do but I just cant find the answer anywhere.
When I comment out the initialization of the nrf24L01, then my screen is able to update, but when I have the code for the nrf24L01 then the oled screen displays what I had displayed without the nrf24L01 code.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <Wire.h>
#include “U8glib.h”
U8GLIB_SH1106_128X64 u8g(13, 11, 10, 9); // SCK = 13, MOSI = 11, CS = 10, A0 = 9
RF24 radio(8,9); //CE, CSN
const byte node1[6] = “00001”;
//int32_t spo2;
int32_t red[2];
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
// radio.begin(); I am able to draw on the oled when i have commented
// radio.openReadingPipe(0,node1); this section out otherwise it doesnt work!!
// radio.setPALevel(RF24_PA_MIN);
// radio.startListening();
setupscreen();
}
void loop() {
// put your main code here, to run repeatedly:
float t=micros();
// if(radio.available()){
// radio.read(&red,sizeof(red));
// Serial.print(red[0],DEC);
// Serial.print(’ ');
// Serial.println(red[1],DEC);
// }
u8g.firstPage();
do {
draw();
} while( u8g.nextPage() );
while((micros()-t)<10000){}
}
void draw() {
// graphic commands to redraw the complete screen should be placed here
//u8g.setFont(u8g_font_osb21);
u8g.drawStr( 20, 30, “Rd:”);
u8g.drawStr( 20, 50, "IR: ");
u8g.setPrintPos(60,30);
u8g.print(red[0]);
u8g.setPrintPos(60,50);
u8g.print(red[1]);
}
void setupscreen()
{
// flip screen, if required
u8g.setRot180();
u8g.setFont(u8g_font_unifont);
}