Looking for a HW/Software solution to a problem

Greetings all I am using a Macintosh Mini (snow leopard) and I am building a Doorbell / camera interface and need help.

I would like when the doorbell is pressed, it activates a relay that runs a Applescript (I already wrote) program to
start a sequence of events.

I am looking for a hardware / software solution that will see the relay, and then run the applescript or application.

I will pay for all hardware and your time.

please email me at Jon (at) macgeek.com

Thanks!

Jonathan

Hi MacGeek,

Where are you located? looking at your name I think Scotland :wink:

There are several solutions possible but:

  • Can your AppleScript monitor the hardware lines of a serial port ? e.g. relay switches RTS from low-> HIGH
  • Can your AppleScript monitor the serial port ? e.g. commands "B" and "O" from the Arduino. B = Bell O = Off

Rob

LOL no I am in Brooklyn, NY NOT Scotland!

I am actually looking for someone to write the program, and set it up for me.

Jonathan

PS: some more thoughts on it's function

  1. once its triggered it should ignore all trigger commands for 2 mins
    (if someone keeps hitting the button to activate it)

  2. it triggers other external events (contact closure)
    (if I want to record the video on a dvr, for instance)

OK Jonathan, Brooklyn it is,

Do you allready own an Arduino?

The additional requirements are quite clear, in pseudocode your application looks something like

define IO & libs

void setup()
{
   .. initialize things
}

void loop()
{
  If (doorbell pressed and last press was more than 2 minutes ago)
  { 
    make a log entry on SDcard;
    set timer for two minutes;
    send signal to AppleScript (retry 3 times);
    if (DVR switch ON)
    { 
      set DVR ON;
    }
  
  if (timer has passed 2 minutes)
  {
    set DVR OFF;
  }
}

Thanks for the code, I actually don't have ANY of the components yet.
I was looking for a HW/SW person to 'put it all together for me'

:wink:

Jonathan

I am still looking for a person, but I may end up doing the project myself (Cost constraints)

Here is the sequence I am trying to accomplish

  1. person rings my doorbell (which triggers a relay)
  2. relay activates doorbell and arduino - which sends a USB/Serial command to Macintosh monitoring and executes a APPLESCRIPT
  3. arduino deactivates / ignores any more attempts to re-activate for 4 mins (doorbell push)
  4. arduino activates a closed contact (so start a DVR, or other triggered function)
  5. after 4 mins, arduino resets, returning all contacts to 'open'

Thanks

Jonathan

Hi Jonathan,

I guess my final offer was also too much for your budget.

I will keep an eye on this thread and chirp in from time to time if you are having problems.

Cheers Pete

I am seeing just what this will cost me $)

I have tracked down the Applescript proxy server, and purchased the Arduino board
it is down now to seeing if I can figure out the code to do the simple

Sense button push
ignore all other button pushes
send command to Macintosh to start applescript

how hard can THAT be?

(we will see) LOL

Jonathan

What you are trying to do it fairly easy to accomplish. I would suggest you either use Processing or Perl (my favorite) on your mini to monitor the serial port where the Arduino is plugged in. Then just come up with a scheme such as send the letter "A" when the doorbell is rung. From the Processing or Perl side it is simple to then read that "A" and trigger your applescript.

Check out:
http://arduino.cc/playground/Interfacing/Processing
http://arduino.cc/playground/Interfacing/PERL

To trigger an AppleScript from the command line, use osascript: Documentation Archive

The reason I mentioned Processing is that if you are a little familiar with Arduino, then Processing is pretty simple to pick up.

Ok, I have been paying, and making some good progress, I am having some MINOR ISSUES,

int ledPin = 13; // LED connected to digital pin 13
int potPin = 0; // white doorbell wire to analog pin 0
int val = 0;

long time = 0;
long debounce = 5000;

void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin as output
Serial.begin(9600); // open serial port at 9600 baud
digitalWrite(14 + potPin, HIGH); // set pullup on the analog pin
// (analog 0 = digital 14, a1 = d15, etc)
}

void loop() {
val = analogRead(potPin);
if (val < 50) { // if the circuit is completed
// (for me, it generally drops from 1023 to ~ 15 when 'ringing')
if (millis()-time > debounce) {
Serial.println("A");
digitalWrite(ledPin, HIGH); // sets the LED on
delay(5000); // ... 240000 = 4 mins
digitalWrite(ledPin, LOW); // and turns the LED off
time = millis();
}
}
}

What seems to be happening, is that I have to push the button 3 times to get it to send the "A" to the serial Port,

I played with the delay(5000) to have it ignore the input, but It doesnt seem to be working...

Any ideas?

Thanks

Jonathan

macgeek:

int ledPin = 13;   // LED connected to digital pin 13

int potPin = 0;    // white doorbell wire to analog pin 0
int val = 0;

long time = 0;
long debounce = 5000;

void setup() {
  pinMode(ledPin, OUTPUT);      // sets the digital pin as output
  Serial.begin(9600);           // open serial port at 9600 baud
  digitalWrite(14 + potPin, HIGH); // set pullup on the analog pin
                                // (analog 0 = digital 14, a1 = d15, etc)
}

void loop() {
  val = analogRead(potPin);
  if (val < 50) {              // if the circuit is completed
  // (for me, it generally drops from 1023 to ~ 15 when 'ringing')
    if (millis()-time > debounce) {
      Serial.println("A");
      digitalWrite(ledPin, HIGH);   // sets the LED on
      delay(5000);                   // ... 240000 = 4 mins
      digitalWrite(ledPin, LOW);    // and turns the LED off
      time = millis();
    }
  }
}




What seems to be happening, is that I have to push the button 3 times to get it to send the "A" to the serial Port,

I played with the delay(5000) to have it ignore the input, but It doesnt seem to be working...

Any ideas?

Change "long time" to "unsigned long time".

On the first pass through your loop, you are trying this

if (millis()-time > debounce)

millis() starts at 0 and counts up, and time starts at 0. So you are waiting until millis() is greater than debounce(5000) before you actually set the fact that the button has been pressed for the first time.

With the current logic, when you first start up, wait 5 seconds after it starts before you try hitting the button and test. You can rearrange your logic to fix this, but this would be generally fine after the first 5 seconds.

It's a Cheat, BUT IT WORKS...

int ledPin = 13; // LED connected to digital pin 13
int potPin = 0; // white doorbell wire to analog pin 0
int val = 0;

long time = 0;

long debounce = 1000;

void setup() {
pinMode(ledPin, OUTPUT); // sets the digital pin as output
Serial.begin(9600); // open serial port at 9600 baud
digitalWrite(14 + potPin, HIGH); // set pullup on the analog pin
// (analog 0 = digital 14, a1 = d15, etc)
}

void loop() {
val = analogRead(potPin);
if (val < 100) { // if the circuit is completed
// (for me, it generally drops from 1023 to ~ 15 when 'ringing')
if (millis()-time > debounce) {
Serial.println("A");
delay(500);
Serial.println("A");
delay(500);
Serial.println("A");
digitalWrite(ledPin, HIGH); // sets the LED on
delay(120000); // ... 240000 = 4 mins
digitalWrite(ledPin, LOW); // and turns the LED off
time = millis();
}
}
}

What I found what was happening, was the Arduino was sending the "A" to the serial port, But the Applescript Proxy was only reading every third "A" so I just had the program, send out THREE.. and by adding the Delay, the unit is ignoring any button pushes for "X"

Jonathan

What I found what was happening, was the Arduino was sending the "A" to the serial port, But the Applescript Proxy was only reading every third "A" so I just had the program, send out THREE

You really need to figure out why this is happening, and fix it properly.

Have you told the proxy server to read 3 characters at a time?

The proxy server is a fixed program, written by someone years ago, who has (and his company too) disappeared

Jonathan

Yeah, that AppleScript proxy server sounds screwy. What's it called? Doing a simple Google search I came up with several AppleScript proxy servers. You may want to check out one of them, one that is less of a black box to you.

Thanks for the advice its called "AsProxy" from tinker.it,
it is a great little program, but seriously under powered and glitchy

I looked around for any other program, that would poll the serial port, and activate a applescript when it received a letter of number from the Arduino, and found nothing.

SerialPortX kinda sorta does the same thing in Applescript (well it lets applescript read the serial port)
But it does not have polling capability, and then I would need to run a applescript, to run a applescript
and that can get a bit dicey.

Any other suggestions?
ALL are welcome!

:slight_smile:

Jonathan