I'm trying to send data to my raspberry PI3 by USB.
Aim : One arduino (n°1) sends data to another by 433Mhz (virtualWire library on arduino) The other arduino(n°2) receives the data and transmits it to the raspberry by USB. This looks pretty simple but i spent several hours without succeed.
Here is my problem :
When i connect the arduino n°2 to the raspberry PI3 by USB, the arduino n°2 doesn't receive 433MHz data anymore.
Code used :
Arduino n°1 : sending data
*#include <VirtualWire.h>
#include <VirtualWire_Config.h>
#include <stdio.h>
#include <string.h>
int t=0;
char* controller="a";
void setup() {
Serial.begin(9600);
vw_set_ptt_inverted(true);
vw_set_tx_pin(14);//Data pin
vw_setup(1200);// speed of data transfer Kbps
}
void loop(){
vw_send((uint8_t *)controller, strlen(controller));
vw_wait_tx(); // Wait until the whole message is gone
Serial.println(controller);
delay(2000);
}*
Arduino n°2 : receiving data from arduino n°1 and sending it to raspberry
*#include <VirtualWire.h>
uint8_t buf[200];
uint8_t buflen = 200;
String message;int i=0;
void setup()
{
Serial.begin(9600);
vw_set_ptt_inverted(true); // Required for DR3100
vw_set_rx_pin(17);
vw_setup(1200); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
}
void loop()
{
if (vw_get_message(buf, &buflen)) // Non-blocking
{
message="";
//Serial.println(char(buf[27]));
for(i=0;i<buflen;i++){
message+=char(buf[i]);
}
Serial.println(message);
}
}*
Raspberry : listening to USB (python code)
*import serial
ser=serial.Serial('/dev/ttyUSB0',9600)
while 1:
print(ser.readline())*
Tests tried :
Communication between the two arduinos while arduino n°2 is not connected to raspberry => The data is received by arduino n°2 (checked by serial monitor)
Communication between arduino n°2 and raspberry => Sending a message which is not in the if (vw_get_message(buf, &buflen)){} works (checked in the shell of the raspberry)
Problem : The receiver 433Mhz of the arduino n°2 is not working when the arduino n°2 is connected to raspberry.
Can anyone help me?