Announcement

Collapse
No announcement yet.

ESP8266 - Proof of Concept

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

  • #61
    Originally posted by FernandoSolanes View Post
    OK I deleted all my libraries and put in just the ones from the plugin and still gets stuck at the LCD..
    I put a few other LCD Libraries using the Manager and it gives me a diffrent error. But definitely with just the libraries from the Plug in and the default sample it gets stuck..

    thanks for all your help...


    WARNING: library LiquidCrystal_I2C claims to run on [avr] architecture(s) and may be incompatible with your current board which runs on [esp8266] architecture(s).
    "/Users/fsolanes/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9-2/bin/xtensa-lx106-elf-g++" -D__ets__ -DICACHE_FLASH -U__STRICT_ANSI__ "-I/Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/tools/sdk/include" "-I/Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/tools/sdk/lwip/include" -c -w -Os -g -mlongcalls -mtext-section-literals -fno-exceptions -fno-rtti -falign-functions=4 -std=c++11 -ffunction-sections -fdata-sections -w -x c++ -E -CC -DF_CPU=80000000L -DARDUINO=10608 -DARDUINO_ESP8266_NODEMCU -DARDUINO_ARCH_ESP8266 -DESP8266 "-I/Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/cores/esp8266" "-I/Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/variants/nodemcu" "-I/Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/EEPROM" "-I/Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/ESP8266WiFi/src" "-I/Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/Servo/src" "-I/Users/fsolanes/Documents/Arduino/libraries/OneWire" "-I/Users/fsolanes/Documents/Arduino/libraries/DallasTemperature" "-I/Users/fsolanes/Documents/Arduino/libraries/LiquidCrystal_I2C" "-I/Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/Wire" "/var/folders/v4/m607qq692kn8s8hg5_bcdmx80000gn/T/build4a26ceb702810316fbd4f3e63b126dc2.tmp/sketch/Homeseer.ino.cpp" -o "/var/folders/v4/m607qq692kn8s8hg5_bcdmx80000gn/T/build4a26ceb702810316fbd4f3e63b126dc2.tmp/preproc/ctags_target_for_gcc_minus_e.cpp"
    In file included from /Users/fsolanes/Downloads/Homeseer/Homeseer.ino:188:0:
    /Users/fsolanes/Documents/Arduino/libraries/OneWire/OneWire.h:77:2: error: #error "Please define I/O register types here"
    #error "Please define I/O register types here"
    ^
    Using library LiquidCrystal_I2C at version 1.1.2 in folder: /Users/fsolanes/Documents/Arduino/libraries/LiquidCrystal_I2C
    Using library Wire at version 1.0 in folder: /Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/Wire
    Using library EEPROM at version 1.0 in folder: /Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/EEPROM
    Using library ESP8266WiFi at version 1.0 in folder: /Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/ESP8266WiFi
    Using library Servo at version 1.0.2 in folder: /Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/Servo
    Using library OneWire in folder: /Users/fsolanes/Documents/Arduino/libraries/OneWire (legacy)
    Using library DallasTemperature in folder: /Users/fsolanes/Documents/Arduino/libraries/DallasTemperature (legacy)
    exit status 1
    Error compiling for board NodeMCU 1.0 (ESP-12E Module).
    Looks like it's happy with LCD now. You need to update the OneWire library via the Arduino Library manager(old version doesn't support ESP8266). Confusing I know... If I get a chance i'll try to put together a better guide.

    Comment


    • #62
      Originally posted by FernandoSolanes View Post
      I have a simple project pasted together that works with my Arduino. now I'm trying to convert it to work with Lolin NodeMCU ESP just like the one pictured.
      I tried your example but cant get it to compile i tried several different ways removing what I don't think i need but just keep making a mess of it.. below is my working code for Arduino. is there a simple explanation to get this to work for the ESP? I don't need any serial all i want is to connect a DHT22 and send it to HomeSeer.

      Thank you

      Code:
      //For serial set to 0 and for Ethernet set to 1 
      #define ISIP 1 
      
      //Do NOT modify these 
      #if ISIP == 1 
      #include <EEPROM.h> 
      #include <SPI.h>        
      #include <Ethernet.h> 
      #include <EthernetUdp.h>  
      #endif 
      /************************************************************ 
       *Arduino to Homeseer 3 Plugin API writen by Enigma Theatre.* 
       * V1.0.0.36                                                * 
       *                                                          * 
       *******Change the values below only************************* 
       */ 
      
      //Address of the board. 
      const byte BoardAdd = 1; 
      
      #if ISIP == 1 
      // Enter a MAC address and IP address for your board below. 
      byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; 
      
      // The IP address will be dependent on your local network. 
      IPAddress ip(192,168,1,177);     //IP entered in HS config. 
      const unsigned int localPort = 8080;      //port entered in HS config. 
      IPAddress HomeseerIP(192,168,1,15); //Homeseer IP address 
      IPAddress ServerIP(EEPROM.read(2),EEPROM.read(3),EEPROM.read(4),EEPROM.read(5)); 
      byte EEpromVersion = EEPROM.read(250); 
      #endif 
      
      //************Do not change anything in Here***************** 
      int FromHS[10];                                          // * 
      boolean IsConnected = false;                             // * 
      #if ISIP == 1                                            // * 
      char packetBuffer[UDP_TX_PACKET_MAX_SIZE];               // * 
      EthernetUDP Udp;                                         // * 
      const unsigned int ServerPort = 8888;                    // * 
      #endif                                                   // * 
      void(* resetFunc) (void) = 0;                            // * 
      //*********************************************************** 
      
      #include "DHT.h" 
      #define DHTPIN 2     // what pin we're connected to 
      // Uncomment whatever type you're using! 
      //#define DHTTYPE DHT11   // DHT 11  
      #define DHTTYPE DHT22   // DHT 22  (AM2302) 
      //#define DHTTYPE DHT21   // DHT 21 (AM2301) 
      
      DHT dht(DHTPIN, DHTTYPE); 
      
      int SendDelay = 3000; 
      long LastSend; 
      
      void setup() { 
        HSSetup(); 
        //************************ 
        //Add YOUR SETUP HERE; 
        //************************ 
      
      
      dht.begin(); 
      
      } 
      
      void loop() { 
      #if ISIP == 1 
        IsUDP(); 
      #endif 
      
          //************************ 
          //Add YOUR CODE HERE; 
          //************************ 
          /* To Send Data to Homeseer use SendToHS(Device,Value) 
           Eg.. SendToHS(1,200); where 1 is the API device in homeseer and 200 is the value to send 
           To Recieve data from Homeseer look up the FromHS array that is updated when the device value changes. 
           Eg.. FromHS[5] would be the data from API Output device 5 
           All code that is located just below this block will execute regardless of connection status! 
           You can include SendToHS() calls, however when there isn't an active connection, it will just return and continue. 
           If you only want code to execute when HomeSeer is connected, put it inside the if statement below. 
           */ 
      
      /*Execute regardless of connection status*/ 
      
      
       if (IsConnected == true) { 
          
          
          if(millis() - LastSend > SendDelay){ 
             
         SendToHS(1,dht.readHumidity()); 
         SendToHS(2,dht.readTemperature()); 
          
          LastSend=millis(); 
          } 
          
          
         /*Execute ONLY when HomeSeer is connected*/ 
      
        } 
      } 
      
      
      
      const char* Version = "API1.0.0.36"; 
      
      byte Byte1,Byte2,Byte3; 
      int Byte4,Byte5; 
      
      
      void HSSetup() { 
      
      #if ISIP == 1 
          if (EEpromVersion!=22) { 
          ServerIP=HomeseerIP; 
          EEPROM.write(2,ServerIP[0]); 
          EEPROM.write(3,ServerIP[1]); 
          EEPROM.write(4,ServerIP[2]); 
          EEPROM.write(5,ServerIP[3]); 
          EEPROM.write(250,22); //Store the version where the eeprom data layout was last changed 
          EEpromVersion=22; 
        } 
      Ethernet.begin(mac,ip); 
        Udp.begin(localPort); 
        Udp.setTimeout(0); 
        delay(1000); 
      SendConnect(); 
      #else 
        Serial.begin(115200); 
        Serial.flush(); 
        Serial.setTimeout(0); 
        delay(1000); 
        Serial.print("Connect "); 
        Serial.println(BoardAdd); 
      #endif 
      
        IsConnected = false; 
      
      } 
      
      void SendConnect() 
      { 
      #if ISIP == 0 
        Serial.print("Connect "); 
        Serial.println(BoardAdd); 
      #else 
          Udp.beginPacket(ServerIP,ServerPort);  //First send a connect packet to the dynamic IP stored in eeprom 
          Udp.print("Connect "); 
          Udp.print(BoardAdd); 
          Udp.endPacket(); 
          if (ServerIP!=HomeseerIP) { 
            Udp.beginPacket(HomeseerIP,ServerPort);  //Then if the stored value doesn't match the pre-specified one, send a connect packet there also 
            Udp.print("Connect "); 
            Udp.print(BoardAdd); 
            Udp.endPacket(); 
          } 
        
      #endif 
      } 
      
      
      #if ISIP == 1 
      void IsUDP(){ 
        int packetSize = Udp.parsePacket(); 
        if(packetSize) 
        { 
          IPAddress remote = Udp.remoteIP(); 
          Byte1 =Udp.parseInt(); 
          Udp.read();  
          Byte2 =Udp.read();  
          Byte3 =Udp.parseInt(); 
          Byte4 =Udp.parseInt(); 
          Byte5 =Udp.parseInt(); 
          DataEvent(); 
        } 
      } 
      
      #else 
      void serialEvent() { 
        while (Serial.available() > 0) { 
          delay(17); 
      
      
          Byte1 = Serial.parseInt(); 
          Serial.read();   
          Byte2 = Serial.read();  
          Byte3 = Serial.parseInt(); 
          Byte4 = Serial.parseInt(); 
          Byte5 = Serial.parseInt(); 
          DataEvent(); 
        } 
      } 
      #endif 
      
      /* 
      
      Used Data Input Cases 
      D Disconnect 
      r reset 
      K Keepalive 
      O PinMode Output Set 
      d Input debounce time set 
      C Connect request 
      c Connection established - report current status 
      */ 
      void DataEvent() { 
      
        if (Byte1 == BoardAdd) { 
          switch (Byte2) { 
      
          case 'c': 
            IsConnected = true; 
      #if ISIP == 1 
            if (Udp.remoteIP() != ServerIP) { 
              ServerIP=Udp.remoteIP(); 
              EEPROM.write(2,ServerIP[0]); 
              EEPROM.write(3,ServerIP[1]); 
              EEPROM.write(4,ServerIP[2]); 
              EEPROM.write(5,ServerIP[3]); 
            }      
      #endif 
      
            break; 
      
          case 'C':    
      #if ISIP == 1 
            Udp.beginPacket(Udp.remoteIP(), ServerPort); 
            Udp.print("Version "); 
            Udp.print(BoardAdd); 
            Udp.print(" "); 
            Udp.print(Version); 
            Udp.println(" HS3"); 
            Udp.endPacket(); 
      
            Udp.beginPacket(Udp.remoteIP(), ServerPort); 
            delay(100); 
            Udp.print("Connected "); 
            Udp.println(BoardAdd); 
            Udp.endPacket(); 
      #else 
            Serial.print("Version "); 
            Serial.print(BoardAdd); 
            Serial.print(" "); 
            Serial.print(Version); 
            Serial.println(" HS3");  
            delay(100); 
            Serial.print("Connected "); 
            Serial.println(BoardAdd); 
      #endif 
            delay(100); 
            IsConnected = false; 
            break; 
      
          case 'K': 
            delay(200); 
      #if ISIP == 1 
            Udp.beginPacket(Udp.remoteIP(), ServerPort); 
            Udp.print("Alive "); 
            Udp.println(BoardAdd); 
            Udp.endPacket(); 
            if (Udp.remoteIP() != ServerIP) { 
              ServerIP=Udp.remoteIP(); 
              EEPROM.write(2,ServerIP[0]); 
              EEPROM.write(3,ServerIP[1]); 
              EEPROM.write(4,ServerIP[2]); 
              EEPROM.write(5,ServerIP[3]); 
            }      
      #else      
            Serial.print("Alive "); 
            Serial.println(BoardAdd); 
      #endif 
            break;  
             
            case 'r': 
            delay(200); 
            resetFunc();  //call reset 
            break;  
      
          case 'O': 
            FromHS[Byte3] = Byte4; 
            break;  
      
          case 'D': 
            IsConnected = false; 
            break;    
          } 
        } 
      } 
      
      void SendToHS(byte Device, long Data){ 
      if (IsConnected == true) { 
      #if ISIP == 1 
        Udp.beginPacket(Udp.remoteIP(), ServerPort); 
        Udp.print(BoardAdd); 
        Udp.print(" API "); 
        Udp.print(Device); 
        Udp.print(" "); 
        Udp.print(Data); 
        Udp.endPacket(); 
      #else 
        Serial.print(BoardAdd); 
        Serial.print(" API "); 
        Serial.print(Device); 
        Serial.print(" "); 
        Serial.println(Data); 
      #endif 
      } 
      }

      See attached.
      I don't have any DHT sensors handy so I couldn't test it, but it compiles.
      If you keep getting WDT resets, make sure your read the earlier posts, you need to make a change to the ESP8266 library, until a new version is released with the bug fixed.

      Again, like the original example this is just a crude mod. It's still on my TODO list to clean it up a bit.
      Attached Files

      Comment


      • #63
        Originally posted by AllanMar View Post
        Have you had the serial console open? Need to confirm if the board is crashing/resetting or if it's just a comms problem.

        Should probably add some serial debug messages.
        I'm away from the house for 2 weeks, will check it out when I get back..

        Sent from my Nexus 7 using Tapatalk
        HS 2.2.0.11

        Comment


        • #64
          Thank you Allan, I tried your code and it does compile
          I am getting the WDT reset as you suspected so I will look to see how that gets fixed..
          Thank you again

          Comment


          • #65
            Hi Allan, or others that may have done the fix. So I looked for that char peek() in the UdpContext.h file to fix the reboot loop and I can't seem to find it. I assume I'm looking in the right place (my libraries folder)..
            Last edited by FernandoSolanes; May 2nd, 2016, 04:15 PM.

            Comment


            • #66
              Originally posted by FernandoSolanes View Post
              Hi Allan, or others that may have done the fix. So I looked for that char peek() in the UdpContext.h file to fix the reboot loop and I can seem to find it. I assume I'm looking in the right place (my libraries folder)..
              Yep I have the same problem and could not find it. The new IDE uses multiple locations for the libraries. I gave up looking the last time I had time so need more info and I will have another go when I get a moment.

              Greig.
              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


              • #67
                Originally posted by FernandoSolanes View Post
                Hi Allan, or others that may have done the fix. So I looked for that char peek() in the UdpContext.h file to fix the reboot loop and I can't seem to find it. I assume I'm looking in the right place (my libraries folder)..
                From the logs you posted before:
                Using library ESP8266WiFi at version 1.0 in folder: /Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/ESP8266WiFi

                so:
                /Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/ESP8266WiFi/src/include/UdpContext.h

                I'd suggest changing it from char to int (that is the official fix coming):
                https://github.com/esp8266/Arduino/c...dde63b42fa38ed

                Comment


                • #68
                  Originally posted by enigmatheatre View Post
                  Yep I have the same problem and could not find it. The new IDE uses multiple locations for the libraries. I gave up looking the last time I had time so need more info and I will have another go when I get a moment.

                  Greig.
                  Check the compile logs, or do a file search?

                  Comment


                  • #69
                    If I do a search for the file i find it, but when I look for the lines to change they are not in the file...I know i must be doing something wrong...could you pm me the modified file and tell me where I should copy it too?

                    Comment


                    • #70
                      Originally posted by FernandoSolanes View Post
                      If I do a search for the file i find it, but when I look for the lines to change they are not in the file...I know i must be doing something wrong...could you pm me the modified file and tell me where I should copy it too?
                      You can find it here:
                      https://raw.githubusercontent.com/es...e/UdpContext.h

                      Put it where i mentioned in the previous post.

                      Comment


                      • #71
                        ok downloaded and put it in..
                        /libraries/ESP8266WIFI/src/include/UdpContect.h

                        Complied and loaded but still reboot loop. I assume this file is already patched? I tried to look at it but cant find any line that says char peek() anything?

                        Comment


                        • #72
                          That file is, yes. When you copied it it overwrote the original?

                          Comment


                          • #73
                            I completely removed IDE and all the old libraries. did a fresh install. downloaded from the plugin the new libraries. Added the ESP8266 so it appears as a programable option on IDE, download the fresh 8266Wifi complied and load and still no go

                            here is the IDE Log and below that the Serial reboot loop..got teamviewer if you'd like to take a look

                            Multiple libraries were found for "ESP8266WiFi.h"
                            Used: /Users/fsolanes/Documents/Arduino/libraries/ESP8266WiFi
                            Not used: /Users/fsolanes/Library/Arduino15/packages/esp8266/hardware/esp8266/2.2.0/libraries/ESP8266WiFi

                            Sketch uses 230,840 bytes (53%) of program storage space. Maximum is 434,160 bytes.
                            Global variables use 32,147 bytes (39%) of dynamic memory, leaving 49,773 bytes for local variables. Maximum is 81,920 bytes.
                            Uploading 234992 bytes from to flash at 0x00000000
                            ............................................................ ............................................................ ............................................................ .................................................Invalid library found in /Users/fsolanes/Documents/Arduino/libraries/UdpBytewise: /Users/fsolanes/Documents/Arduino/libraries/UdpBytewise
                            Invalid library found in /Users/fsolanes/Documents/Arduino/libraries/UdpBytewise: /Users/fsolanes/Documents/Arduino/libraries/UdpBytewise
                            .


                            Soft WDT reset

                            ctx: cont
                            sp: 3ffefae0 end: 3ffefd50 offset: 01b0

                            >>>stack>>>
                            3ffefc90: 000022b8 3ffeeb3c 3ffeeaec 40201cd2
                            3ffefca0: 3ffe85d0 0f01a8c0 3ffeeaec 402037dc
                            3ffefcb0: 402010ae 000003e8 3ffeeaec 40203822
                            3ffefcc0: 00000001 3ffeeaec 3ffeeaec 40203861
                            3ffefcd0: 0000002d 00000000 00000064 40203bd8
                            3ffefce0: 3ffe85d0 00ffffff 3ffe85d0 3ffeed28
                            3ffefcf0: 3fffdad0 00000000 3ffeeaec 402038d0
                            3ffefd00: 3fffdad0 00000000 3ffeeaec 40202152
                            3ffefd10: 3ffe85d0 0f01a8c0 feefeffe 3ffeed28
                            3ffefd20: 00000000 00000000 3ffeed20 40202196
                            3ffefd30: 3fffdad0 00000000 3ffeed20 40203bac
                            3ffefd40: feefeffe feefeffe 3ffeed30 40100718
                            <<<stack<<<

                            ets Jan 8 2013,rst cause:2, boot mode3,6)

                            load 0x4010f000, len 1264, room 16
                            tail 0
                            chksum 0x0f
                            csum 0x0f
                            ~ld

                            Comment


                            • #74
                              Where did you put the file after you reinstalled?

                              Comment


                              • #75
                                full path:
                                /Users/fsolanes/Documents/Arduino/libraries/ESP8266WiFi/src/include/UdpContext.h

                                Comment

                                Working...
                                X