Hi everybody!
I am in trouble… I have 10x Arduino uno, 10x cheap receiver, 10x cheap transmitter, 10x relay. I want… to control light bulbs that are distant from each other. Static idea e.g. 2 seconds light, 3 seconds dark, 4 seconds light and loop. How to use a Board with a transmitter so that the rest will start after that one? I need to synchronize them.
There are indeed good souls here. Have you got the basics to work? Like, make a single Arduino make a light blink like that? Without the sync and other units, etc. ?
My first thought would be to have a single transmitter instructing the other nodes when to turn on/off, so one Arduino Uno with a transmitter and some number of Arduino Unos with a receiver.
One approach would be to use a standard library for transmit/receive like RadioHead. The receiver node might then be configured to recognize a particular character as the command to turn on and a different character to turn off. e.g. "A" turns on the first channel, "a" turns it off, "B" turns on the second channel, and so forth.
The advantage to such a scheme is that the sequence can be changed by reprogramming only the transmit node. A disadvantage is that missed messages may momentarily get the display out of sync, but the occasional error may be acceptable in this application.
This should be a fairly straightforward extension of the ASK transmit and receive example code.
From what you have described, I'd definitely agree with the architecture proposed by @MrMark in that you have a master which controls X slaves, telling them to switch their lights on and off according to a schedule. To minimise the consequences of a failed transmission, redundantly send to each slave, say every 100ms, its current status (on or off).
The interesting challenge would be to devise a clean C++ representation of the schedule of on and off periods for each slave and the code to interpret it.
Using just 4 arduino pins , you could personalise each slave (up to 16 with 4 pins) so each slave would have identical code.
Thank U for responds. Any idea how to transform this basic code (if something I missed sorry, using phone right now) for receiver to make lets say a simple blink on some pin. Because right now it just printing some buffer values.
I use max msp so I understand more or less working rules but I don’t have experience with c/c++.
</> #include <RH_ASK.h> #ifdef RH_HAVE_HARDWARE_SPI #include <SPI.h> // Not actually used but needed to compile #endif
Well, if you've received the message "Got:" etc. then you are doing well.
I've added 3 lines (untested) to your code which should light a led on pin 13 (also the Uno's built in led) the first time the message "Got:" appears and marked these "// ***"
#include <RH_ASK.h>
#ifdef RH_HAVE_HARDWARE_SPI
#include <SPI.h> // Not actually used but needed to compile
#endif
RH_ASK driver;
const uint8_t LedPin = 13 ; // your choice for the LED // ***
void setup()
{
pinMode( LedPin, OUTPUT ) ; // ***
#ifdef RH_HAVE_SERIAL
Serial.begin(9600);
if (!driver.init())
#ifdef RH_HAVE_SERIAL
Serial.println("init failed");
#else
;
#endif
}
void loop()
{
uint8_t buf[RH_ASK_MAX_MESSAGE_LEN];
uint8_t buflen = sizeof(buf);
if (driver.recv(buf, &buflen))
{
int i;
driver.printBuffer("Got:", buf, buflen);
digitalWrite( LedPin, HIGH ) ; // ***
}
}
To develop this idea and to reduce the number of messages, I would suggest sending every 100ms to all slaves one common message containing the status of the entire network - say in the form of an int16 value, where each bit will represent the state of one receiver - on or off
Thank U for all answers. After few updates in code it works with external bulb, but unfortunately I see that transmitter and receiver have externally short distance (bad quality). I have those two:
May I replace just transmitter for something better and keep this receiver? Or any other ideas? Need to place it in city park, let’s say 70m max distance, no buildings, walls etc… just few tress.
That receiver is not very good. It is a "regenerative receiver" which has poor selectivity compared to "superheterodyne" receivers. The transmitter should be good enough.
People who have tested a number of receivers seem to prefer the RXB-12 modules which would work with the same code as the receiver you are currently using. One can also improve performance with a better antenna arrangement.
Yes, it is true. But it does work. I used one to receive from a transmitter located with 2 floors between, about 20m apart. It worked perfectly.
So, I suggest ordering a better receiver, but don't give up just because people want to use the best parts. Make sure you have about 7" wire antennas on both modules.
Indeed, poster "jremington" claims to have gotten 300 m range with those devices and his dipole antenna in the thread I linked. I believe poster "srnet" has done a lot of testing with various radios as well.
The problem with poor selectivity in a receiver is that performance degrades much more rapidly if there are strong emitters at nearby frequencies, so a setup that works in a rural environment might work much less well in an urban environment.
Thank U all for help, finally I decided to just connect controllers with lamps and let them start together... was working at the beginning then had diff in blinking. However I have good feedback and experience so next time I will expand this. Thanks one more time