Transmitting Device: Arduino Micro with 433Mhz Transmitter via VirtualWire and an Ultra Sonic Sensor. Both Connected to 5V and Ground as well as:
Ultra Sonic Sensor: Trigger Pin: 11 Echo Pin: 12 433 Transmitter: Transmitter: 11
my code so far using the NewPing Library for the Sonic Distance Measurement:
#include <NewPing.h>
#include <VirtualWire.h>
#define TRIGGER_PIN 10
#define ECHO_PIN 12
#define MAX_DISTANCE 500
#define ledPin 13
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
void setup() {
vw_set_tx_pin(11);
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
vw_setup(2000);
}
void loop() {
delay(5000);
unsigned int uS = sonar.ping();
Serial.print("Distance: ");
unsigned int Distance = (uS / US_ROUNDTRIP_CM);
Serial.print(Distance);
Serial.println("cm");
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
}
This gives me an output in the Serial monitor like this:
Distance: 40cm
Distance: 39cm
My question: What is the easiest/best way to send the Measurement via 433 MHz.
(in that case 40
or 39
)
I would like to receive this value with a RaspberryPi that has the receiver unit connected to it and is running PIGPIO.
I am pretty sure I don't really get the syntax of Virtual Wire and would appreciate some help on how to prepare and send the Message.