# Detect Signal using GRC and Raspberry pi

**URL:** <https://www.ruby-forum.com/t/detect-signal-using-grc-and-raspberry-pi/252549>\
**Category:** GNU Radio\
**Created:** [June 7, 2019, 7:26pm UTC](https://www.ruby-forum.com/t/detect-signal-using-grc-and-raspberry-pi/252549 "2019-06-07T19:26:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hamza.haras](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecae2f/32.png) [@Hamza.haras](https://www.ruby-forum.com/u/Hamza.haras)\
**Post date:** [June 7, 2019, 7:26pm UTC](https://www.ruby-forum.com/t/detect-signal-using-grc-and-raspberry-pi/252549/1 "2019-06-07T19:26:05Z")

</div>

Hi,

I am trying to simply detect specific signal at specific frequency (as a start) then send signal from raspberry pi to arduino to trigger other command.

From my research I found GRC as best option with hackRF one. I got the signal at monitor as below but as I am totally new in GRC I don’t know which blocks can detect the signal, I think the best way is to record the signal in file then detecting it in future using kind of comparison or by measuring the power.

Please help me to choose appropriate blocks to achieve this result.

The signal to be detected

 ![with%20Signal](https://www.ruby-forum.com/uploads/default/original/2X/6/694d292e9c48c7b55bb1f0063f027ca5bfdd78d0.png)

---

<div class="post-metadata">

**Author:** ![Cufe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/96bed5/32.png) [@Cufe](https://www.ruby-forum.com/u/Cufe)\
**Post date:** [June 30, 2019, 6:52pm UTC](https://www.ruby-forum.com/t/detect-signal-using-grc-and-raspberry-pi/252549/2 "2019-06-30T18:52:39Z")

</div>

Install the rpi\_gpio gem directly to the pi as well as the arduino\_firmata gem.

With these gems you can manipulate the pi’s gpio pins as well as directly control the Arduino.

On the Arduino make sure you load the firmata sketch. This will open the arduino’s serial to the pi and you can control and catch the io stream

---

<div class="post-metadata">

**Author:** ![Cufe](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/96bed5/32.png) [@Cufe](https://www.ruby-forum.com/u/Cufe)\
**Post date:** [June 30, 2019, 7:38pm UTC](https://www.ruby-forum.com/t/detect-signal-using-grc-and-raspberry-pi/252549/3 "2019-06-30T19:38:52Z")

</div>

The code for the firmata. I make a global variable called pin for my short hand… But you can name it anything. I do recommend making it global however.

require ‘arduino\_firmata’  
$pin = ArduinoFirmata.connect # this binds a global variable to connect and communicate with the Arduino.

def firmata\_ver  
puts "Firmata version: #{$pin.version}  
end

# making a method will keep you from having to retype the puts string for the firmata version.

#simple on/off commands for io pins.

def led\_on  
a = proc[$pin.digital\_write 5, true]  
a.call  
end  
#the code method\_name(this case $pin).digital\_write pin\_number, true/false tells the pi to connect with the Arduino and access the io pin and turn it on or off. I used 5 in this example. Setting it to true will turn the pin on.

def led\_off  
a = proc[$pin.digital\_write 5, false]  
a.call  
end

# digital\_write makes the pin a output pin. The next attr\_accessor I will show you is digital\_read. This pulls information about a pin. Let’s make a new method for a new led.

def blue\_led\_on  
a = proc[$pin.digital write 6, true]  
a.call  
b = proc[puts “blue led is #{$pin.digital\_read 6}”)  
b.call  
end

#input pins. These can be trigger pins like buttons. Where output pins sends voltage out, input pins act like a ground pin. It takes the voltage in and uses It for data measurements.

Connect your button to the 3.5v aux of the Arduino. NOT THE 5V PIN! IO pins can only take 3.5 volts and cannot exceed 30ma(milliamps). If it draws more than a led, don’t use the io pins to power it. These are our signal pins.

3.5v pin to button, button to pin #(we will use 7)

button = $pin.pin\_mode 7, ArduinoFirmata::INPUT ;  
While button == true  
if led\_off == true  
puts. $pin.digital\_read 7  
led\_on  
puts $pin.digital\_read 7  
end  
If led\_on == true  
puts $pin.digital\_read 7  
led\_off  
puts $pin.digital read 7  
end  
end

#pwm (pulse width modulation). Makes a output pin produce a square wave.

This is used to control fan speeds, motors, servos, etc.

> **[Arduino Firmata on Ruby](https://shokai.github.io/arduino_firmata/)**

---

<div class="post-metadata">

**Author:** ![AvrilPress](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@AvrilPress](https://www.ruby-forum.com/u/AvrilPress)\
**Post date:** [July 10, 2020, 4:44pm UTC](https://www.ruby-forum.com/t/detect-signal-using-grc-and-raspberry-pi/252549/4 "2020-07-10T16:44:49Z")

</div>

Hi…It looks like modes\_rx consumes too much CPU for it to work, which is a shame, although it is possible to run rtl\_tcp on the Pi and send the data via network cable to another PC running modes\_rx. I’ve tried using a wireless connection but it doesn’t really have enough bandwidth.  
I’m recompiling gnuradio with some more aggressive CFLAGS but I’m not holding out much hope.
