Go Down

Topic: rc-switch and bash commands (Read 805 times) previous topic - next topic

neozerocool

Hello.
First of all this concept was main reason i ended up buying arduino :(

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

For example
Code: [Select]

#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: [Select]
#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 :(
any sugestions for arduino and linux newbie?
Thank You in advance.

johncc

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: [Select]
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 :)

Cheers,
John


Go Up