//NRF24L01_DS18S20_RX_Temperature_Teensy3.2
#include <SPI.h> // Comes with Arduino IDE
#include <RF24.h> // Download and Install (See above)
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
RF24 myRadio (9, 10); // "myRadio" is the identifier you will use in following methods
byte addresses[][6] = {"1Node"}; // Create address for 1 pipe.
float dataReceived; // Data that will be received from the transmitter
float temperature;
void setup() /****** SETUP: RUNS ONCE ******/
{
display.begin(SSD1306_SWITCHCAPVCC, 0x3c); // initialize with the I2C addr 0x3C (for the 128x64)
Serial.begin(115200);
delay(1000);
myRadio.begin(); // Start up the physical nRF24L01 Radio
myRadio.setChannel(108); // Above most Wifi Channels
myRadio.setPALevel(RF24_PA_MAX); // Uncomment for more power
myRadio.setDataRate(RF24_250KBPS); // Fast enough.. Better range
myRadio.openReadingPipe(1, addresses[0]); // Use the first entry in array 'addresses' (Only 1 right now)
myRadio.startListening();
}
void loop(){
if ( myRadio.available()) // Check for incoming data from transmitter
{
{
myRadio.read( &dataReceived, sizeof(dataReceived) ); // Get the data payload (You must have defined that already!)
temperature = dataReceived;
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(20, 0);
display.println("Temperature");
display.setCursor(20, 7);
display.println("in degrees C");
display.setTextSize(1);
display.setCursor(40, 20);
display.println(temperature);
display.display();
}
}