• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Aduino to RPi

Status
Not open for further replies.

ibwev

Member
I am trying to send a string from ProMicro 5V to Raspberry Pi 3.

This is the code I am using in the Pi

Code:
/*
  RFSniffer

  Usage: ./RFSniffer [<pulseLength>]
  [] = optional

  Hacked from http://code.google.com/p/rc-switch/
  by @justy to provide a handy RF code sniffer
*/

#include "../rc-switch/RCSwitch.h"
#include <stdlib.h>
#include <stdio.h>
     
     
RCSwitch mySwitch;



int main(int argc, char *argv[]) {
 
     // This pin is not the first pin on the RPi GPIO header!
     // Consult https://projects.drogon.net/raspberry-pi/wiringpi/pins/
     // for more information.
     int PIN = 2;
     
     if(wiringPiSetup() == -1) {
       printf("wiringPiSetup failed, exiting...");
       return 0;
     }

     int pulseLength = 0;
     if (argv[1] != NULL) pulseLength = atoi(argv[1]);

     mySwitch = RCSwitch();
     if (pulseLength != 0) mySwitch.setPulseLength(pulseLength);
     mySwitch.enableReceive(PIN);  // Receiver on interrupt 0 => that is pin #2
     
   
     while(1) {
 
      if (mySwitch.available()) {
   
        int value = mySwitch.getReceivedValue();
   
        if (value == 0) {
          printf("Unknown encoding\n");
        } else {    
   
          printf("Received %i\n", mySwitch.getReceivedValue() );
        }
   
        mySwitch.resetAvailable();
   
      }
     
 
  }

  exit(0);


}
This is the code in ProMicro:

Code:
[#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile

RH_ASK driver(2000, 2, 14, 5);;

void setup()
{

    Serial.begin(9600);   // Debugging only
    if (!driver.init())
         Serial.println("init failed");
}

void loop()
{
    Serial.write("on");
    const char *msg = "Hello World!";
    driver.send((uint8_t *)msg, strlen(msg));
    driver.waitPacketSent();
    delay(1000);
}
This is the result

RFSnifferResult.jpg

This is my wiring schematic:

ProMicroToPi.jpg

This is the signal I am receiving on GPIO27 on the Pi:

AduinoToPi.png

Please help me understand why I am not seeing "Hello World" on the Putty console when I run
Code:
sudo ~/433Utils/RPi_utils/RFSniffer
 

Les Jones

Well-Known Member
Most Helpful Member
The RFSniffer program that you are running on the Raspberry Pi is expecting to see the sort of data stream sent by a remote control keyfob. You are sending an ASCII string at 9600 bauds to it . It will not be able to make any sense of this.

Les.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top