Announcement

Collapse
No announcement yet.

Uno Wifi Rev2 issue with script compiling

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Uno Wifi Rev2 issue with script compiling

    I think think is something simple and obvious but when I try to compile the downloaded script for this Uno Wifi Rev2, I get a bunch of errors as follows :

    char* Version = "1.0.0.166";

    ^~~~~~~~~~~

    In file included from C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:27:0:

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp: In function 'void TIMER2_COMPA_vect()':

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:34:36: warning: 'TIMER2_COMPA_vect' appears to be a misspelled 'signal' handler, missing '__vector' prefix [-Wmisspelled-isr]

    #define SOFTPWM_TIMER_INTERRUPT TIMER2_COMPA_vect

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:70:5: note: in expansion of macro 'SOFTPWM_TIMER_INTERRUPT'

    ISR(SOFTPWM_TIMER_INTERRUPT)

    ^~~~~~~~~~~~~~~~~~~~~~~

    In file included from C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:29:0:

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp: In function 'void SoftPWMBegin(uint8_t)':

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:37:3: error: 'TIFR2' was not declared in this scope

    TIFR2 = (1 << TOV2); /* clear interrupt flag */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:37:3: note: suggested alternative: 'TIMERB2'

    TIFR2 = (1 << TOV2); /* clear interrupt flag */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:37:17: error: 'TOV2' was not declared in this scope

    TIFR2 = (1 << TOV2); /* clear interrupt flag */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:37:17: note: suggested alternative: 'TCB2'

    TIFR2 = (1 << TOV2); /* clear interrupt flag */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:38:3: error: 'TCCR2B' was not declared in this scope

    TCCR2B = (1 << CS21); /* start timer (ck/8 prescalar) */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:38:3: note: suggested alternative: 'TCB2'

    TCCR2B = (1 << CS21); /* start timer (ck/8 prescalar) */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:38:18: error: 'CS21' was not declared in this scope

    TCCR2B = (1 << CS21); /* start timer (ck/8 prescalar) */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:39:3: error: 'TCCR2A' was not declared in this scope

    TCCR2A = (1 << WGM21); /* CTC mode */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:39:3: note: suggested alternative: 'TCB2'

    TCCR2A = (1 << WGM21); /* CTC mode */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:39:18: error: 'WGM21' was not declared in this scope

    TCCR2A = (1 << WGM21); /* CTC mode */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:40:3: error: 'OCR2A' was not declared in this scope

    OCR2A = (ocr); /* We want to have at least 30Hz or else it gets choppy */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:41:3: error: 'TIMSK2' was not declared in this scope

    TIMSK2 = (1 << OCIE2A); /* enable timer2 output compare match interrupt */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:41:3: note: suggested alternative: 'TIMERB2'

    TIMSK2 = (1 << OCIE2A); /* enable timer2 output compare match interrupt */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:41:18: error: 'OCIE2A' was not declared in this scope

    TIMSK2 = (1 << OCIE2A); /* enable timer2 output compare match interrupt */ \

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:156:3: note: in expansion of macro 'SOFTPWM_TIMER_INIT'

    SOFTPWM_TIMER_INIT(SOFTPWM_OCR);

    ^~~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp: In function 'void SoftPWMSet(int8_t, uint8_t, uint8_t)':

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:35:37: error: 'TCNT2' was not declared in this scope

    #define SOFTPWM_TIMER_SET(val) (TCNT2 = (val))

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:205:5: note: in expansion of macro 'SOFTPWM_TIMER_SET'

    SOFTPWM_TIMER_SET(0);

    ^~~~~~~~~~~~~~~~~

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM_timer.h:35:37: note: suggested alternative: 'TCB2'

    #define SOFTPWM_TIMER_SET(val) (TCNT2 = (val))

    ^

    C:\Program Files (x86)\Arduino\libraries\SoftPWM\SoftPWM.cpp:205:5: note: in expansion of macro 'SOFTPWM_TIMER_SET'

    SOFTPWM_TIMER_SET(0);

    ^~~~~~~~~~~~~~~~~

    exit status 1
    Error compiling for board Arduino Uno WiFi Rev2.


    Clearly its having issues with the SoftPWM library. I downloaded the library files again and copied them into the folder as I had before, but no change.

    This is a new Uno Wifi Rev2 board. I have compiled and loaded a few other scripts to it and it was fine.

    As I said, I suspect its something stupid/simple......


    #2
    Sorry I missed this post. I have not tried the wifi Uno with this and am not sure if it will work without modification to the sketch after you download it. What board type do you have it set to? Can you post the sketch?
    Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
    X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
    Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
    Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
    Scripts =
    Various

    Comment


      #3
      Here is the sketch.

      I selected "Arduino" and I selected the Uno button

      /********************************************************
      Arduino to Homeseer 3 Plugin written by Enigma Theatre.
      V1.0.0.166 *Beta* *
      *******Do not Change any values below*******************
      */

      //Global Variables
      #define ISIP 0
      #define BoardType 0
      #define Uno 1
      const byte BoardAdd = 4;
      byte Byte1, Byte2, Byte3;
      unsigned int Byte4, Byte5;
      char* Version = "1.0.0.166";
      bool IsConnected = false;
      byte AlivePin = 255;
      unsigned long LastAlive = 0;
      bool WaitForAck = false;
      int Available = 0;
      byte count = 0;
      #define Debug false

      #if BoardType == 2
      int PrevWiFiStatus = 0;
      void resetFunc() {
      #if Debug
      Serial.println(F("Reset"));
      #endif
      ESP.reset();
      }
      #else
      void(* resetFunc) (void) = 0;
      #endif

      //******************************Ethernet Setup*****************************
      #if ISIP == 1

      #if BoardType == 2
      #include <ESP8266WiFi.h>
      #include <WiFiUdp.h>
      #include <ESP8266mDNS.h>
      #include <ArduinoOTA.h>
      char ssid[] = "TALKTALK73651A";
      char pass[] = "44749T8W";
      #else
      #include <SPI.h>
      #include <Ethernet.h>
      #include <EthernetUdp.h>
      #endif



      char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
      byte mac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x04};
      IPAddress ip(192,168,1,7); //IP entered In HS config.
      const unsigned int localPort = 8903; //port entered In HS config.
      IPAddress HomeseerIP(192,168,1,3); //Homeseer IP address
      IPAddress gateway(192,168,1,1);
      IPAddress subnet(255,255,255,0);

      #if BoardType == 2
      WiFiUDP Udp;
      WiFiUDP SendPort;
      #else
      EthernetUDP Udp;
      #endif

      void UDPCheck() {


      Available = Udp.parsePacket();;
      if (Available)
      {





      #if BoardType == 2

      if (Udp.remoteIP() != HomeseerIP) {
      HomeseerIP = Udp.remoteIP();
      }
      Byte1 = Udp.parseInt();
      Udp.read();
      Byte2 = Udp.read();
      Udp.read();
      Byte3 = Udp.parseInt();
      Udp.read();
      Byte4 = Udp.parseInt();
      Udp.read();
      Byte5 = Udp.parseInt();
      DataEvent();
      #else
      if (Udp.remoteIP() != HomeseerIP) {
      HomeseerIP = Udp.remoteIP();
      }
      Byte1 = Udp.parseInt();
      Udp.read();
      Byte2 = Udp.read();
      Byte3 = Udp.parseInt();;
      Byte4 = Udp.parseInt();
      Byte5 = Udp.parseInt();;
      DataEvent();
      #endif
      }
      }
      #endif



      //********************************Input Setup*******************************
      unsigned int debounceDelay = 30;
      byte NoOfInPins = 0;
      #if Uno == 1
      byte InPinArray[20] = { 255 };
      unsigned long lastDebounceTime [20] = { 0 };
      bool lastButtonState [20] = {LOW};
      bool buttonState[20] = {LOW};
      #else
      byte InPinArray[40] = { 255 };
      unsigned long lastDebounceTime [40] = { 0 };
      bool lastButtonState [40] = {LOW};
      bool buttonState[40] = {LOW};
      #endif
      static byte InputCount = 0;
      //********************************Input Setup*******************************

      void InputCheck() {

      if (InputCount >= NoOfInPins ) {
      InputCount = 0;
      }

      if (InPinArray[InputCount] < 255) {

      if (millis() < lastDebounceTime[InputCount]) {
      lastDebounceTime[InputCount] = millis();
      }

      bool Inputpinread = (digitalRead(InPinArray[InputCount]));

      if (Inputpinread != lastButtonState[InputCount]) {
      lastDebounceTime[InputCount] = millis();
      }

      if ((millis() - lastDebounceTime[InputCount]) > debounceDelay) {


      if (Inputpinread != buttonState[InputCount]) {
      buttonState[InputCount] = Inputpinread;
      lastDebounceTime[InputCount] = millis();
      Send(String(BoardAdd));
      Send(F(" I "));
      Send(String(InputCount + 1));
      Send(F(" "));
      Send(String(Inputpinread));
      Send();
      }
      }

      lastButtonState[InputCount] = Inputpinread;
      }
      InputCount++;

      }

      //*******************************Output toggle/flash****************************

      byte OutputCount = 0;
      #if Uno == 1
      unsigned long previousOutMillis[15] = {0};
      unsigned int OutputFlash[15] = { 0 };
      bool OutputState[15] = {LOW};
      byte OutPinArray[15] = { 255 };
      word OutputMillis[15];
      #else
      unsigned long previousOutMillis[40] = {0};
      unsigned int OutputFlash[40] = { 0 };
      bool OutputState[40] = {LOW};
      byte OutPinArray[40] = { 255 };
      word OutputMillis[40];
      #endif

      void OutputCheck() {

      if (millis() < previousOutMillis[OutputCount]) { // we wrapped around, lets just try again
      previousOutMillis[OutputCount] = millis();
      }

      if (previousOutMillis[OutputCount] + OutputMillis[OutputCount] < millis() ) {
      previousOutMillis[OutputCount] = millis();

      if (OutPinArray[OutputCount] < 255 ) {
      // if the Output is off turn it on and vice-versa

      digitalWrite(OutPinArray[OutputCount], !OutputState[OutputCount]);
      OutputState[OutputCount] = !OutputState[OutputCount];

      if (OutputFlash[OutputCount] == 1) {
      OutputFlash[OutputCount] = 0;
      OutPinArray[OutputCount] = 255;
      previousOutMillis[OutputCount] = 0;
      }

      }
      }


      OutputCount++;

      #if Uno == 1
      if (OutputCount == 20 ) {
      OutputCount = 0;
      }
      #else
      if (OutputCount == 40 ) {
      OutputCount = 0;
      }
      #endif

      return;
      }





      //*******************************Analogue Setup****************************
      //#if Uno == 1
      //byte AnalogPinArray[5] = {255};
      //unsigned int AnalogStateArray[5];
      //unsigned long PrevAnalogeMillis[5];
      // int AnalogDelay[10];
      //#else
      byte AnalogPinArray[10] = {255};
      unsigned int AnalogStateArray[10];
      unsigned long PrevAnalogeMillis[10];
      unsigned int AnalogDelay[10] = {0};
      //#endif
      word AnalogInvert = 0;
      byte NoOfAnalogPins = 0;
      unsigned int AnalogueCount = 0;


      void AnalogCheck() {

      if (AnalogueCount >= NoOfAnalogPins) {
      AnalogueCount = 0;
      }

      if (AnalogPinArray[AnalogueCount] < 255) {


      if (millis() < PrevAnalogeMillis[AnalogueCount]) { // we wrapped around, lets just try again
      PrevAnalogeMillis[AnalogueCount] = millis();
      }

      if (AnalogDelay[AnalogueCount] + PrevAnalogeMillis[AnalogueCount] < millis()) {
      PrevAnalogeMillis[AnalogueCount] = millis();
      int pinread;
      pinread = analogRead(AnalogPinArray[AnalogueCount]);

      if (AnalogStateArray[AnalogueCount] != pinread) {
      AnalogStateArray[AnalogueCount] = pinread;
      Send(String(BoardAdd));
      Send(F(" A "));
      Send(String(AnalogueCount + 1));
      Send(F(" "));
      if (bitRead(AnalogInvert, AnalogueCount) == 1) {
      Send(String(map(AnalogStateArray[AnalogueCount], 0, 1023, 1023, 0)));
      Send();
      WaitForAck = true;
      }
      else {
      Send(String(AnalogStateArray[AnalogueCount]));
      Send();
      WaitForAck = true;
      }
      }
      #if Debug
      Serial.print(F("AnalogueCount = "));
      Serial.print(AnalogueCount);
      Serial.print(F(", NoOfAnalogPins = "));
      Serial.print(NoOfAnalogPins);


      Serial.print(F(", PrevAnalogeMillis[AnalogueCount] = "));
      Serial.print(PrevAnalogeMillis[AnalogueCount]);
      Serial.print(F(", AnalogPinArray[AnalogueCount] = "));
      Serial.print(AnalogPinArray[AnalogueCount]);
      Serial.print(F(", AnalogDelay[AnalogueCount] = "));
      Serial.println(AnalogDelay[AnalogueCount]);
      #endif
      }
      }

      AnalogueCount++;

      return;
      }


      //*****************************PWM Setup****************************
      #if BoardType == 0
      #include <SoftPWM.h>
      #endif



      //*****************************Servo Setup***************************
      #include <Servo.h>
      unsigned long lastServoMove = 0;
      bool ServoActive = false;
      Servo myservo[6];

      //
      void ServoCheck() {


      if (800 + lastServoMove < millis() && ServoActive == true) {
      for (int i = 0; i < 6; i++) {
      myservo[i].detach();
      }
      ServoActive = false;
      }
      }

      //***************************One Wire Setup**************************
      #include <OneWire.h>
      #include <DallasTemperature.h>
      byte OneWirePin = 255;
      byte TEMPERATURE_PRECISION = 9;
      DeviceAddress tempDeviceAddress;
      unsigned long lastTempRequest = 0;
      bool waitingForTempsGlobal = false;
      float Temps[15] = {0};
      unsigned long lastUpdated[15] = {0};
      bool OWStartup = false;

      void OneWireCheck() {

      if (OneWirePin < 255) {

      OneWire oneWire(OneWirePin);
      DallasTemperature sensors(&oneWire);

      if (OWStartup == false && millis() - lastTempRequest > 10000) {

      #if Debug
      Serial.print(F("OneWire Setup run with pin "));
      Serial.println(OneWirePin);
      #endif

      sensors.setResolution(TEMPERATURE_PRECISION);
      sensors.setWaitForConversion(false);
      if (sensors.isParasitePowerMode()) {
      sensors.setCheckForConversion(true);
      }
      OWStartup = true;
      }

      if (waitingForTempsGlobal && lastTempRequest + 1000 < millis() ) {
      sensors.begin();

      #if Debug
      Serial.println(F("conversionDelay passed"));
      #endif


      for (int i = 0; i < sensors.getDeviceCount(); i++) {


      if (millis() < lastUpdated[i]) { // we wrapped around, lets just try again
      lastUpdated[i] = millis();
      }

      sensors.getAddress(tempDeviceAddress, i);
      float Temp = sensors.getTempC(tempDeviceAddress);



      #if Debug
      Serial.print(F("Device count = "));
      Serial.print(String(sensors.getDeviceCount()));
      Serial.print(F(", Device = "));
      Serial.print(String(tempDeviceAddress[i]));
      Serial.print(F(", sensors.getTempC = "));
      Serial.println(Temp);
      #endif

      if ((Temps[i] != Temp && sensors.validAddress(tempDeviceAddress)) || ( millis() - lastUpdated[i] >= 60000 && sensors.validAddress(tempDeviceAddress))) {
      Temps[i] = Temp;
      Send(String(BoardAdd));
      Send(F(" Rom "));
      for (uint8_t i = 0; i < 8; i++)
      {
      if (tempDeviceAddress[i] < 16) Send("0");
      Send(String(tempDeviceAddress[i]));
      }
      Send(F(" "));
      Send(String(Temp));
      Send();
      lastUpdated[i] = millis();
      //WaitForAck = true;
      }
      }
      waitingForTempsGlobal = false;
      }
      if (!waitingForTempsGlobal && millis() - lastTempRequest > 15000) {
      lastTempRequest = millis();
      waitingForTempsGlobal = true;

      sensors.requestTemperatures();
      #if Debug
      Serial.println(F("Requesting Temperatures"));
      #endif

      }
      }
      }
      //************************************************************ ******************




      #include <LiquidCrystal_I2C.h>

      LiquidCrystal_I2C lcd(0x27, 4, 20);
      bool LCDInit = false;



      //**********************************Alive Check***********************************

      void AliveCheck() {

      if ( millis() - LastAlive < 40000 && IsConnected == true) { //if connected and data recieved within 40sec set Alive pin High.
      if (AlivePin < 255 ) {
      digitalWrite(AlivePin, HIGH);
      }
      }
      else if (millis() - LastAlive > 60000 && millis() - LastAlive < 60005 && IsConnected == true) { //if connected but no data recieved for 81sec reset Ack.
      WaitForAck = false;
      if (LCDInit == true ) {
      lcd.clear();
      lcd.setCursor(2, 1);
      lcd.print(F("Connection Error"));
      }
      Send(F("Alive "));
      Send(String(BoardAdd));
      Send();
      }

      else {
      if (AlivePin < 255 && millis() - LastAlive > 81000 && millis() - LastAlive < 81005) {
      if (LCDInit == true) {
      lcd.clear();
      lcd.setCursor(2, 1);
      lcd.print(F("Connection Failed"));
      }
      Send(F("Connect "));
      Send(String(BoardAdd));
      Send();

      digitalWrite(AlivePin, LOW);
      }
      }

      if (millis() - LastAlive > 90000 && IsConnected == true) { //if connected but no data recieved for 90sec reset the board.
      if (LCDInit == true) {
      lcd.setCursor(6, 2);
      lcd.print(F("Reseting"));
      delay(1000);
      }
      resetFunc();
      }
      }


      //************************************************************ ******************
      bool UdpSend = false;

      //**********************************Send Data***********************************


      void Send(const String& Data)
      {
      #if ISIP == 0
      Serial.print(Data);
      #else
      if (UdpSend == false) {
      UdpSend = true;
      Udp.beginPacket(HomeseerIP, 8888);
      Udp.print(Data);
      }
      else {
      Udp.print(Data);
      }
      #if Debug
      Serial.print(Data);//debug
      #endif
      #endif
      }

      void Send()
      {
      #if ISIP == 0
      Serial.println();
      #else
      Udp.endPacket();
      UdpSend = false;
      #if Debug
      Serial.print(F(", Sent to "));//debug
      Serial.println(HomeseerIP);//debug
      #endif
      #endif

      }


      //*****************************Data Input********************************
      /*

      Used Data Input Cases
      D Disconnect
      r reset
      F PWM Fade Time Set
      P PWM State Set
      K Keepalive
      W OneWire Pin Set
      p PinMode set PWM
      a PinMode AnalogInverted Set
      A PinMode Analog Input Set
      H PinMode Alive
      h acknowledge Data
      I PinMode Digital Input Set
      L Lcd Display Data
      l Lcd Backlight control
      O PinMode Output Set
      d Input debounceDelay time set
      S Servo set Pos
      s PinMode Servo set
      C Connect request
      c Connection established - reUdp current status
      X Board PinMode Reset
      */

      void DataEvent() {

      if (Byte1 == BoardAdd) {

      LastAlive = millis();//Reset the Alive timer if board Data recieved
      #if Debug
      Serial.print(Byte2);//debug
      Serial.print(",");
      Serial.print(Byte3);
      Serial.print(",");
      Serial.print(Byte4);
      Serial.print(",");
      Serial.println(Byte5);
      #endif

      switch (Byte2) {

      case 'X':
      #if Debug
      Serial.println(F("Pin Reset Recieved"));
      #endif
      NoOfInPins = 0;
      NoOfAnalogPins = 0;
      OneWirePin = 255;
      break;

      case 'c':
      #if Debug
      Serial.println(F("Sending Pin Values"));
      Serial.print(F("NoOfInPins = "));
      Serial.println(NoOfInPins);
      #endif

      byte pinread;
      for (count = 0; count < NoOfInPins; count++) {
      pinread = digitalRead(InPinArray[count]);
      Send(String(BoardAdd));
      Send(F(" I "));
      Send(String(count + 1));
      Send(F(" "));
      Send(String(pinread));
      Send();
      lastButtonState[count] = pinread;
      }

      #if Debug
      Serial.println(F("IsConnected = true"));
      #endif
      IsConnected = true;
      break;

      case 'C':
      #if Debug
      Serial.println(F("Recieved C"));
      #endif
      if (LCDInit == true) {
      lcd.clear();
      lcd.setCursor(5, 0);
      lcd.print(F("Board No:"));
      lcd.print(BoardAdd);
      lcd.setCursor(5, 1);
      lcd.print(F("V"));
      lcd.setCursor(5, 1);
      lcd.print(Version);
      lcd.setCursor(5, 2);
      lcd.print(F("Connecting"));
      lcd.setCursor(0, 3);
      lcd.print(F(" HS "));
      #if ISIP
      lcd.print(Udp.remoteIP());
      #endif
      // delay(2000);
      }
      #if Debug
      Serial.println(F("Sending Version"));
      #endif
      Send(F("Version "));
      Send(String(BoardAdd));
      Send(F(" "));
      Send(String(Version));
      Send(F(" HS3"));
      Send();
      delay(1000);
      #if Debug
      Serial.println(F("Sending Connected"));
      #endif
      Send(F("Connected "));
      Send(String(BoardAdd));
      Send();
      // delay(100);
      IsConnected = false;
      if (LCDInit == true) {
      lcd.setCursor(5, 2);
      lcd.print(F("Connected "));
      // delay(1000);
      // lcd.clear();
      }
      break;

      case 'S':
      myservo[Byte3 - 1].attach(Byte4);
      myservo[Byte3 - 1].write(Byte5);
      lastServoMove = millis();
      ServoActive = true;
      #if Debug
      Serial.print(F("Servo No:"));
      Serial.print(Byte3);
      Serial.print(F(", Pin No:"));
      Serial.print(Byte4);
      Serial.print(F(", Set to "));
      Serial.println(Byte5);
      #endif
      break;


      case 'd':
      #if Debug
      Serial.println(F("debounceDelay Setup recieved"));
      #endif
      debounceDelay = Byte4;
      break;

      case 'l':


      if (LCDInit == false) {
      #if Debug
      Serial.println(F("LCD int display"));
      #endif
      lcd.init(); // initialize the lcd
      lcd.init();
      LCDInit = true;
      lcd.backlight();
      lcd.clear();
      lcd.setCursor(5, 0);
      lcd.print(F("Board No:"));
      lcd.print(BoardAdd);
      lcd.setCursor(5, 1);
      lcd.print(F("V"));
      lcd.setCursor(5, 1);
      lcd.print(Version);
      lcd.setCursor(2, 2);
      lcd.print(F("Initializing LCD"));
      // delay(3000);
      // lcd.clear();

      }
      if (Byte3 == 0) {
      lcd.noBacklight();
      }
      if (Byte3 == 1) {
      lcd.backlight();
      }
      if (Byte3 == 2) {
      lcd.clear();
      }
      break;

      case 'L':
      #if Debug
      Serial.println(F("LCD Value update"));
      #endif
      if (LCDInit == false) {
      lcd.init(); // initialize the lcd
      lcd.init();
      LCDInit = true;
      }
      lcd.setCursor(0, Byte3 - 1);

      #if ISIP == 1
      Udp.read();
      Available = (Available - 9);
      for (count = 1; count < Available ; count++) {
      lcd.write(Udp.read());
      }
      #else

      Serial.read();
      Available = (Available - 11);
      for (count = 1; count < Available ; count++) {
      lcd.write(Serial.read());
      }
      #endif

      break;


      case 'o':

      //Change state , one flash
      pinMode(Byte3, OUTPUT);
      digitalWrite(Byte3, !OutputState[Byte5 - 1]);
      previousOutMillis[Byte5 - 1] = millis();

      OutputMillis[Byte5 - 1] = Byte4;
      OutPinArray[Byte5 - 1] = Byte3;
      OutputFlash[Byte5 - 1] = 1;
      OutputState[Byte5 - 1] = !OutputState[Byte5 - 1];
      #if Debug
      Serial.println(F("One flash Recieved"));//debug
      Serial.print(F("Values"));
      Serial.print(F(", OutPinArray = "));
      Serial.print(Byte3);
      Serial.print(F(", OutputMillis = "));
      Serial.print(Byte4);
      Serial.print(F(", Index = "));
      Serial.println(Byte5);
      #endif
      break;

      case 'O':

      pinMode(Byte3, OUTPUT);

      if (Byte4 > 1) {//Blink
      #if Debug
      Serial.println(F("Blink Recieved"));//debug
      Serial.print(F("Values"));
      Serial.print(F(", OutPinArray = "));
      Serial.print(Byte3);
      Serial.print(F(", OutputMillis = "));
      Serial.print(Byte4);
      Serial.print(F(", Index = "));
      Serial.println(Byte5);
      #endif

      digitalWrite(Byte3, !OutputState[Byte5 - 1]);
      OutputState[Byte5 - 1] = !OutputState[Byte5 - 1];
      previousOutMillis[Byte5 - 1] = millis();
      OutPinArray[Byte5 - 1] = Byte3;
      OutputMillis[Byte5 - 1] = Byte4;
      OutputFlash[Byte5 - 1] = 0;

      }
      else
      { //Toggle

      Serial.println(F("Output Change state or Toggle Recieved"));//debug
      Serial.print(F("Values"));
      Serial.print(F(", Pin = "));
      Serial.print(Byte3);
      Serial.print(F(", Value = "));
      Serial.print(Byte4);
      Serial.print(F(", Index = "));
      Serial.println(Byte5);


      digitalWrite(Byte3, Byte4);
      OutPinArray[Byte5 - 1] = 255;
      OutputFlash[Byte5 - 1] = 0;
      previousOutMillis[Byte5 - 1] = 0;
      OutputState[Byte5 - 1] = Byte4;
      }

      break;

      case 'H':
      #if Debug
      Serial.println(F("Alive Pin Setup Recieved"));
      #endif
      pinMode(Byte3, OUTPUT);
      AlivePin = Byte3;
      break;

      case 'h':
      WaitForAck = false;
      break;

      case 'I':
      #if Debug
      Serial.print(F("Input Pin Setup"));
      Serial.print(F(", Byte3 = "));
      Serial.print(Byte3);
      Serial.print(F(", Pin = "));
      Serial.print(Byte4);
      #endif

      pinMode(Byte4, INPUT_PULLUP);

      if (Byte3 > NoOfInPins) {
      NoOfInPins = Byte3;
      Serial.print(F(", NoOfInPins set to = "));
      Serial.print(Byte3);
      }
      InPinArray[Byte3 - 1] = Byte4;
      #if Debug
      Serial.print(F(", NoOfInPins = "));
      Serial.println(NoOfInPins);
      #endif
      break;

      case 'A':
      #if Debug
      Serial.println(F("Analog Setup Recieved"));
      Serial.print(F("Byte5 = "));
      Serial.println(Byte5);
      #endif
      pinMode(Byte4, INPUT);
      if (Byte3 > NoOfAnalogPins) {
      NoOfAnalogPins = Byte3;
      }
      AnalogDelay[Byte3 - 1] = Byte5;
      AnalogPinArray[Byte3 - 1] = Byte4;
      PrevAnalogeMillis[Byte3 - 1] = 0;
      break;

      case 'a':
      #if Debug
      Serial.println(F("Analog Setup Value Recieved"));
      #endif
      bitWrite(AnalogInvert, Byte3 - 1, Byte4);
      break;


      case 'W':
      #if Debug
      Serial.println(F("Onewire Setup Recieved"));
      #endif
      if (OneWirePin != Byte3) {
      OneWirePin = Byte3;
      lastTempRequest = millis() - 30000;
      }
      if (TEMPERATURE_PRECISION != Byte4) {
      TEMPERATURE_PRECISION = Byte4;
      #if Debug
      Serial.print(F("TEMPERATURE_PRECISION = "));
      Serial.println(TEMPERATURE_PRECISION);
      #endif
      }

      break;

      case 'K':
      #if Debug
      Serial.println(F("Keep Alive Recieved"));
      #endif
      Send(F("Alive "));
      Send(String(BoardAdd));
      Send();

      break;

      #if BoardType == 0

      case 'P':
      SoftPWMSet(Byte3, Byte4);
      #if Debug
      Serial.print(F("PWM Value Set = "));//debug
      Serial.print(Byte4);
      Serial.print(F(", Pin = "));
      Serial.println(Byte3);
      #endif

      break;

      case 'F':
      SoftPWMSetFadeTime(Byte3, Byte4, Byte4);
      #if Debug
      Serial.print(F("PWM Time Set = "));//debug
      Serial.print(Byte4);
      Serial.print(F(", Pin = "));
      Serial.println(Byte3);
      #endif
      break;
      #endif
      case 'r':
      if (LCDInit == true) {
      lcd.clear();
      lcd.setCursor(6, 1);
      lcd.print(F("Reseting"));
      }
      delay(200);
      resetFunc();
      break;

      case 'D':
      #if Debug
      Serial.println(F("Disconnect Recieved"));
      #endif
      IsConnected = false;
      if (LCDInit == true) {
      lcd.clear();
      lcd.setCursor(4, 1);
      lcd.print(F("Disconnected"));
      }
      if (AlivePin < 255 ) {
      digitalWrite(AlivePin, LOW );
      }
      break;

      }
      }
      }

      #if ISIP == 0
      //*****************************Serial Event*********************************
      void serialEvent() {
      while (Serial.available() > 0) {
      delay(17);
      Available = Serial.available();
      Byte1 = Serial.parseInt();
      Serial.read();
      Byte2 = Serial.read();
      Byte3 = Serial.parseInt();
      Byte4 = Serial.parseInt();
      Byte5 = Serial.parseInt();
      DataEvent();
      }
      }
      #endif


      //*****************************Setup Void*********************************
      void setup() {
      #if Debug
      Serial.begin(115200);
      Serial.println("debug Start......");//debug
      #endif

      #if BoardType == 2
      PrevWiFiStatus = 0;
      #else
      SoftPWMBegin();
      #endif

      #if ISIP == 1

      #if BoardType == 2
      WiFi.begin(ssid, pass);
      WiFi.config(ip, gateway, subnet);
      OTA();
      WiFi.mode(WIFI_STA);

      while (WiFi.status() != WL_CONNECTED) {
      delay(500);
      }

      WiFiStatus();

      #else

      Ethernet.begin(mac, ip, gateway, gateway, subnet);

      #endif

      Udp.begin(localPort);
      Udp.setTimeout(0);

      #else
      Serial.begin(115200);
      Serial.flush();
      Serial.setTimeout(0);
      #endif

      //#############Reset Varibles########



      //Reset Inputs
      NoOfInPins = 0;
      for (count = 0; count < (sizeof(InPinArray) / sizeof(InPinArray[0])); count++) {
      InPinArray[count] = 255;
      lastDebounceTime [count] = 0;
      lastButtonState [count] = LOW;
      buttonState[count] = LOW;
      }

      //Reset Outputs
      for (count = 0; count < (sizeof(OutPinArray) / sizeof(OutPinArray[0])); count++) {
      previousOutMillis[count] = 0;
      OutputFlash[count] = 0;
      OutputState[count] = LOW;
      OutPinArray[count] = 255;
      OutputMillis[count] = 0;
      }

      //Reset Analog
      NoOfAnalogPins = 0;
      AnalogueCount = 0;
      for (count = 0; count < (sizeof(AnalogPinArray) / sizeof(AnalogPinArray[0])); count++) {
      AnalogPinArray[count] = 255;
      AnalogStateArray[count] = 0;
      PrevAnalogeMillis[count] = 0;
      AnalogDelay[count] = 0;
      }

      //Reset Onewire
      OneWirePin = 255;


      delay(1500);
      IsConnected = false;
      Send(F("Connect "));
      Send(String(BoardAdd));
      Send();

      }
      //*******************************OTA Update*************************
      void OTA() {
      #if BoardType == 2
      char OTAName[50];
      sprintf(OTAName, "Homeseer Board:%02i", BoardAdd );
      ArduinoOTA.setHostname(OTAName);
      ArduinoOTA.onStart([]() {
      if (LCDInit == true) {
      lcd.clear();
      lcd.setCursor(5, 0);
      lcd.print(F("Performing"));
      lcd.setCursor(5, 1);
      lcd.print(F("OTA Update"));
      }

      });
      ArduinoOTA.onEnd([]() {
      if (LCDInit == true) {
      delay(1000);
      lcd.clear();
      lcd.setCursor(5, 0);
      lcd.print(F("OTA Update"));
      lcd.setCursor(6, 1);
      lcd.print(F("Complete"));
      lcd.setCursor(3, 3);
      lcd.print(F("Please Wait..."));
      }
      delay(1000);

      });
      ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
      if (LCDInit == true) {
      lcd.setCursor(4, 3);
      lcd.print(F("Progress:"));
      lcd.setCursor(13, 3);
      lcd.print(progress / (total / 100));
      lcd.print(F("%"));
      }
      });
      ArduinoOTA.onError([](ota_error_t error) {
      Serial.printf("Error[%u]: ", error);
      if (LCDInit == true) {
      lcd.clear();
      lcd.setCursor(5, 0);
      lcd.print(F("OTA Error:"));
      lcd.setCursor(5, 1);

      if (error == OTA_AUTH_ERROR) lcd.print(F("Auth Failed"));
      else if (error == OTA_BEGIN_ERROR) lcd.print(F("Begin Failed"));
      else if (error == OTA_CONNECT_ERROR) lcd.print(F("Connect Failed"));
      else if (error == OTA_RECEIVE_ERROR) lcd.print(F("Receive Failed"));
      else if (error == OTA_END_ERROR) lcd.print(F("End Failed"));
      }
      }
      );

      ArduinoOTA.begin();
      #endif
      }

      #if BoardType == 2
      void WiFiStatus() {

      if (PrevWiFiStatus - 10 > WiFi.RSSI() || PrevWiFiStatus + 10 < WiFi.RSSI()) {
      Send(F("WiFi "));
      Send(String(BoardAdd));
      Send(" ");
      Send(String(WiFi.RSSI()));
      Send();
      PrevWiFiStatus = WiFi.RSSI();
      }
      }
      #endif


      //*****************************Loop Void*********************************
      void loop() {
      #if ISIP == 1
      UDPCheck();
      #if BoardType == 2
      ArduinoOTA.handle();
      #endif
      #endif
      AliveCheck();

      if (IsConnected == true)
      {

      #if BoardType == 2
      WiFiStatus();
      #endif

      InputCheck();
      OutputCheck();
      AnalogCheck();
      OneWireCheck();

      #if BoardType == 0
      ServoCheck();
      #endif



      }
      yield();
      }


      //****************************************End***************** *********************************

      Comment


        #4
        OK, it compiles here for Uno and Unowifi. Are you trying to connect it with wifi or USB? I have not used that board and I think it needs special libraries for the wifi.
        Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
        X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
        Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
        Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
        Scripts =
        Various

        Comment


          #5
          I'm connecting using USB.

          Comment


            #6
            Did you ever get the Uno Wifi Rev 2 working?

            Thanks,
            Robert

            Comment


              #7
              The problem seems to be with the WIFI drivers being different than that on the the regular UNO. Did you get a chance to take a look, this is a nice simple board that would be great for attached monitoring. Please advise if you plan to write the routines for the Arduino Uno Wifi Rev. 2

              Comment

              Working...
              X