Go Down

Topic: Need Help getting started (Read 2165 times) previous topic - next topic

Julius217

I'm am building an RC Tank. I'm using two MKR 1000 boards. I've got a 433 MHz Transmitter and Receiver modules. I found some code that is incomplete can anybody help me get it to work so that I can transmit data?

Transmitter Code

// oddWires: this is a simple exmaple that shows the 433Mhz module working. It sends a simple message to the receiver

#include

void setup()
{
  // Initialise the IO and ISR
  vw_set_ptt_inverted(true);               // Required for RF Link module
  vw_set_tx_pin(10);                       // pin 10 is used as the transmit data out to the TX Link module,

                                           // change this to suit your needs.
}

void loop()
{
  rfSend("this is a test");
  delay(5000);
}


void rfSend(String message)
{
  char output[100];

  message.toCharArray(output, 99);

  vw_setup(2000);
  vw_send((uint8_t *)output, strlen(output));
  vw_wait_tx();                          // Wait for message to finish
  vw_setup(40);
}

 
Receiver Code

// oddWires: this is a simple example that shows the 433Mhz module working. It receives simple message from the transmitter

#include

#define rxPin 2


const int ledPin =  13;      // the number of the LED pin
int ledState = LOW;          // ledState used to set the LED
long onMillis = 0;           // will store last time LED was updated


void setup()
{
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);

  // Initialise the IO and ISR
  vw_set_ptt_inverted(true);          // Required for RX Link Module
  vw_setup(2000);                     // Bits per sec
  vw_set_rx_pin(rxPin);               // We will be receiving on pin 2 ie the RX pin from the module connects to this pin.
  vw_rx_start();                      // Start the receiver
}

void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;

  if (vw_get_message(buf, &buflen))   // check to see if anything has been received
  {
    int i;
    // Message with a good checksum received.

    for (i = 0; i < buflen; i++)
    {
      Serial.print((char)buf);     // print the received data stored in buffer to the serial monitor
    }
    Serial.println(" ");
    digitalWrite(ledPin, HIGH);
    onMillis = millis();
  }

  if (millis() - onMillis > 100 && onMillis > 0)
  {
    onMillis = 0;
    digitalWrite(ledPin, LOW);
  }
}

AWOL

Please remember to use code tags when posting code
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

vinceherman

Why do you think it is incomplete?

What do you expect it to do?
What does it actually do?
How do those 2 differ?


jremington

If you plan to use VirtualWire, start with the examples that you download with the library.

The examples you improperly posted use Strings, which is a bad idea and should be avoided.

Willpatel_Kendmirez

Why do you think it is incomplete?
Code: [Select]
#include

OP probably should have found that the sketches don't compile, due to (at least) the incomplete #include's.

start with the examples
(So not the "exmaples"? ;) )

Code: [Select]
// oddWires: this is a simple exmaple

Julius217

I don't know if the MKR 1000 has existing code that would be used with the #include or if that's something that the person made and didn't make available.

Where I got the code:
https://www.oddwires.com/433-mhz-communication-between-arduinos/

jremington

Download VirtualWire and working examples here.

Julius217

I'm not using Virtual Wire. I'm using Radio Frequency

Julius217

I just found a Library for MHz RF in the Library Manager, ESPiLight by Puuu, would it work as complete base for the transmitter and receiver that I am using?

The Transmitter and receiver:
https://www.oddwires.com/433-mhz-transmitter-and-receiver-modules-great-for-arduino/

jremington

#9
Jan 12, 2019, 06:00 am Last Edit: Jan 12, 2019, 06:03 am by jremington
Quote
I'm not using Virtual Wire. I'm using Radio Frequency
You certainly are confused. These function calls:
Code: [Select]
vw_set_ptt_inverted(true);          // Required for RX Link Module
  vw_setup(2000);                     // Bits per sec
  vw_set_rx_pin(rxPin);               // We will be receiving on pin 2 ie the RX pin from the module connects to this pin.
  vw_rx_start();                      // Start the receiver
}

are very obviously to functions in the VirtualWire library

It could be that someone has taken that library and renamed it, as a result of some peculiar mental problem, but that would be yet another reason to stay far away from wherever you got that code.



Julius217

I tried the Virtual Wire link and tried to upload it, but it says that it is not compatible with the MKR 1000

jremington

Please read and follow the directions in the "How to use this forum" post.

Julius217

Would PWM work for sending a signal to the transmitter? If so, how would I program it for the 27 different signals I would need to send?

AWOL

Would PWM work for sending a signal to the transmitter? If so, how would I program it for the 27 different signals I would need to send?
That's how "digi-prop" RC systems have worked since the 1970s, albeit with far fewer channels, by combining PWM pulses into a PPM stream.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Julius217

The reason there are so many "channels" is because I'm going to be using 3 switches on the controller and 3 motors on the tank.
I've never messed with PWM before, so how do I program it to do PWM?

Go Up