The goal of my project is to have a power strip that can be switched using an Arduino micro and a relay. The Arduino is driven by commands sent from my Pi 2 B+ via 433MHz RF modules http://www.dipmicro.com/store/RF315PAIR.
Both the RPi and the Ardunio have a Tx and Rx module wired to, so i can have a 2-way communications between them: send commands from the RPi and get confirm too.
The code side of RF communications between them are managed using VirtualWire library (Arduino: https://www.pjrc.com/teensy/td_libs_VirtualWire.html and RPi https://github.com/DzikuVx/piVirtualWire)
What i expect to have is the RPi sending the command to open the relay, the Arduino receiving it, opening the relay and sending the confirm to the RPi.
The problem i'm facing is that the RPi does not receive any signals while it has the Data pin of the antenna (the tx) wired to him.
On the RPi side, both the Tx and Rx are wired to the 3V3 as Vin and to pin 9 (not GPIO9) for GND. The Tx data is connected to GPIO17 and Rx data to GPIO18. For test purpouse the Arduino keeps sending messages every 0.5 seconds and, as far as the Tx is not wired, the RPi is receiving all of them without any problem.
This is the script on the RPi to receive mesages, but i'm quite sure it's not a code problem because the problem comes out even if i plug/unplug the antenna while the script is running
The same configuration, but with another Arduino instead of the RPi works like a charm.
Code: Select all
import piVirtualWire.piVirtualWire as piVirtualWire import time import pigpio if __name__ == "__main__": pi = pigpio.pi() rx = piVirtualWire.rx(pi, 18, 2000) # Set pigpio instance, RX module GPIO pin and baud rate while True: while rx.ready(): print("".join(chr (c) for c in rx.get())) time.sleep(0.1) rx.cancel() pi.stop()
I hope that some of you can point me the right direction to sort out this problem.
Thank you in advance!