1

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 40or 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.

Peter S
  • 625
  • 1
  • 9
  • 32

1 Answers1

0

Use UART port on RaspberryPi to receive data from UART on arduino. Be careful RaspberryPi is 3.3V and Arduino is 5V. If you connect directly can break your RaspberryPi. Use resister to convert 5V to 3.3V.

dante
  • 984
  • 3
  • 10
  • 24