Arduino

#include <VirtualWire.h> int data=10; void setup() { vw_setup(2000); Serial.begin(9600); // Use this for debugging Serial.println("Iniciando"); delay(5000); } void loop() { data=data+1; const char *msg = "pp"; vw_send((uint8_t *)msg, sizeof(msg)); vw_wait_tx(); Serial.println(msg); delay(2000); }

Raspberry

Instalar

sudo apt-get install pigpio python-pigpio python3-pigpio

Iniciar el servicio

sudo systemctl status pigpiod.service sudo systemctl start pigpiod.service sudo systemctl status pigpiod.service

Descargar la libreria y descomprimirla, creando el archivo siguiente recibir.py

#!/usr/bin/env python import time import pigpio import vw RX=20 BPS=2000 pi = pigpio.pi() # Connect to local Pi. rx = vw.rx(pi, RX, BPS) # Specify Pi, rx GPIO, and baud. msg = 0 start = time.time() while (time.time()-start) < 300: msg += 1 while rx.ready(): print("Leyendo "+str(msg/10000)+":") print("".join(chr (c) for c in rx.get())) rx.cancel() # Cancel Virtual Wire receiver. pi.stop() # Disconnect from local Pi.

Ejecutar

python recibir.py

Referencias

http://abyz.me.uk/rpi/pigpio/examples.html#Python_vw

http://abyz.me.uk/rpi/pigpio/#Type_3

https://github.com/DzikuVx/piVirtualWire

https://quadmeup.com/virtualwire-support-for-raspberry-pi/

https://forums.raspberrypi.com/viewtopic.php?t=84596