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); }

Convirtiendo uint8 a char

#include <VirtualWire.h> uint8_t data=10; void setup() { vw_setup(1000); Serial.begin(9600); // Use this for debugging Serial.println("Iniciando"); delay(5000); } String converter(uint8_t num){ char cv[2]; num=num; cv[0]=(num/10)%10+48; cv[1]=num%10+48; Serial.print(cv[0]);Serial.println(cv[1]); return String((char *)cv); } void loop() { data=data+1; String tempo; tempo=converter(data); const char *msg = tempo.c_str(); vw_send((uint8_t *)msg, sizeof(msg)); vw_wait_tx(); Serial.print(data);Serial.print("-");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

Conectar el reciever 433 en los pines:

VCC pin 2 - 5V

GND Pin 12 - GND

DATA pin 38 - GPIO20

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

https://n8henrie.com/2015/03/range-testing-for-wireless-arduino-projects-rf-433-mhz-and-nrf24l01/