Homeyduino ontvangt de commando's niet

Beste leden,

ik ben bezig met mijn arduino en mijn Homey met Homeyduino app.

hiervoor het ik in Homey een flow gemaakt (if) all triggers (then) spraak bericht “hij doet het”

op de arduino heb ik de volgende code :

/*
  Circuit:
   Ethernet shield attached to pins 10, 11, 12, 13


*/
#include <Homey.h>
#include <SPI.h>
#include <Ethernet.h>



// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[ ] = {
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;


int analogPinA1 = A1; 
                    // outside leads to ground and +5V
int val = 0;  // variable to store the value read
const int threshold = 400;   // an arbitrary threshold level that's in the range of the analog input


void setup() {

  Homey.begin("Belduino");
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  // this check is only needed on the Leonardo:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for (;; )
      ;
  }
  // print your local IP address:
  printIPAddress();


  
}

void loop() {

  Homey.loop();

 // read the value of the potentiometer:
  int analogValue = analogRead(analogPinA1);

  // if the analog value is high enough, turn on the LED:
  if (analogValue > threshold) {
Serial.println("High"); 
Homey.trigger("PinA1High");
  } else {
Serial.println("Low"); 
Homey.trigger("PinA1Low");
  }

 
  delay(1000);        // delay in between reads for stability



  switch (Ethernet.maintain())
  {
    case 1:
      //renewed fail
      Serial.println("Error: renewed fail");
      break;

    case 2:
      //renewed success
      Serial.println("Renewed success");

      //print your local IP address:
      printIPAddress();
      break;

    case 3:
      //rebind fail
      Serial.println("Error: rebind fail");
      break;

    case 4:
      //rebind success
      Serial.println("Rebind success");

      //print your local IP address:
      printIPAddress();
      break;

    default:
      //nothing happened
      break;

  }
}

void printIPAddress()
{
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print(".");
  }

  Serial.println();
}

Iemand enig idee waarom ik geen commando’s op Homey binnen krijg?

ter info deze sketch ga ik gebruiken voor mijn voordeur bel. hiermee start ik een flow op homey.

Arduino Uno + ethernetshield v1 (libary is aangepast naar V1)

Homey heeft wel al connectie met de arduino (de app kan hem vinden)

Hoe zien je flows er uit?

Zo op het eerste gezicht lijkt dat wel te kloppen. Heb je al eens geprobeerd om Homey.begin() pas aan te roepen op het moment dat de netwerkverbinding gestart is (dus na Ethernet.begin())? Heb je een serieële verbinding met de Arduino, en laat die de juiste berichten (High/Low) zien?

dat was de trick! ik was er wel achter dat als ik hem op low had staan en dan opstart dat er achter elkaar de flow gestart werd. als je dan de status 1x naar high veranderde dan werkte het niet meer.

nu de Homey.begin na de Ethernet.begin staat werkt het wel steady! thx voor het mee denken!

Voor de gene die ook met Arduino een input naar Homey willen maken hier de Code van de sketch.

/*
Arduino Uno
Ethernet v1 schield

Libary :
Zoek in de libary "Homey.h" op je pc. Open de file met een text editoren.
Verwijder de // marker voor het volgende //#define HOMEY_USE_ETHERNET_V1 
Zo dat er alleenhet volgende staat #define HOMEY_USE_ETHERNET_V1
Hier na moet je de homey libary weer opnieuw toevoegen aan dit script #include <Homey.h>

  Circuit:
   Ethernet shield attached to pins 10, 11, 12, 13


*/
#include <Homey.h>
#include <SPI.h>
#include <Ethernet.h>



// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = {
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02
};

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;


int analogPinA1 = A1; // Input contact kan je schakelen door grd en A1 te verbinden
int val = 0;  // variable to store the value read
const int threshold = 400;   // an arbitrary threshold level that's in the range of the analog input


void setup() {


  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  // this check is only needed on the Leonardo:
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for (;;)
      ;
  }

  
  // start the Homey connection:
  Homey.begin("Belduino");

    
  // print your local IP address:
  printIPAddress();


  
}

void loop() {

  Homey.loop();

 // read the value of the potentiometer:
  int analogValue = analogRead(analogPinA1);

  // if the analog value is Low enough Trigger Homey:
  if (analogValue > threshold) {
Serial.println("High"); 

  } else {
Serial.println("Low"); 
Homey.trigger("PinA1Low");
  }

 
  delay(200);        // delay in between reads for stability



  switch (Ethernet.maintain())
  {
    case 1:
      //renewed fail
      Serial.println("Error: renewed fail");
      break;

    case 2:
      //renewed success
      Serial.println("Renewed success");

      //print your local IP address:
      printIPAddress();
      break;

    case 3:
      //rebind fail
      Serial.println("Error: rebind fail");
      break;

    case 4:
      //rebind success
      Serial.println("Rebind success");

      //print your local IP address:
      printIPAddress();
      break;

    default:
      //nothing happened
      break;

  }
}

void printIPAddress()
{
  Serial.print("My IP address: ");
  for (byte thisByte = 0; thisByte < 4; thisByte++) {
    // print the value of each byte of the IP address:
    Serial.print(Ethernet.localIP()[thisByte], DEC);
    Serial.print(".");
  }

  Serial.println();
}
1 Like