Author Topic: Arduino Plugin  (Read 22169 times)

0 Members and 1 Guest are viewing this topic.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Arduino Plugin
« Reply #15 on: April 13, 2014, 07:56:04 AM »
Sure, no problem.  ;D

VoxCommando can communicate with multiple devices using multiple com ports.  Other than that I don't really know what you are asking.
« Last Edit: April 13, 2014, 07:59:34 AM by jitterjames »

donmehdi

  • Jr. Member
  • **
  • Posts: 21
  • Karma: 0
    • View Profile
Re: Arduino Plugin
« Reply #16 on: April 27, 2015, 07:09:16 PM »
[img][img]Hey, i just made the circuit on my arduino UNO. i dont know if it is correct since  the tutoriel of the arduino doesn t use a breadboard but a relayboard. I want to know if it is correct.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Arduino Plugin
« Reply #17 on: April 27, 2015, 07:29:55 PM »
Hi donmehdi, no your wiring is wrong.

D3-> resistor -> LED(long leg=anode=+) and LED (short leg=kathode= -) to ground

D4-> resistor-> LED(long leg=anode=+) and LED (short leg=kathode= -) to ground

D5-> resistor -> LED(long leg=anode=+) and LED (short leg=kathode= -) to ground

You will find a lot of examples here: http://www.arduino.cc/en/Tutorial/Blink
« Last Edit: April 27, 2015, 07:32:03 PM by Kalle »
***********  get excited and make things  **********

donmehdi

  • Jr. Member
  • **
  • Posts: 21
  • Karma: 0
    • View Profile
Re: Arduino Plugin
« Reply #18 on: April 27, 2015, 07:37:30 PM »
OH the placement of my resistors is wrong  i have to put it between the digital and the led. i'm going to try that
Thanks.

donmehdi

  • Jr. Member
  • **
  • Posts: 21
  • Karma: 0
    • View Profile
Re: Arduino Plugin
« Reply #19 on: April 27, 2015, 09:11:18 PM »
i think the method adjustrelays() provided in the wiki for arduino should be like that:

///////////////////

void adjustRelay(int whichPin, char setState)
{
  if (setState=='1')// 1 instead of 0
  {

    Serial.write(" OFF");
    digitalWrite(whichPin, HIGH);
  }
  else if(setState=='0')// 0 instead of 1
  {   
    Serial.write(" ON");
    digitalWrite(whichPin, LOW);   
  }     
}

/////////////////////////////////

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Arduino Plugin
« Reply #20 on: April 28, 2015, 09:15:45 AM »
The nice thing about code is that you are free to modify it to suit yourself.

I personally like to follow logical conventions as much possible so that code is easier to understand.

99.9 percent of the time 0 = off and 1 = on but you can do whatever makes you happy.  :)

donmehdi

  • Jr. Member
  • **
  • Posts: 21
  • Karma: 0
    • View Profile
Re: Arduino Plugin
« Reply #21 on: April 29, 2015, 12:12:48 AM »
I know, but the thing is when i used the code you provided, when i tell vc to turn relays on it turns them to off and same thing for off,  it turns them to on.  :D :D ;)

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: Arduino Plugin
« Reply #22 on: April 29, 2015, 03:49:32 AM »
Yes there are some relays available which works in reverse  ::)
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Arduino Plugin
« Reply #23 on: April 29, 2015, 08:48:12 AM »
Maybe this will help.
https://youtu.be/YN_kV2h-a04

And if you are using LEDs you should be aware that there are two different types. Common anode and common cathode. http://forum.arduino.cc/index.php?topic=22413.0

donmehdi

  • Jr. Member
  • **
  • Posts: 21
  • Karma: 0
    • View Profile
Re: Arduino Plugin
« Reply #24 on: April 29, 2015, 09:22:44 AM »
Thanks James :), now i understand ;)

batfasturd

  • Jr. Member
  • **
  • Posts: 24
  • Karma: 0
    • View Profile
Re: Arduino Plugin
« Reply #25 on: June 15, 2015, 12:38:43 PM »
I use Openhab as the center of my home automation which is a combination of arduinos using the Mysensors libraries, the Hue hub and bulbs and a few GE smart bulbs. Openhab has a web API which can be easily accessed using Voxcommando so I can ask, what's the weather outside and it can pull data directly from my HA controller via web scrape and tell me the conditions from my arduino node. Voxcommando also can control all the lights in my house, garage door, etc... using the same web API.

laksmanx

  • Jr. Member
  • **
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Arduino Plugin
« Reply #26 on: June 16, 2015, 08:18:26 AM »
Hi James.

I want VC to reply with speech if an input is triggered on the arduino.

I used the code provided in THIS FORUM and it works but I am unable to get VC to read an input from my Arduino when triggered.



Kind regards


jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Arduino Plugin
« Reply #27 on: June 16, 2015, 08:51:18 AM »
Hi laksmanx,
Welcome to the forum.

There are many codes posted on "this forum".  It always helps to be specific about what you have tried when seeking help from others.

In fact,  in this very thread,  a few posts up,  you can find an example of sending data in both directions,  to Arduino from VoxCommando and to VoxCommando from Arduino:  http://voxcommando.com/forum/index.php?topic=1452.msg12742#msg12742

If you have tried this example code and are unable to get it to work,  then please tell us more specifically what you are doing and what is happening vs what you expect etc.

Read the following for tips on getting support more effectively: http://voxcommando.com/mediawiki/index.php?title=Getting_support

laksmanx

  • Jr. Member
  • **
  • Posts: 3
  • Karma: 0
    • View Profile
Re: Arduino Plugin
« Reply #28 on: June 16, 2015, 09:49:57 AM »
I am referring to reply #9 to #12 in the Arduino plugin post which is about two way coms between VC and Arduino.

I used the code and it works for both Arduino uno and VC.
VC is able to set outputs on Arduino high or low and I am able to ask VC what the pin status is of relevant pin.

What I would like to do is trigger an input on the Arduin uno and have VC respond with a phrase eg. the front door is open garage door opening.

I am not sure where to make the change , in Arduino code or python code or probably both.



jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Arduino Plugin
« Reply #29 on: June 16, 2015, 02:11:05 PM »
Now we are getting somewhere!

Yes you only need to adjust the Arduino Sketch.  You do not need to modify the python code.

You only need to know a few fundamental things about Arduino to modify the code I posted.  The code that I posted was supposed to be a starting point so that you could see how it works and then modify it to suit your needs.  I suggest that you look over the Arduino sketch and the Python code and try to understand how it all fits together.

In order to add some extra functionality to your sketch for a button, you should first take a look at this example:
http://www.arduino.cc/en/Tutorial/Button

That sketch is using a button, and resistor, and Digital pin #2 to read the state of the button.  You can add a button using the same wiring that they show.  Then you need to borrow some of their code and adapt it a little bit to our existing sketch.

At the beginning of our sketch you need to define some constants and variables:
Code: [Select]
const int buttonPin = 2;     // the number of the pushbutton pin
int buttonState = 0;         // variable for reading the pushbutton status

in the setup() you need to let Arduino know that we will be using pin 2 as an input:
Code: [Select]
pinMode(buttonPin, INPUT);
and in the loop we need to look at the state of the button (newButtonState), compare it to the old state of the button (buttonState) to see if it changed.  If it did change then we can fire an event in VC showing if the button is pressed or released.  Finally we should store the new button state (newButtonState) in our variable (buttonState) so next time we can see if it changed or not.

Code: [Select]
// read the state of the pushbutton value:
  int newButtonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (newButtonState != buttonState) {     
    //send event to VC showing the button changed
    if(newButtonState)
    {   
      Serial.println("VC.TriggerEvent&&Button.Pressed");
    }
    else
    {   
      Serial.println("VC.TriggerEvent&&Button.State.Released");
    }
    buttonState=newButtonState;
  }

Then you can use the event to trigger any commands in VC that you like.

The updated Arduino sketch is attached.