Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15484

Building wake on lan remote control

$
0
0

Hi folks,
this is my first arduino project I did myself. I use a Wemos D1 mini, which I know from the AHOY project to connect my Hoymiles PV Inverter to the Victron Energy System.

What is it about? I added a mini pc to my television set to replace the internal streaming solution. Now I have to go to the television and switch the pc on, to e. g. watch youtube. So I thought, a remote control would be nice (working with wake on lan and the WLAN module of the Wemos D1 mini).

I have a harddisc video recorder (EasyVDR), too. So I build the following thing:

A 9V battery "plus" goes to a push button and then to a 9V to 5V voltage conversion pcb. And then to the Wemos D1 Mini. Via an AB Switch I can take D2 or D3 to GND.

So I thought: I switch to Easyvdr or Streaming PC and the press the power button of my circuit. The circuit switches on and the device I want wakes up via wake on lan.

I used the following code:

#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
WiFiUDP UDP;
#include <WakeOnLan.h>
WakeOnLan WOL(UDP); // Pass WiFiUDP class

//The ESP-12 has a blue LED on GPIO2
#define LED 2
#define D3 0
#define D2 4

// Name and password of the WLAN access point
#define SSID "MY WLAN"
#define PASSWORD "MY PASSWORD"

/** Runs once at startup */
void setup() 
{
    pinMode(LED, OUTPUT);
    pinMode(D2, INPUT_PULLUP);
    pinMode(D3, INPUT_PULLUP);

    WiFi.mode(WIFI_STA);
    WiFi.begin(SSID, PASSWORD);
    WOL.setRepeat(3, 100); // Repeat the packet three times with 100ms delay between
}

/** Main loop, executed repeatedly */
void loop() 
{
  const char *ESPRIMO = "90: … :xy";
  const char *EASYVDR = "d4: … :85";

  digitalWrite(LED,LOW);
  delay(500);
  digitalWrite(LED,HIGH);

  int D2Val = digitalRead(D2);
  int D3Val = digitalRead(D3);


  if (D2Val == LOW) 
    {
    WOL.sendMagicPacket(ESPRIMO);  
    } 

 if (D3Val == LOW) 
    {
    WOL.sendMagicPacket(EASYVDR);  
    } 

 }

The problem is: The circuits does nothing, because the AB switch is connected at startup of the Wemos D1 mini. The design is done this way, because of the power consumtion. It has to work with a battery. Solution: Disconnect the AB Switch from the Wemos at startup. When I press the power button, the circuit wakes up. Now I connect the AB Switch to D2 and D3 and at the moment the right device wakes up.

My next step: Buy a switch with on - off - on and power the circuit while the Switch is in middle position and wait a second and then choose the device I want to wake. I hope this will work. For the moment I disconnected the switch and only wake the streaming pc.

My question is: What is the problem? Is it, because at the moment of startup one of the pins D2 and D3 is connected to GND and the Input with internal pullup is not set, yet.

It would be nice, if anyone with more experience could tell my, where my problem is coming from.

Thank you,
Markus

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 15484

Trending Articles