1

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?

  • You don't say how you power the Arduino n2 when it's connected to the PI. If your powering it from the PI's USB and have other peripherals connected there maybe insufficient current. – mintyfreshpenguin Nov 1 '17 at 13:45
  • Are you sure the Arduino can do Virtual Wire and serial at the same time? Both are CPU intensive. – joan Nov 1 '17 at 14:58
  • @mintyfreshpinguin : Hi. Thanks for your answer. I'm powering the arduino with an external source (12V 6A). When i power it, the RX LED is blinking (so the arduino receives data) but when i connect the USB cable to the raspberry, the LED stops blinking and in receive nothing on the raspberry. – kikiz Nov 1 '17 at 16:51
  • @joan : Hi joan, thank you too for your answer. I already tried to use virtualWire and serial (sending 433MHz data to another arduino by serial) and it worked perfectly. – kikiz Nov 1 '17 at 16:52
  • Did you use USB serial to the other Arduino? – joan Nov 1 '17 at 17:00
1

I think decoding is the problem. Try this code.....

import serial
ser= serial.Serial('/dev/ttyUSB0', baudrate = 9600,timeout=0)
value = ser.readline().decode('ascii')
print('Value is : '.format(value))
  • Hi, thanks for your answer. Unfortunatly, this doesn't work. I have multiple lines with 'Value is :' but no data... – kikiz Nov 5 '17 at 17:43
  • The thing extremly weird is that the RX LED of the arduino stops blinking when i connect the usb cable to the raspberry... – kikiz Nov 5 '17 at 17:56
0

I'm going to go out on a limb here and say it's not your Arduinos that's the problem. (It's not even your attitude about the problem that's the problem.)

Since you have checked the data communication over the Serial Monitor (test 1), it is evidently working when connected to some sort of computer. I would double-check your Python code on the RPi.

It's either not connecting to the Arduino correctly or it's not displaying the results correctly. I would write a super basic sketch for the Arduino just to test your serial connection to the RPi.

Well, that's all I have. I don't have a ready way to test your code, so.... Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.