0

My setup is: Arduino with 433 cheap transmitter module, photodiode and a laser and 433 receiver connected to Rpi, button.

I've used rpi-rf lib to receive codes. I'm trying to make stopwatch that when i push BTN on Rpi it starts counting and when laser beam is cut, it sends signal to stop the stopwatch. I have no idea how to send signal from receive script to my stopwatch. Later i will post code for stopwatch

Code:

# importing libraries 

from PyQt5.QtWidgets import * 
from PyQt5 import QtCore, QtGui 
from PyQt5.QtGui import * 
from PyQt5.QtCore import * 
import sys 

class Window(QMainWindow): 

    def __init__(self): 
        super().__init__() 

       # setting title 
        self.setWindowTitle("Python Stop watch") 

       # setting geometry 
        self.setGeometry(100, 100, 400, 500) 

       # calling method 
        self.UiComponents() 

       # showing all the widgets 
        self.show() 

    # method for widgets 
    def UiComponents(self): 

        # counter 
        self.count = 0

        # creating flag 
        self.flag = False

        # creating a label to show the time 
        self.label = QLabel(self) 

        # setting geometry of label 
        self.label.setGeometry(75, 100, 250, 70) 

        # adding border to the label 
        self.label.setStyleSheet("border : 4px solid black;") 

        # setting text to the label 
        self.label.setText(str(self.count)) 

        # setting font to the label 
        self.label.setFont(QFont('Arial', 25)) 

        # setting alignment to the text of label 
        self.label.setAlignment(Qt.AlignCenter) 

        # creating start button 
        start = QPushButton("Start", self) 

        # setting geometry to the button 
        start.setGeometry(125, 250, 150, 40) 

        # add action to the method 
        start.pressed.connect(self.Start) 

        # creating pause button 
        pause = QPushButton("Pause", self) 

        # setting geometry to the button 
        pause.setGeometry(125, 300, 150, 40) 

        # add action to the method 
        pause.pressed.connect(self.Pause) 

        # creating reset button 
        re_set = QPushButton("Re-set", self) 

        # setting geometry to the button 
        re_set.setGeometry(125, 350, 150, 40) 

        # add action to the method 
        re_set.pressed.connect(self.Re_set) 

        # creating a timer object 
        timer = QTimer(self) 

        # adding action to timer 
        timer.timeout.connect(self.showTime) 

        # update the timer every tenth second 
        timer.start(100) 

    # method called by timer 
    def showTime(self): 

        # checking if flag is true 
        if self.flag: 

            # incrementing the counter 
            self.count+= 1

        # getting text from count 
        text = str(self.count / 10) 

        # showing text 
        self.label.setText(text) 
  

    def Start(self): 

        # making flag to true 
        self.flag = True

    def Pause(self): 

       # making flag to False 
        self.flag = False

    def Re_set(self): 

        # making flag to false 
        self.flag = False

        # reseeting the count 
        self.count = 0

        # setting text to label 
        self.label.setText(str(self.count)) 

  

  
# create pyqt5 app 
App = QApplication(sys.argv) 
  
# create the instance of our Window 
window = Window() 
  
# start the app 
sys.exit(App.exec()) 
0

You can think of the radio modules as a signal converter: the sender modulates a 433MHz wave according to the input signal A (amplitude shift keying). The receiver demodulates the signal and provides the signal A at the output.

You can e.g. use UART to handle the actual communication:

  • connect the arduino's Tx-Signal to the senders input
  • connect the receivers output to Rx of the Raspberry Pi
  • perform communication with Serial.print() (arduino) and pyserial (Pi), just like you would implement an ordinary serial communication. The radio part is completely irrelevant for you.
2
  • Thing is that Arduino will be 100 meters away. So i really need radio communication, it's crutial. I managed to get radio transmission working but I don't know how to make receiver script to stop my stopwatch when specific message is sent Jun 17 at 19:59
  • From your point of view, things work exactly the same with radio like they would with a wired connection. You can use the serial functions, because you can feed the radio modules with whatever signal you like (e.g. uart).
    – Sim Son
    Jun 18 at 13:13

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.