Advertisement
    SHARE
    TWEET
    Guest User

    Untitled

    a guest
    Aug 5th, 2013
    507
    0
    Never
    Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
    C++ 1.88 KB | None | 0 0
    1. void setup()
    2. {
    3. //Start communications radio
    4. //Serial.begin(9600);
    5. SPI.begin();
    6. radio.begin();
    7. network.begin(/*channel*/ 90, /*node address*/ this_node);
    8. analogReference(DEFAULT);
    9. //delay(1000);
    10. pinMode(2, INPUT);
    11. //attachInterrupt(0, messageReceived, FALLING);
    12. //Sleep the NRF24L01
    13. //radio.powerDown();
    14. //Sleep the MCU
    15. //LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
    16. }
    17. void(* resetFunc) (void) = 0; //declare reset function @ address 0
    18. void loop()
    19. {
    20. attachInterrupt(0, messageReceived, FALLING);
    21. //radio.powerDown();
    22. LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
    23. //radio.powerUp();
    24. detachInterrupt(0);
    25. network.update();
    26. if(network.available())
    27. {
    28. // If so, grab it and print it out
    29. RF24NetworkHeader header;
    30. payload_t payload;
    31. network.read(header, &payload, sizeof(payload));
    32. //Interrogation de toutes les données
    33. if((payload.value == 0) && (header.from_node == edams_server))
    34. {
    35. int chk = dht22.read22(DHT22_PIN);
    36. if(chk == DHTLIB_OK)
    37. {
    38. dht22_temperature_data_send();
    39. dht22_humidity_data_send();
    40. }
    41. battery_level_send();
    42. }
    43. //Interrogation d'une donnée précise
    44. else if ((payload.value == 1) && (header.from_node == edams_server))
    45. {
    46. if(payload.id == 301 || payload.id == 302)
    47. {
    48. int chk = dht22.read22(DHT22_PIN);
    49. if(chk == DHTLIB_OK)
    50. {
    51. if(payload.id == 301)
    52. dht22_temperature_data_send();
    53. else if(payload.id == 302)
    54. dht22_humidity_data_send();
    55. }
    56. }
    57. else if(payload.id == 303)
    58. {
    59. battery_level_send();
    60. }
    61. }
    62. //Interrogation du firmware du noeud
    63. else if ((payload.value == 9) && (header.from_node == edams_server))
    64. {
    65. }
    66. //resetFunc(); //call reset
    67. }
    68. }
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Advertisement
    Public Pastes
    Advertisement
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /