Initialising multiple drivers in RadioHead

I want to know how i could initialise multiple drivers in radiohead and also what are managers in radiohead.

If it is the normal way, just like you would do for a single driver…then…my code gets stuck at driver.waitPacketSent().

This is my code.

#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

//RH_ASK driver;
RH_ASK driver0(6000,D7,D1);
RH_ASK driver1(6000,D7,D5);
RH_ASK driver2(6000,D7,D4);
RH_ASK driver3(6000,D7,D8);

int c = 0;

void setup()
    //pinMode(LED_BUILTIN, OUTPUT);
    Serial.begin(9600);    // Debugging only
    if (!driver0.init())
         Serial.println("Driver 0 init failed");
    if (!driver1.init())
         Serial.println("Driver 1 init failed");
    if (!driver2.init())
         Serial.println("Driver 2 init failed");
    if (!driver3.init())
         Serial.println("Driver 3 init failed");

void loop()
    const char *msg0 = "A0";
    const char *msg1 = "A1";
    const char *msg2 = "A2";
    const char *msg3 = "A3";

    driver0.send((uint8_t *)msg0, strlen(msg0));
    driver1.send((uint8_t *)msg1, strlen(msg1));
    driver2.send((uint8_t *)msg2, strlen(msg2));
    driver3.send((uint8_t *)msg3, strlen(msg3));

    //digitalWrite(LED_BUILTIN, HIGH);
    //digitalWrite(LED_BUILTIN, LOW);

The code works with the single drivers on all the mentioned pins. The pins are so because i switched to an ESP8266. It wont go past driver0.waitPacketSent();

I am using inexpensive RF module transmitters to send some values for now. That’s it. I plan to make a distance calculating program based on Time of Flight of the RF and finally try to get location of a mobile object indoors.

It does not make sense to have multiple emitters - only one will be able to speak at a given time anyway as it’s taking ownership of the frequency (and it’s interrupt driven)

The overhead of the protocol might make it pretty tough to do anything meaningful for ToF

It does not make sense to have multiple emitters - only one will be able to speak at a given time anyway as it’s taking ownership of the frequency (and it’s interrupt driven)

So as you can see from the code, no two emitters are working at the same time. At a time only one is transmitting. I have 4 drivers for 4 different emitters placed around the room.

What does 'interrupt driven' mean?

There is thiss approach, another 'could be'(i'm not sure) to use single transmitter board which has 4 different antenna placed around the room, emitting different messages one at a time. Now to my mind, this would only work of i get the ToF from the antenna end to the reciever and not from the emitter board to the reciever.

The overhead of the protocol might make it pretty tough to do anything meaningful for ToF

I didn't understand this, could you pls explain..
If you are saying getting ToF is not possible through this, could you refer to a source where something like this could be acheived.

I see what you had in mind but won’t work

From source code

    /// Constructor.
    /// At present only one instance of RH_ASK per sketch is supported.  <<==== 
    /// \param[in] speed The desired bit rate in bits per second
    /// \param[in] rxPin The pin that is used to get data from the receiver
    /// \param[in] txPin The pin that is used to send data to the transmitter
    /// \param[in] pttPin The pin that is connected to the transmitter controller. It will be set HIGH to enable the transmitter (unless pttInverted is true).
    /// \param[in] pttInverted true if you desire the pttin to be inverted so that LOW wil enable the transmitter.
    RH_ASK(uint16_t speed = 2000, uint8_t rxPin = 11, uint8_t txPin = 12, uint8_t pttPin = 10, bool pttInverted = false);

General Precise Triangulation or multilateration in space (what size?) based on RF is mostly out of reach with basic arduino and typical budgets. Look it up it’s a frequent question

But, according to RadioHeads documentation,

In some specialised use cases, it is possible to instantiate more than one Driver and more than one Manager.

But no where can i find how.

Yes yes i want to go for ‘multilateration’, not a huge space, a room sized space, for VR actually or even smaller for some cases, a few meters. I see what you mean, that it is not possible with arduinos…what abt Raspberry Pis or something?

Never done it - electromagnetic waves travel at speed of light in vacuum - pretty close in open air (The actual speed through a material is dependent upon the optical density of that medium. Different materials cause a different amount of delay due to the absorption and reemission process.)

If you are 3m away from the source it takes 10 nanosecond to go from source to receiver and if you want precision of 3cm you’ll need to differentiate a signal at the nanosecond level and sub nanosecond if you want 1cm précision

A typical Arduino at 16Mhz executes 1 instruction in 62.5 nanosecond... so you see the issue

A Raspberry Pi 4 features a BCM2711B0 System on Chip, a quad-core Cortex-A72 processor clocked at up to 1.5GHz so assuming you can use the 4 cores in parallel You could execute only 4 to 6 instructions in a nano second...

This is rally talking at electromagnetic wave level - if you send a frame that bounced off walls with a time stamp or ID of emitter and plan to decide location based on this you are likely off by a huge factor

GPS system work with atomic clocks (not cheap) and because they are quite far away from earth but you don’t get cm precision anyway...

May be you want a rotating lidar on your mobile - looking at room geometry ? Ultrasound travel also slower - that’s why such distance sensor work on an arduino

Yeah so i went ahead with using the RPi but as it seems with three libraries and techniques that i tried to work the RF modules with are themselves very slow.
I mean the data i was getting by simple codes in the arduino were way faster than this. Its taking like more than half seconds to just fetch the RF data message.

Is there a simpler method that just fetches the data from the Pi? without too much delay. I have tried rpi-rf, rcswitch(433utils), pivirtualwire up till now..

I don't know what you are trying to achieve. I told you you can't get indoor geolocation by sending around messages through a 433MHz ASK radio and trying to decode those...

Then without any code I can't tell you what's wrong in getting your messages... You might want to go also to a RPi forum as you are likely to find more skilled participants there than here.

sorry can't help.

Alright alright, lets skip the geolocation thing for now.

Can you tell me if i could make a simple demux circuit where in i send my data signal and 2 select(enable) signals to one of the four transmitter data pins. Is it possible?

sample diagram:

so what i would be doing is sending s1 = HIGH and s2 = LOW and my radiohead driver would have its driver for the transmitter at pin 12 of arduino and so the fourth wire of the demux would be activated and sending the rf data from the arduino pin 12. Or i could instead switch the VCC or GND pins of the rf modules. How would i be doing this...making the demux or anything elsse...what would be required.

One of the challenge is that the library you use explicitly states it's not meant to be instantiated multiple times.

You could instantiate it only once and try to demux the data link, but I've never looked into the details of what the setup of the module is, what data is being kept in the instance to represent the state of the RF module etc

May be you'll need to formally shutdown the RH_ASK driver instance (not sure with which method), switch with DEMUX to a new RF module, and activate again the new RH_ASK driver instance (driver.init()) for things to work OK...

May be that will work.

Alternatively - as arduino costs are low - you could have 4 arduino, driving each their own RF module, and managed by a 5th arduino through serial bus communication and a small protocol you would write on the master to control those slaves. that would make things much simpler...