Pages: [1]   Go Down
Author Topic: rc-switch and bash commands  (Read 645 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello.
First of all this concept was main reason i ended up buying arduino smiley-sad

Im trying to set up router with custom firmware (tomato based) and on that router device is recognised as /dev/ttyACM0

For example
Code:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(10);
}
void loop() {
mySwitch.switchOn("11001", "01000");
}

works perfect with my setup - device connected to receiver responds and turns on.
The question is - how can i control that from bash on router.
I tried with:

Code:
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableTransmit(10);
}
void loop()
{
}

uploaded to arduino
and echo command to arduino:

echo "mySwitch.switchOn(\"11001\", \"01000\");" > /dev/ttyACM0

but it doesnt seem to work
arduino is blinking and RF transmitter is not smiley-sad
any sugestions for arduino and linux newbie?
Thank You in advance.
Logged

Temple, Texas
Offline Offline
Sr. Member
****
Karma: 14
Posts: 354
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not sure I can help, but I have experience using Tomato and WRT54g as a lawn sprinkler pump controller and I'm interested in what you're attempting.

As I understand it your using a router that has a usb host port into which you've plugged the Arduino?  Or, you have wired up the router RX/TX outputs to Arduino.  (which)

What does "Works perfect with my setup" mean?  (Obviously not working perfect otherwise you would not be asking).

I suspect what may be missing is your understanding that there needs to be some Arduino code in setup() and loop() which will be looking to read characters from the serial port (which were sent by your bash script), interpreting them, and then sending something appropriate to "mySwitch".  But I'm not quite sure, I may be misinterpreting what you've tried.  Also, I am not familiar yet with RCSwitch so I'm not sure what type of commands you're wanting to send.

It might be as simple as (gross pseudcode):
Code:
void loop:
  cumulate characters from serial
  if I've received 10 characters:
     split into first5chars and second5chars
     mySerial.switchOn( first5chars, second5chars)
 
But I kinda doubt it smiley

Cheers,
John

Logged

Pages: [1]   Go Up
Jump to: