Wireless connection via 433 MHz with the Arduino
FunduinoPublished on
Daten drahtlos zwischen zwei Arduinos übertragen
You need this
433 MHz Radio Module Set - Transmitter and Receiver, 3.3-5 V
2,90 € *Item no. F23108773About the product — 433 MHz Radio Module Set - Transmitter and Receiver, 3.3-5 V
Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
11,12 € *Item no. F23107480About the product — Funduino UNO R3 Microcontroller - ATmega328P, 16 MHz, for Arduino
830-point Breadboard - solderless breadboard for Arduino
2,90 € *Item no. FUN-1010553About the product — 830-point Breadboard - solderless breadboard for Arduino
Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
1,74 € *Item no. FUN-1010558About the product — Breadboard Cables Male-to-Male - 40 Pieces, 20 cm
Breadboard cables male-female - 40 pieces, 20 cm
1,74 € *Item no. FUN-1010554About the product — Breadboard cables male-female - 40 pieces, 20 cm
LED 5 mm - 100 Pieces, 5 Colors, 2 V
1,97 € *Item no. F23107316About the product — LED 5 mm - 100 Pieces, 5 Colors, 2 V
Resistor Assortment 100 Pieces - 5 Values 100 Ω to 10 kΩ, 0.5 W
1,72 € *Item no. F23107216About the product — Resistor Assortment 100 Pieces - 5 Values 100 Ω to 10 kΩ, 0.5 W
All 7 parts together 24,09 € *Ready to ship immediately · Delivery time: 1-3 business days
* All prices include statutory VAT, plus shipping costs.
The 433 MHz radio transmitter module
1 / 2
Program code - 433 MHz radio transmitter
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
mySwitch.enableTransmit(10); // The transmitter is connected to pin 10
}
void loop() {
mySwitch.send(1234, 24); // The 433 MHz transmitter sends the decimal number "1234"
delay(1000); // One-second pause, then the sketch starts over
}The 433 MHz radio receiver module
1 / 2
Program Code – 433 MHz Radio Receiver
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup()
{
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver is connected to interrupt pin "0" - on the UNO, that is pin 2
}
void loop() {
if (mySwitch.available()) // If a code is received...
{
int value = mySwitch.getReceivedValue(); // The received data is stored in the variable "value".
if (value == 0) // If the received data is "0", "Unknown code" is displayed.
{
Serial.println("Unknown code");
}
else // If the received code is usable, it is sent to the Serial Monitor here.
{
Serial.print("Received: ");
Serial.println( value );
}
mySwitch.resetAvailable(); // The receiver is "reset" here
}
}Expansion: Transmit signals between two microcontrollers
1 / 2
Program code – radio transmitter with push button
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
int taster = 7; // The word "taster" now stands for the value 7.
int tasterstatus = 0; // This variable stores whether the button is pressed or not.
void setup() // The setup starts here.
{
mySwitch.enableTransmit(10); // The transmitter is connected to pin 10
pinMode(taster, INPUT); // The pin with the button (pin 7) is now an input.
}
void loop()
{ // This brace opens the loop section.
tasterstatus = digitalRead(taster); // Pin 7 is read here (command: digitalRead).
if (tasterstatus == HIGH) // Processing: If the button is pressed (the voltage signal is high)...
{ // Open the program section of the IF statement.
mySwitch.send(5678, 24); // The 433 MHz transmitter sends the decimal number "5678"
delay(50); // 50 millisecond pause
} // Close the program section of the IF statement.
else // ...otherwise...
{ // Open the program section of the else statement.
mySwitch.send(1234, 24); // The 433 MHz transmitter sends the decimal number "1234"
} // Close the program section of the else statement.
} // This final brace closes the loop section.Program code - radio receiver with LED
#include <RCSwitch.h>
int LED = 12;
RCSwitch mySwitch = RCSwitch();
void setup()
{
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver is connected to interrupt pin "0" - on the UNO, that's pin 2
pinMode(LED, OUTPUT); // The pin with the LED (pin 12) is now an output.
}
void loop() {
if (mySwitch.available()) // If a code is received...
{
int value = mySwitch.getReceivedValue(); // The received data is stored in the variable "value".
if (value == 0) // If the received data is "0", "Unknown code" is displayed.
{
Serial.println("Unknown code");
}
else // If the received code is usable, it is sent to the Serial Monitor here.
{
Serial.print("Received: ");
Serial.println( value );
if (value == 5678) // Processing: If the Arduino receives the number "5678", then...
{ // Open the program section of the IF statement.
digitalWrite(LED, HIGH); // ...the LED should light up
delay(500); // for 0.5 seconds (500 milliseconds).
digitalWrite(LED, LOW); // Then the LED should be off.
} // Close the program section of the IF statement.
}
mySwitch.resetAvailable(); // The receiver is "reset" here
}
}Extension: Transmit measurement data wirelessly
1 / 2
Program code – radio transmitter with temperature sensor
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
int TMP36 = A0; // The sensor is connected to analog pin A0. From now on, we’ll call the pin "TMP36".
int sensorwert; // Create a variable for the sensor reading.
int temperatur = 0; // The temperature value will later be stored in the variable "temperatur".
void setup() // This is where setup begins.
{
mySwitch.enableTransmit(10); // The transmitter is connected to pin 10
}
void loop()
{ // This brace opens the loop section.
sensorwert = analogRead(TMP36); // Read the sensor value.
temperatur = map(sensorwert, 0, 410, -50, 150); // Convert the sensor value using the "map" command.
mySwitch.send(temperatur, 24); // The 433-MHz transmitter sends the temperature as a decimal number.
delay(1000); // Pause for one second.
} // This final brace closes the loop section.Program code - radio receiver with warning LED
#include <RCSwitch.h>
int LED = 12;
RCSwitch mySwitch = RCSwitch();
void setup()
{
Serial.begin(9600);
mySwitch.enableReceive(0); // Receiver is connected to interrupt pin "0" - on the UNO, this is pin 2
pinMode(LED, OUTPUT); // The pin with the LED (pin 12) is now an output.
}
void loop() {
if (mySwitch.available()) // If a code is received...
{
int value = mySwitch.getReceivedValue(); // Received data is stored in the variable "value".
Serial.print("Temperature: ");
Serial.println( value );
if (value >= 25) // Processing: If the temperature is 25 °C or higher...
{ // Open the program section of the IF statement.
digitalWrite(LED, HIGH); // ...the LED should light up
} // Close the program section of the IF statement.
else // ...otherwise...
{ // Open the program section of the else statement.
digitalWrite(LED, LOW); // ...the LED should be off.
} // Close the program section of the else statement.
mySwitch.resetAvailable(); // The receiver is "reset" here
}
}Rate the instructions