more G-Labs products

Author Topic: Basics of 2 Way TCP/IP (Arduino Garage Door Opener)  (Read 2649 times)

May 20, 2014, 10:58:29 PM
Read 2649 times

Eric_S

  • *
  • Information
  • Newbie
  • Posts: 22
Hi,

I have an Arduino with a network shield on my local network that is going to control (button push to open/close) and report status of my garage door (open, partially open, closed and direction of travel. It will use the magnetic reed switches that came with the garage door opener for up/down limits, a Sharp GP2Y0A710K0F to sense location and up/down motion and a ECS1030-L72 to confirm if the motor is running (the GP2Y0A710K0F is rather noisy).

My questions are:

1. How would I send TCP/IP communications from HG to the Arduino poll or button push)? Right now I have the Arduino receiving and parsing a HTTP GET request and that seems to work adequately but maybe there is a better way.

2. How would I get HG to listen for a response from the Arduino and display it in both the web interface and the Andriod app (again, poll or button push)?

3. Would it be better to have HG poll the Arduino for status or have the Arduino send status updates periodically?

When I get this all working smoothly, I'll post the recipe with schematics and code.

Thanks!

May 22, 2014, 09:52:01 PM
Reply #1

Eric_S

  • *
  • Information
  • Newbie
  • Posts: 22
Regarding questions 1 and 2: Would I use WebService Call or GetData?

As far as question #3: How does z-wave do it? Does each node periodically report status or does the controller (HG] poll for a response every so often? Or on demand?

WebService will listen for a response but can it just sit there and wait for the Arduino to check in with a status report?
« Last Edit: May 31, 2014, 07:55:15 AM by Eric_S »

May 31, 2014, 08:05:51 AM
Reply #2

Eric_S

  • *
  • Information
  • Newbie
  • Posts: 22
Both Call and GetData work well. They retrieve data from the Arduino and display it in a notification popup. Now I have to design a widget. I'll probably end up using Call though since all the Arduino returns is one of the following strings:

Opening
Open
Partially Open
Closed
Closing

About question #3: No answers? I guess I'll have HG poll the Arduino every 5 minutes or on demand when the widget loads.

May 31, 2014, 02:54:53 PM
Reply #3

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
For question 3, it's better that Arduino sends the status update when something change.
Your automation program should implement custom webservice entries to allow this.
Also when a status change is received it should call Program.RaiseEvent method.
That way your widget will automatically update the displayed data as the event is received (it's automatic, it don't need to poll).

See the philips hue bridge program for an example of custom webservice and RaiseEvent.

Cheers,
g.