Arduino / ESP8266 Switch mit fhem steuern

Begonnen von mainframe, 28 März 2017, 09:59:41

Vorheriges Thema - Nächstes Thema

mainframe

Hallo,

Ich habe mir das Teil hier aufgebaut und die Steuerung funktioniert mit einem  W5100 und einem ESP8266.
http://bildr.org/2011/06/arduino-ethernet-pin-control/
Im Blog seht ihr das der Befehl in der URL Adressliste abgesetzte wird
(http://192.168.1.167/?2)
Wie kann ich das jetzt per fhem steuern.
Im Netz habe ich nicht viel darüber gefunden. Gibt es irgendwo eine Anleitung wie man das ganze Konfiguriert.
Da ich nicht der fhem spezialist bin suche ich deshalb hier mal nach Hilfe.

Danke im vorraus.

MadMax-FHEM

Es gibt bereits viele Umsetzungen mit ESP8266 und fhem.

Schon mal nach ESP8266 im Forum gesucht?
Mit google nach ESP8266 und fhem gesucht?

Per Ethernetanbindung (wenn ich das richtig überflogen hab) kenne ich keine...
...will aber nicht heißen, dass es keine gibt... ;)

Sorry, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

Beta-User

Arduino+Ethernet-shield=(z.B.) firmata, also zu.ein anderer sketch.

Mobile Grüsse
Server: HP-elitedesk@Debian 12, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: MiLight@ESP-GW, BT@OpenMQTTGw | MySensors: seriell, v.a. 2.3.1@RS485 | ZWave | ZigBee@deCONZ | SIGNALduino | MapleCUN | RHASSPY
svn: u.a MySensors, Weekday-&RandomTimer, Twilight,  div. attrTemplate-files

Thorsten Pferdekaemper

Hi,
ich mache so etwas ähnliches einfach so:

HttpUtils_NonblockingGet({
     url=>sprintf("http://192.168.178.41/atsettmp%.0f", $atf),
     atf=>$atf,
     callback=>sub($$$){ Log 3,"atsettmp $_[0]->{atf} ERR:$_[1] DATA:$_[2]" } });

Das ganze natürlich in eine Funktion in 99_myUtils.pm verpackt.
Gruß,
    Thorsten
FUIP

mainframe

Ich habe mal das mit dem wiki für HTTPMOD verwendet, und ich bekomme am fhem folgenden eintrag:

https://wiki.fhem.de/wiki/HTTPMOD#Simple_Configuration_of_HTTP_Devices

Das ist der Eintrag in die fhem.cfg:

define ESP8266 HTTPMOD none 0
attr ESP8266 set01IMap 0:off, 1:on
attr ESP8266 set01Name Licht1
attr ESP8266 set01URL http://192.168.2.253/switcha=$val
attr ESP8266 set02IMap 0:off, 1:on
attr ESP8266 set02Name Licht2
attr ESP8266 set02URL http://192.168.2.253/switchb=$val

Im fhem web sieht das ganze dann so aus, jedoch ist der Eintrag als Unsorted eingetragen.

Schalten kann ich das ganze jetzt aber ohne Probleme. Wie mache ich jetzt daraus einen Schalter der nicht mehr im Unsorted erscheint.



Das ganze

Frank_Huber

meine Empfehlung: ESPEasy. gibt es als Modul, Ausgänge können direkt mit "Set "DEVICE" ......" gesetzt werden.

mainframe

Danke für das ESPEasy, nur: Es geht nicht. Wenn ich den Source in Ardiuino einbinde und das nach der Anleitung,geht es beim Compilieren schon los, compiler fehler. Wenn ich das bin image direkt Flashen will , geht nicht. Und genau das ist es was mich davon abhält sowas zu nutzen.

/Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino: In function 'void setup()':
ESPEasy:626: error: 'FreeMem' was not declared in this scope
   lowestRAM = FreeMem();
                       ^
ESPEasy:630: error: 'initLog' was not declared in this scope
   initLog();
           ^
ESPEasy:633: error: 'SpiffsSectors' was not declared in this scope
   if (SpiffsSectors() < 32)
                     ^
ESPEasy:640: error: 'emergencyReset' was not declared in this scope
   emergencyReset();
                  ^
ESPEasy:644: error: 'addLog' was not declared in this scope
   addLog(LOG_LEVEL_INFO, log);
                             ^
ESPEasy:646: error: 'fileSystemCheck' was not declared in this scope
   fileSystemCheck();
                   ^
ESPEasy:647: error: 'LoadSettings' was not declared in this scope
   LoadSettings();
                ^
ESPEasy:665: error: 'ResetFactory' was not declared in this scope
     ResetFactory();
                  ^
ESPEasy:672: error: 'BuildFixes' was not declared in this scope
     BuildFixes();
                ^
ESPEasy:682: error: 'hardwareInit' was not declared in this scope
   hardwareInit();
                ^
ESPEasy:685: error: 'WifiAPconfig' was not declared in this scope
   WifiAPconfig();
                ^
ESPEasy:686: error: 'WifiConnect' was not declared in this scope
   if (!WifiConnect(true,3))
                          ^
ESPEasy:701: error: 'PluginInit' was not declared in this scope
   PluginInit();
              ^
ESPEasy:702: error: 'CPluginInit' was not declared in this scope
   CPluginInit();
               ^
ESPEasy:703: error: 'NPluginInit' was not declared in this scope
   NPluginInit();
               ^
ESPEasy:705: error: 'WebServerInit' was not declared in this scope
   WebServerInit();
                 ^
ESPEasy:716: error: 'getProtocolIndex' was not declared in this scope
   byte ProtocolIndex = getProtocolIndex(Settings.Protocol[0]);
                                                             ^
ESPEasy:718: error: 'MQTTConnect' was not declared in this scope
     MQTTConnect();
                 ^
ESPEasy:720: error: 'sendSysInfoUDP' was not declared in this scope
   sendSysInfoUDP(3);
                   ^
ESPEasy:723: error: 'readFromRTC' was not declared in this scope
   if (readFromRTC())
                   ^
ESPEasy:725: error: 'readUserVarFromRTC' was not declared in this scope
     readUserVarFromRTC();
                        ^
ESPEasy:742: error: 'saveToRTC' was not declared in this scope
     saveToRTC();
               ^
ESPEasy:754: error: 'initTime' was not declared in this scope
     initTime();
              ^
ESPEasy:769: error: 'rulesProcessing' was not declared in this scope
     rulesProcessing(event);
                          ^
ESPEasy:773: error: 'saveToRTC' was not declared in this scope
   saveToRTC();
             ^
/Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino: In function 'void loop()':
ESPEasy:788: error: 'WifiConnect' was not declared in this scope
     WifiConnect(true,1);
                       ^
ESPEasy:794: error: 'PluginCall' was not declared in this scope
       if (!PluginCall(PLUGIN_SERIAL_IN, 0, dummyString))
                                                       ^
ESPEasy:795: error: 'serial' was not declared in this scope
         serial();
                ^
ESPEasy:804: error: 'deepSleep' was not declared in this scope
       deepSleep(Settings.Delay);
                               ^
/Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino: In function 'void run50TimesPerSecond()':
ESPEasy:836: error: 'PluginCall' was not declared in this scope
   PluginCall(PLUGIN_FIFTY_PER_SECOND, 0, dummyString);
                                                     ^
/Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino: In function 'void run10TimesPerSecond()':
ESPEasy:846: error: 'PluginCall' was not declared in this scope
   PluginCall(PLUGIN_TEN_PER_SECOND, 0, dummyString);
                                                   ^
ESPEasy:847: error: 'checkUDP' was not declared in this scope
   checkUDP();
            ^
ESPEasy:850: error: 'rulesProcessing' was not declared in this scope
     rulesProcessing(eventBuffer);
                                ^
/Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino: In function 'void runOncePerSecond()':
ESPEasy:866: error: 'saveToRTC' was not declared in this scope
     saveToRTC();
               ^
ESPEasy:869: error: 'addLog' was not declared in this scope
     addLog(LOG_LEVEL_INFO, log);
                               ^
ESPEasy:878: error: 'delayedReboot' was not declared in this scope
       delayedReboot(60);
                       ^
ESPEasy:886: error: 'WifiDisconnect' was not declared in this scope
           WifiDisconnect();
                          ^
ESPEasy:900: error: 'checkTime' was not declared in this scope
     checkTime();
               ^
ESPEasy:903: error: 'PluginCall' was not declared in this scope
   PluginCall(PLUGIN_ONCE_A_SECOND, 0, dummyString);
                                                  ^
ESPEasy:908: error: 'rulesTimers' was not declared in this scope
     rulesTimers();
                 ^
/Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino: In function 'void runEach30Seconds()':
ESPEasy:946: error: 'FreeMem' was not declared in this scope
   sprintf_P(str, PSTR("Uptime %u ConnectFailures %u FreeMem %u"), wdcounter / 2, connectionFailures, FreeMem());
                                                                                                              ^
ESPEasy:949: error: 'addLog' was not declared in this scope
   addLog(LOG_LEVEL_INFO, log);
                             ^
ESPEasy:950: error: 'sendSysInfoUDP' was not declared in this scope
   sendSysInfoUDP(1);
                   ^
ESPEasy:951: error: 'refreshNodeList' was not declared in this scope
   refreshNodeList();
                   ^
ESPEasy:952: error: 'MQTTCheck' was not declared in this scope
   MQTTCheck();
             ^
ESPEasy:954: error: 'SSDP_update' was not declared in this scope
     SSDP_update();
                 ^
ESPEasy:963: error: 'WifiCheck' was not declared in this scope
   WifiCheck();
             ^
/Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino: In function 'void checkSensors()':
ESPEasy:987: error: 'saveUserVarToRTC' was not declared in this scope
   saveUserVarToRTC();
                    ^
/Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino: In function 'void SensorSendTask(byte)':
ESPEasy:1013: error: 'getDeviceIndex' was not declared in this scope
     byte DeviceIndex = getDeviceIndex(Settings.TaskDeviceNumber[TaskIndex]);
                                                                           ^
ESPEasy:1014: error: 'LoadTaskSettings' was not declared in this scope
     LoadTaskSettings(TaskIndex);
                               ^
ESPEasy:1027: error: 'PluginCall' was not declared in this scope
       success = PluginCall(PLUGIN_READ, &TempEvent, dummyString);
                                                                ^
ESPEasy:1044: error: 'Calculate' was not declared in this scope
           byte error = Calculate(formula.c_str(), &result);
                                                          ^
ESPEasy:1049: error: 'sendData' was not declared in this scope
       sendData(&TempEvent);
                          ^
/Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino: In function 'boolean checkSystemTimers()':
ESPEasy:1114: error: 'timeOut' was not declared in this scope
       if (timeOut(systemTimers
  • .timer))
                                            ^
    ESPEasy:1129: error: 'timeOut' was not declared in this scope
           if (timeOut(systemCMDTimers
  • .timer))
                                               ^
    ESPEasy:1132: error: 'parseCommandString' was not declared in this scope
             parseCommandString(&TempEvent, systemCMDTimers
  • .action);
                                                                     ^
    ESPEasy:1133: error: 'PluginCall' was not declared in this scope
             if (!PluginCall(PLUGIN_WRITE, &TempEvent, systemCMDTimers
  • .action))
                                                                                ^
    ESPEasy:1134: error: 'ExecuteCommand' was not declared in this scope
               ExecuteCommand(VALUE_SOURCE_SYSTEM, systemCMDTimers
  • .action.c_str());
                                                                                    ^
    /Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino: In function 'void backgroundtasks()':
    ESPEasy:1152: error: 'statusLED' was not declared in this scope
       statusLED(false);
                      ^
    ESPEasy:1153: error: 'checkUDP' was not declared in this scope
       checkUDP();
                ^
    Mehrere Bibliotheken wurden für "PubSubClient.h" gefunden
    Benutzt: /Volumes/User/sven/Documents/ArduinoScetch/libraries/pubsubclient
    Nicht benutzt: /Volumes/User/sven/Documents/ArduinoScetch/libraries/pubsubclient-2.6
    Mehrere Bibliotheken wurden für "Servo.h" gefunden
    Benutzt: /Volumes/User/sven/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/Servo
    Nicht benutzt: /Volumes/User/sven/Programme/Development/Arduino.app/Contents/Java/libraries/Servo
    Mehrere Bibliotheken wurden für "SD.h" gefunden
    Benutzt: /Volumes/User/sven/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/libraries/SD
    Nicht benutzt: /Volumes/User/sven/Programme/Development/Arduino.app/Contents/Java/libraries/SD
    exit status 1
    'FreeMem' was not declared in this scope
    Ungültige Bibliothek /Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy in /Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy gefunden
    Ungültige Bibliothek /Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy_v2.0.0-dev7 in /Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy_v2.0.0-dev7 gefunden

Frank_Huber

Ich hab die fertigen images genommen.
Nur flashen,
Die  Relais Ausgänge als Input Switch device angelegt.
Kamen dann automatisch in fhem rein.
Musste nur den presence Check ausmachen.

mainframe

Genau das versuche ich auch gerade verzweifelt, und so wie es aussieht kann ich es nicht auf Wemos D1 flashen. Im Serial Terminal kommt immer die Fehlermeldung Wrong PID.....
Ich habe es mit allen Images die ich habe Probiert.

Frank_Huber

Dateiname vom Image?
Welche Parameter gibst beim flashen über das Script ein?
Da passt was nicht zusammen.

dev0

Zitat von: mainframe am 31 März 2017, 20:11:12
Wenn ich den Source in Ardiuino einbinde und das nach der Anleitung
...
/Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy/ESPEasy.ino
Ich keine diese Anleitungen nicht, aber das ESPEasy Verzeichnis gehört wohl eher nicht unterhalb von /libraries/

Zitat
Ungültige Bibliothek /Volumes/User/sven/Documents/ArduinoScetch/libraries/ESPEasy_v2.0.0-dev7
Auch dieser Ordner gehört dort nicht hin.

Zitat
Mehrere Bibliotheken wurden für "PubSubClient.h" gefunden
Mehrere Bibliotheken wurden für "Servo.h" gefunden
Mehrere Bibliotheken wurden für "SD.h" gefunden
Doppelt installierte Libraries sind auch nicht gut.

Zitat
Wenn ich das bin image direkt Flashen will, geht nicht.
Ohne Details ist keine sinnvolle Anwort möglich.

Zitat
Und genau das ist es was mich davon abhält sowas zu nutzen.
Wenn Du keine Lust hast Dich mit dem Thema zu beschäftigen, dann solltest Du in der Tat die Finger davon lassen und eine fertige Lösung kaufen. Blind nach Anleitung zu installieren war noch nie eine gute Idee.
Außerdem bitte Logs, wie oben, nächstes Mal in Code Tags einfassen (# Button), so ist das je nach Client schwer zu lesen.

mainframe

Es hat nichts mit Lust zu tun, es geht einfach darum das ich mittlerweile immer mehr Projekte mit ähnlichen Problemen hatte, un jedesmal muss irgendwas von hand irgendwo hin und her geschoben werden.Und das mit den Anleitungen ist das gleiche, ich suche im Internet immer stückchenweise nach lösungen, und das immer auf mehreren Seiten.(Ironie an: Sowas nennt man dann auch Schnitzeljagd).

Zudem Arbeite ich mich ja auch selber ein , sonnst hätte ich das mit dem ESP ja wohl nicht zum laufen bekommen oder?

mainframe

#12
Ich konnte das ESPEasy am Arduino IDE jetzt auf einen Fehler minimieren, hat jemand dazu eine Ahnung?

/Volumes/User/sven/Documents/ArduinoScetch/ESPEasy/_P036_FrameOLED.ino:22:20: fatal error: images.h: No such file or directory
#include "images.h"
                    ^
compilation terminated.
exit status 1

So, ich habe die Datei jetzt mal gelöscht, Compiler ohne Fehler, dann Upload auf ein Wemos D1.
Im Seriellen Terminal kommt jetzt folgendes:

load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v09826c6d
~ld
�U


INIT : Booting version: (custom)
FS   : Mount successful
Resetting factory defaults...
RESET: Reboot count: 251
RESET: To many reset attempts

PID:0
Version:0
INIT : Incorrect PID or version!
Resetting factory defaults...
RESET: Reboot count: 251
RESET: To many reset attempts

Exception (0):
epc1=0x40106f65 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000

ctx: cont
sp: 3fff3900 end: 3fff3b70 offset: 01a0

>>>stack>>>
3fff3aa0:  0000001c 00000000 3fff2a8c 401004d8 
3fff3ab0:  3fff2a8c 3fff2a8c 3fff4c04 40202e69 
3fff3ac0:  00000000 00000001 00000101 4010020c 
3fff3ad0:  0000001c 00000000 3fff2a8c 00000000 
3fff3ae0:  0000001c 00000000 3fff2a8c 402343dc 
3fff3af0:  00000001 3fff292c 3fff2b50 3fff292c 
3fff3b00:  3fffdad0 3fff2b48 40235e40 3fff2b48 
3fff3b10:  3fffdad0 3fff2a8c 3fff123c 40207d69 
3fff3b20:  3fffdad0 3fff2a8c 3fff123c 402202e9 
3fff3b30:  feefeffe feefeffe feefeffe 3fff495c 
3fff3b40:  0000002f 00000023 feefeffe feefeffe 
3fff3b50:  3fffdad0 00000000 3fff2b42 40235e84 
3fff3b60:  feefeffe feefeffe 3fff2b50 40100718 
<<<stack<<<

ets Jan  8 2013,rst cause:2, boot mode:(3,6)

????????????????
Das selbe bekomme ich wenn ich die Images direkt draufschreibe.
????????????????