I have bought this 433MHz ASK transceiver link kit.
Now, with Arduino, I want to send signals with these modules.
At first, to analyse, I've built the following: Receiver: Vcc to 5V, GND to GND, out-Data to pin10(shouldnt matter which pin to use) Transmitter: Vcc to 5V, GND to GND, in-Data via a button to 5v and a in-data via a resistor to GND (look picture)
That means:
I press the button: transmitter gets 5V as input
I dont press the button: transmitter gets 0V as input
Then I wrote a simple program to check what is received (because it's ASK modulation, it should be 5V or 0V (proved with analog in))
I used "digitalRead" and looked for changes, that means, in the loop , i have:
void loop()
{
int nowstate = digitalRead(pin);
if (nowstate != laststate)
{
Serial.println(micros());
laststate = nowstate;
}
}
The results are the x-values for a graph
Why is it always up and down when I send nothing?
How can I receive/send signals and read them?
16 mS cycle time is 62.5 Hz. If the pulse width is actually 8.333... milliseconds instead of 8.0 then you are probably picking up interference from something running off 60Hz AC.
Because the receiver only detects "signal" or "no signal" it is sensitive to any noise in that frequency range. That's the trouble with using $5 radio sets.
I suspect more likely that the OP's scope ground lead wasn't well connected. The 433 MHz radios are virtually un affected by 60HZ 'interference' and not quite AM but On Off Keying and the rF part of the receiver are relatively insensitive to anything more than 10 - 20 MHz away from the intended (Tuned) frequency. They are super-regenerative receivers with an RF stage to prevent the regen oscillator (detector) from radiating as much junk as a "normal" Super-regenerative receiver would. Although Extremely sensitive for the power radiated by the transmitter they suffer from being "Broad as a barn door" in other words while having 10uV sensitivity they also have 50 to 100 KHz wide detection windows especially if mistuned and that can be metal near the receiver coil and or antenna on some.
They also need regular data transitions in order for the receivers data slicer to be able to figure out what is a 1 and what is a 0.
Most that I have played around with need a minimum transition rate of around 90 bps or more, otherwise the recievers AGC
thinks that there isnt any input signal , and starts winding the gain up.
The IF bandwidth seems to be 2 -3 Mhz wide on most.
Virtualwire takes care of all that.
The transmitter sends out bytes to give the receiver a chance to get in sync, then it sends the manchester encoded data.
Very nice library.
Unfortunately, Virtualwire didnt work. The output was like this:
"
Sent
Timeout
"
So, it didnt receive an answer
However, I want to know HOW the signal is transmitted at all.
This is supposed to be connected to the pin that is providing the data to transmit. Why is it connected this way?
Thats what i did later, too. I wanted to test if a signal is transmitted
I expected that the receiver gives 5v at data out if 5v is supplied to transmitter's data in and receiver has 0v at data out if transmitter gets 0v at its data in (but it is NOT !??)
I tried the following:
rx/tx modules at one arduino (have only one) and the following code : (written myself)
// <CODE>; Freitag, 31. August 2012
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 9); // RX, TX // i dont use rx=10 because I want to see how it looks like in a graph
int pin = 8; // RX pin
int ledpin = 13;
int laststate = 0;
unsigned long ausgabe; // micros() nach 70min UEberlauf -> genug Zeit
unsigned long ausgabe_ = 0;
unsigned long micros_ = 0;
byte i = 0;
boolean oddnow = false;
void setup()
{
Serial.begin(9600);
Serial.println("pulse_in raw^2, <v2.4>; 31.8. - 23.9. 2012\n");
pinMode(ledpin, OUTPUT);
digitalWrite(ledpin, LOW);
pinMode(pin, INPUT);
//digitalWrite(pin, HIGH);//pullup
mySerial.begin(9600);
mySerial.println("Hello, world?");
}
void loop()
{
unsigned long myc = micros();
if (Serial.available())
mySerial.write(Serial.read());
if ((myc - micros_) / 100 >= 1000 * 1000 * 5) // 5 Sekunden
{
micros_ = myc;
// mySerial.write(i); //just test;dont execute
i++;
}
int nowstate = digitalRead(pin);
if (nowstate != laststate)
{
oddnow = !oddnow;
ausgabe = myc;
Serial.println(ausgabe);
if (oddnow) // only every second time
{
unsigned long diff = ausgabe - ausgabe_;
if ((diff < 7000) || (diff > 12000)) // if dutycicle is MUCH different
{
//Serial.print(" D = ");
//Serial.println(diff); // bewirkt anderen Duty-Cycle falls zu hauefig angewendet
digitalWrite(ledpin, !digitalRead(ledpin));
}
}
ausgabe_ = ausgabe;
laststate = nowstate;
}
}
So basically a led changes it state (on->off / off->on) if dutycyle(?) changed . AND it worked.
I know, that it is a very bad technique but it shows that it could work.
What happens here?:
Why does the receiver has an output 0V / 5V changing rapidly ?
The Vitualwire Library only supports half duplex transmission.
ie you can only send or receive, but not both at the same time.
So you will need 2 Arduinos to implement vitualwire.
Its extremely hard to implement full duplex Manchester coding in software
in the one Microcontroller.
Actually, I don't know if the signal is Manchester encoded. The seller told me that it doesn't use encoding/decoding functions.
Does it has to use any kind of encoding or could I do it myself, that means: sending encoded data and receive and then decode it manually.?
I still want to know WHY there are these up and downs in what I recorded of the receiver (referring to the graph).
9600 bps is right at the upper limit of those receivers, and you would do better by trying 4800 bps or less.
Also, if the receiver and the transmitter are physically close to each other, lime 1 M or less apart, the receiver will overload
from the transmission, so place them a bit further apart.
or could I have to use a pull down(?) resistor to avoid a read from random data that is not actually given out by the rx?
So maybe if the receiver doesn't give me anything at its pin, there might be read a wrong voltage. (referring to "bouncing buttons") or is it very different between different modules?
By the way:
I think, am really sure, that the up and downs in the raw read graph output were caused by the lack of a pulldown. I checked the following: read the value digitalRead(8) of pin 8 without anything but a cable put in pin8 - not more, thats all. Then touched the cable, moved it and the values changed rapidly (I think that is what is understood by "BOUNCING").
Then touched the cable, moved it and the values changed rapidly (I think that is what is understood by "BOUNCING").
No, that is a floating pin.
Bouncing refers to switches making intermittent contact as they open and close.
or could I have to use a pull down(?) resistor to avoid a read from random data that is not actually given out by the rx?
No. The receiver is holding the pin HIGH or LOW as appropriate. Your issue is likely to be that your cheap transmitter and/or receiver are not immune from electrical interference - before or after the data is converted to over-the-air form and before or after it is converted back from over-the-air form.
That is why those radios have such low baud rates and range, and are generally not advised for serious transmission of critical information.
Have a look at using Xbee modules .
You can get an Xbee shield for your Arduino, and Xbee to Serial converters exist which you can connect your PC too.
The Xbee modules do all the hard work of encoding the serial data, so work just like a hardwired connection.
if you want bi-directional 433 comms then the virtual wire will work fine its just you cannot have full duplex you will have to do a master slave configuration or implement a collision detection implementation if you need multiple masters or have different frequency for tx vs rx, but that is not usually any better if more than 2 devices etc..
the 433 tx rx modules use the same frequency and hence you only want one talking at any given time its nothing to do with software its to do with airwaves !
i use 20 sensors all talking to a base station in 433 with time cycling and a randomiser to minimise collisions but i have also made my second generation system using tx and rx on a single module utilising a master slave configuration where you do get bi-directional communications.
I use the Atmega 328 in sensors and repeaters and the Atmega 1280 in our base station because this handles SMS messaging of alarms, keyboard, LCD display , 434 RX , sounder, USB to PC , SD card, and USB host for writing info to Pen drives (so needs a little bit more horse power
The sensors work off 2 AA and utilising sleep and watch dog I get 4 - 5 years life - monitors battery life, 3 digital temperature sensors with error rejection, and lost transmission recovery over 500M range.
RF transmiters and receivers only send and receive digital values, 1 and 0, mounted on a radio frecuency with some kind of modulation: Amplitude, frequency or phase.
There's neither manchester nor any other kind of encoding or decoding method involved in this RF process yet. You have to choose one.
Any kind of noise affects RF, so 1 and 0 can be received from the noise, but it's random! If you try to read what 1s and 0s are received, you'll get many of them, even when your transmiter does't transmit. So you must use an encoding/decoding method to recognize the 1s and 0s you receive (and how you send them). Manchester is a method. There are others, for example the one used by Holtek (http://www.holtek.com/pdf/consumer/6p20v170.pdf)
Generic RF remote controls use this holtek chip to encode and decode. I made a program to decode holtek encoding method and works fine. It in this forum, you can check (http://arduino.cc/forum/index.php/topic,129201.0.html)
Yes I know, I consulted VirtualWire for that issue. However, when I started the thread I had only one Arduino and so couldn't check whether they work. And full duplex for one Arduino was not possible for me to work on, because this is not worth the effort. And now with my two Arduinos it works great.
VirtualWire also includes some kind of checksum (CRC) so shouldn't get noise in.