Smart-Home am Beispiel der Präsenzerkennung im Raum Projektarbeit Lennart Heimbs, Johannes Krug, Sebastian Dohle und Kevin Holzschuh bei Prof. Oliver Hofmann SS2019
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PHSensor.ino 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * The MySensors Arduino library handles the wireless radio link and protocol
  3. * between your home built sensors/actuators and HA controller of choice.
  4. * The sensors forms a self healing radio network with optional repeaters. Each
  5. * repeater and gateway builds a routing tables in EEPROM which keeps track of the
  6. * network topology allowing messages to be routed to nodes.
  7. *
  8. * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
  9. * Copyright (C) 2013-2018 Sensnology AB
  10. * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
  11. *
  12. * Documentation: http://www.mysensors.org
  13. * Support Forum: http://forum.mysensors.org
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * version 2 as published by the Free Software Foundation.
  18. *
  19. *******************************
  20. *
  21. * REVISION HISTORY
  22. * Version 1.0 - mboyer85
  23. *
  24. * DESCRIPTION
  25. * Example sketch showing how to send PH readings back to the controller
  26. */
  27. // Enable debug prints to serial monitor
  28. //#define MY_DEBUG
  29. // Enable and select radio type attached
  30. #define MY_RADIO_RF24
  31. //#define MY_RADIO_NRF5_ESB
  32. //#define MY_RADIO_RFM69
  33. //#define MY_RADIO_RFM95
  34. #include <MySensors.h>
  35. #define COMPARE_PH 1 // Send PH only if changed? 1 = Yes 0 = No
  36. uint32_t SLEEP_TIME = 60000; // Sleep time between reads (in milliseconds)
  37. float lastPH;
  38. bool receivedConfig = false;
  39. bool metric = true;
  40. // Initialize PH message
  41. MyMessage msg(0, V_PH);
  42. void setup()
  43. {
  44. //Setup your PH sensor here (I2C,Serial,Phidget...)
  45. }
  46. float getPH()
  47. {
  48. //query your PH sensor here (I2C,Serial,Phidget...)
  49. float dummy = 7;
  50. return dummy;
  51. }
  52. void presentation()
  53. {
  54. // Send the sketch version information to the gateway and Controller
  55. sendSketchInfo("PH Sensor", "1.1");
  56. present(0, S_WATER_QUALITY);
  57. }
  58. void loop()
  59. {
  60. float ph = getPH();
  61. #if COMPARE_PH == 1
  62. if (lastPH != ph) {
  63. #endif
  64. // Send in the new PH value
  65. send(msg.set(ph, 1));
  66. // Save new PH value for next compare
  67. lastPH = ph;
  68. #if COMPARE_PH == 1
  69. }
  70. #endif
  71. sleep(SLEEP_TIME);
  72. }