Indigo and Arduino

Posted on
Sun Mar 14, 2010 9:10 pm
mesford offline
Posts: 2
Joined: Mar 14, 2010

Indigo and Arduino

Hi. I'm planning a new-home lighting control system and I'd like a little feedback on my high-level design. Then I can start asking more specific questions ;)

I'm planning on controlling SSRs using one or more Arduino boards. The Arduinos would also monitor switch states. The Arduino connects via USB so I *think* that rules out using Serial Bridge. I was able to get Indigo to trigger an Applescript that sent a message to the Arduino and cause an LED to turn on or off. What I haven't figured out is how to listen to the USB port. I understand an Applescript could do that in theory, and then pass that info on to Indigo. But I haven't figured out how to do that in an Applescript. I started looking at XCode projects but I don't know the studio well enough to figure out how to modify the code for my use.

Can anyone comment on my overall plan and offer any critiques or suggestions? FTR, I'm not interested in using X-10 or Insteon.

Thanks,
Mike

Posted on
Sun Mar 14, 2010 10:17 pm
jay (support) offline
Site Admin
User avatar
Posts: 8881
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo and Arduino

If you're comfortable using another scripting language then you could use one of those to do the comm with the Arduino and then use the RESTful APIs to update information in Indigo. I found this article about dealing with it via python for instance.

Having said that, since the Arduino hardware uses the FTDI driver, which creates a virtual comm (serial) port, you should be able to use Serial Bridge if you really want to. I wouldn't really recommend it since SB is pretty much in legacy mode and isn't likely to get updated.

Jay (Indigo Support)
Twitter | Facebook

Posted on
Mon Mar 15, 2010 7:58 am
mesford offline
Posts: 2
Joined: Mar 14, 2010

Re: Indigo and Arduino

Jay,

Python sounds way easier. I thought I was limited to Applescript for talking to Indigo. The RESTful API stuff looks interesting. I hadn't heard of that before. Is it simply a matter of having Python (or some other language) send that info to the given URL? And defining the URL is part of the Indigo setup I suppose? That would simplify things. Where can I find some documentation on the RESTful APIs?

Mike

Posted on
Mon Mar 15, 2010 8:10 am
jay (support) offline
Site Admin
User avatar
Posts: 8881
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Indigo and Arduino

The link above is to the docs on the RESTful APIs. They are very straight-forward so don't really need any more information. And yes, they work from any environment that can do HTTP GETs or POSTs.

Jay (Indigo Support)
Twitter | Facebook

Posted on
Sat May 22, 2010 7:34 am
pifpaf offline
Posts: 3
Joined: May 22, 2010

Re: Indigo and Arduino

I am trying to use the RESTful URL (http://127.0.0.1:8176/devices/), but I get a "can't connect to the server" error.
I checked the IP address, but do I need to modify the port number?
Server is 4.1.7

Thanks

Posted on
Sat May 22, 2010 6:22 pm
anode offline
Posts: 695
Joined: May 27, 2007
Location: NC

Re: Indigo and Arduino

The 127... Is a loopback ip. Have you tried the ip of the server itself?
(loop back should be ok -if- you are running the server and this app on the same machine. But try the real LAN ip and see what happens)

though Ive never used the restful api so the lopback may be the norm. Sorry if I'm off base

Posted on
Sat May 22, 2010 9:12 pm
pifpaf offline
Posts: 3
Joined: May 22, 2010

Re: Indigo and Arduino

Thanks anode.
I did try with the actual IP address of the server.
I found that the problem was with the port. The example 8176 was not working.
I looked at the server preference and found that it was setup to use 8000. After changing the RESTful URL to 8000, it now works!

Posted on
Sun May 23, 2010 4:54 am
anode offline
Posts: 695
Joined: May 27, 2007
Location: NC

Re: Indigo and Arduino

Just curious, working with real ip or loopback?

Posted on
Mon May 24, 2010 10:14 am
pifpaf offline
Posts: 3
Joined: May 22, 2010

Re: Indigo and Arduino

real IP.
I have not tried loopback.

Posted on
Thu Oct 13, 2011 12:21 pm
ckeyes888 offline
Posts: 1453
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Indigo and Arduino

Might someone have some sample AS code to send an Arduino commands?
I'm setting up Arduino sketches to control an LED strip.

Thanks,

Carl

Posted on
Fri Nov 23, 2012 12:25 pm
ckeyes888 offline
Posts: 1453
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Indigo and Arduino

Thinking of setting up some Christmas lights using a LPD98806 LED strip controlled by an Arduino from Indigo.

I had it working about a year ago, with a ton of help from berkinet, to control it from Indigo on a remote
machine but now the Arduino is setup on my Indigo machine.

I just need to send it simple characters, "a", "b" etc. and was thinking maybe a plugin could do that?

It's at /dev/cu.usbmodem21 according to the Arduino app.

Any ideas?

Thanks,

Carl

Posted on
Fri Nov 23, 2012 11:00 pm
ckeyes888 offline
Posts: 1453
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Indigo and Arduino

Can Python send serial commands?

Trying to piece together something like this to send a "b" to the Arduino:

import serial
s = serial.Serial(port='/dev/tty.usbmodemfd541', baudrate=9600)

s.write('b')

Edit: In the Arduino sketch a "b" command should make its LED blink on and off twice.
What's happening when I send the above code from Indigo is making it blink
a few times very quickly. I tested the sketch from the Arduino serial monitor
and it works fine from there. Any ideas?

Thanks,

Carl

Posted on
Sat Nov 24, 2012 1:07 am
ckeyes888 offline
Posts: 1453
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Indigo and Arduino

Doh, again. Got it.

Seems all it needed was to replace the:

s = serial.Serial(port='/dev/tty.usbmodemfd541', baudrate=9600)

s.write('b')

with:

text = serial.Serial(port='/dev/tty.usbmodemfd541', baudrate=9600)

text.write('b')

Carl

Posted on
Sat Nov 24, 2012 6:45 pm
ckeyes888 offline
Posts: 1453
Joined: Nov 26, 2009
Location: Kalispell, MT

Re: Indigo and Arduino

Just a general question but can anyone think of a reason why when executing
the above python script from Indigo it only works if the Arduino app and it's serial monitor
window are opened?

Thanks,

Carl

Posted on
Sat Nov 24, 2012 8:35 pm
berkinet offline
User avatar
Posts: 2407
Joined: Nov 18, 2008
Location: Mougins, France & Berkeley, CA, USA

Re: Indigo and Arduino

I don't know a lot about the arduino, but, I suspect that something needs to create the serial device. That is, just plugging the arduino into the Mac may not automatically establish the device. I suggest you kill the arduino app and the following in a terminal window:
cd /dev
ls tty.usb*

Then, start the arduino app and do the ls tty.usb* command again.

See anything different?

Who is online

Users browsing this forum: No registered users and 1 guest