Advertisement
blastermak

Controllino code

Sep 5th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.78 KB | None | 0 0
  1. #include <HTTPClient.h>
  2.  
  3. #include <processData.h>
  4. #include <Ethernet.h>
  5. #include <Controllino.h>
  6. #include <TimeLib.h>
  7.  
  8. //ETHERNET SETTINGS
  9. #define SERVER_UPDATE_TIMEOUT 5000                     // Send data every x ms
  10. byte ip[] = { 192, 168, 42, 30 };                      // This ip address is coupled to the mac address in the router!
  11. //byte server[] = { 192, 168, 42, 10 };
  12. char server = "192.168.42.25";
  13. byte dnsServer[] = { 8, 8, 8, 8 };
  14. byte gateway[] = { 192, 168, 42, 1 };
  15. byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };   // This mac address is coupled to the ip address in the router!
  16. byte subnet[] = {255,255,255,0};
  17.  
  18. #define TIME_GMTOFFSET -2      // Offset to correct for time
  19.  
  20. EthernetClient client;
  21.  
  22. processData processor = processData(client);
  23.  
  24. void setup() {
  25.   //Serial1 is XBee, connected on pin 18 and 19 on Controllino
  26.   Serial1.begin(115200);  //XBee/UART1/pins 0 and 1
  27.   Serial.begin(115200);   //USB
  28.   Serial.println("Test program for communicating to webserver");
  29.  
  30.   //Initialize ethernet connection on Controllino
  31.   Ethernet.begin(mac, ip);
  32.  
  33.    //RTC
  34.   Controllino_RTC_init(0);                // Initialize RTC pins
  35.   setTime((int)Controllino_GetHour() + TIME_GMTOFFSET,(int)Controllino_GetMinute(), (int)Controllino_GetSecond(), (int)Controllino_GetDay(), (int)Controllino_GetMonth(), (int)Controllino_GetYear()); // setup time library to later generate UNIX timestapm
  36.  
  37. }
  38.  
  39.  
  40.  
  41. void loop() {
  42.   //Check for incoming data from XBee
  43.   while (Serial1.available() > 0) {
  44.     //Logic statement to seperate incoming data
  45.     //from sending XBee with sensors
  46.     processor.storeData( Serial1.readString());
  47. //    String restData = Serial1.readString();
  48.   delay(500);
  49.  
  50.   }//while
  51. //  Serial1.flush();
  52. //  Serial.flush();
  53. //  delay(500);
  54. }//void loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement