Guest User

Untitled

a guest
Nov 7th, 2014
138
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <nRF905.h>
  2. #include <SPI.h>
  3.  
  4. #define TIMEOUT 1000 // 1 second ping timeout
  5.  
  6. void setup()
  7. {
  8.     // Start up
  9.     nRF905_init();
  10.  
  11.     // Put into receive mode
  12.     nRF905_receive();
  13.  
  14.     Serial.begin(9600);
  15.    
  16.     Serial.println(F("Client started"));
  17. }
  18.  
  19. void loop()
  20. {
  21.     // Make data
  22.     byte data[NRF905_MAX_PAYLOAD];
  23.  
  24.     float temp_c = sht1x.readTemperatureC();
  25.     float temp_f = sht1x.readTemperatureF();
  26.     float humidity = sht1x.readHumidity();
  27.  
  28.     // Copy data to buffer
  29.     memcpy(data, &temp_c, sizeof(float));
  30.     memcpy(data + sizeof(float), &temp_f, sizeof(float));
  31.     memcpy(data + (sizeof(float) * 2), &humidity, sizeof(float));
  32.  
  33.     // Set payload data
  34.     nRF905_setData(data, sizeof(data));
  35.  
  36.     // Send payload (send fails if other transmissions are going on, keep trying until success)
  37.     while(!nRF905_send());
  38.  
  39.     // Put into receive mode
  40.     nRF905_receive();
  41.  
  42.     delay(1000);
  43. }
RAW Paste Data