Alternating wakereason

Hi!
I’m playing with my first imp and i’m a little bit confused.
I wrote the following code to test my imp:

//Doorbell
// Configure Pin1 to be wake up pin
hardware.pin1.configure(DIGITAL_IN_WAKEUP);
hardware.pin9.configure(DIGITAL_OUT);
local outputValue = OutputPort(“Türklingel”, “string”);
function check_state() {
switch (hardware.wakereason()) {
case WAKEREASON_TIMER:
server.log(“Timer wakeup”);
break;
case WAKEREASON_PIN1:
server.show(“Tür: DingDong!”);
server.log(“Tür: DingDong!”);
hardware.pin9.write(0);
imp.sleep(3);
hardware.pin9.write(1);
imp.sleep(0.5);
break;
default :
}
}
// Configure on planner and register with imp server
imp.configure(“Doorbell”, [], [outputValue]);
hardware.pin9.write(1);
check_state();
imp.onidle(function() { server.sleepfor(900.0); });

In the serverlog it looks like this:

09/06/2013 19:26:44: Power state: offline=>online
09/06/2013 19:26:44: Device booting
09/06/2013 19:26:44: Device configured to be "Doorbell"
09/06/2013 19:26:44: Timer wakeup
09/06/2013 19:26:44: Power state: online=>asleep
09/06/2013 19:26:44: Power state: online=>offline
09/06/2013 20:03:13: Power state: offline=>online
09/06/2013 20:03:13: Device booting
09/06/2013 20:03:14: Device configured to be "Doorbell"
09/06/2013 20:03:14: Tür: DingDong!
09/06/2013 20:03:17: Power state: online=>asleep
09/06/2013 20:03:17: Power state: online=>offline
09/06/2013 21:03:22: Power state: offline=>online
09/06/2013 21:03:22: Device booting
09/06/2013 21:03:22: Device configured to be "Doorbell"
09/06/2013 21:03:22: Timer wakeup
09/06/2013 21:03:22: Power state: online=>asleep
09/06/2013 21:03:22: Power state: online=>offline

and so on.

But there is no change on input pin 1.
Any sugestions?

A quick look at the code and seems ok.
Assume you are taking pin1 high as it needs to see rising edge.
Are you using a Sparkfun April?
There can be an issue with SD card holder on some pins a gentle push might be needed

When you say there is no change on pin 1, do you have a long length of wire attached? The internal pull-down on pin 1 is quite weak, you may need to add a stronger external pulldown (eg: 1k) and maybe a capacitor between pin1 and ground to filter out any induced noise.

Basically, the imp is pretty sensitive, and if you have a long length of wire attached you are likely picking up noise - could be from anywhere, including local radio transmitters or TV stations - which is triggering the imp to wakeup.

Hi Hugo.
The cable between pin1 and the optocoupler is 30cm.
I will test it with a external resistor.
THX