Python Forum
[Tkinter] Anyone know what happened to my button?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Tkinter] Anyone know what happened to my button?
#21
Could you please give an example of the returned data from
data = xbee_message.data.decode()
print(data)
for one sensor and for 3 sensors.
Reply
#22
(May-31-2021, 12:17 PM)Yoriz Wrote: Could you please give an example of the returned data from
data = xbee_message.data.decode()
print(data)
for one sensor and for 3 sensors.

Yes Yoriz
data = xbee_message.data.decode()
print(data)
data = 30.00,09:18:36,30/05/2021
Reply
#23
OK that's data for one, what does data look like when there are 3 sensors.
What I'm looking for is how to tell from the result of data how many sensors there are and how to extract each voltage?
Reply
#24
(May-31-2021, 02:18 PM)Yoriz Wrote: OK that's data for one, what does data look like when there are 3 sensors.
What I'm looking for is how to tell from the result of data how many sensors there are and how to extract each voltage?

Ok I understand you.
All the sensors will send the same data.

The only difference is that each sensor has a different identification number.
addres = xbee_message.remote_device.get_64bit_addr()
print (addres)

0013A20040D7B01E

This address will vary for each sensor
Reply
#25
If the update method was like this
    @submit_to_pool_executor(thread_pool_executor)
    def update(self):
        device.open()
        DATA_TO_SEND = "Hola XBee!"
        device.send_data_broadcast(DATA_TO_SEND)

        try:
            device.flush_queues()
            while True:
                xbee_message = device.read_data()
                if xbee_message is not None:
                    voltage, time, date = xbee_message.data.decode().split(',')
                    address = xbee_message.remote_device.get_64bit_addr()
                    print(f'Address: {address}')
                    print(f'Voltage: {voltage}, Time: {time}, Date: {date}')

                    self.data.set_date('30/05/2021')
                    self.data.set_time('12:00')
                    self.data.set_voltages((0.12, 3.8, 1.3))
                    self.form_frame.update()

        finally:
            if device is not None and device.is_open():
                device.close()
            self.btn_enable()
Would it on each while loop be a new sensor address and if there was 3 it would stop looping after the 3rd?
Reply
#26
(May-31-2021, 02:37 PM)Yoriz Wrote: If the update method was like this
    @submit_to_pool_executor(thread_pool_executor)
    def update(self):
        device.open()
        DATA_TO_SEND = "Hola XBee!"
        device.send_data_broadcast(DATA_TO_SEND)

        try:
            device.flush_queues()
            while True:
                xbee_message = device.read_data()
                if xbee_message is not None:
                    voltage, time, date = xbee_message.data.decode().split(',')
                    address = xbee_message.remote_device.get_64bit_addr()
                    print(f'Address: {address}')
                    print(f'Voltage: {voltage}, Time: {time}, Date: {date}')

                    self.data.set_date('30/05/2021')
                    self.data.set_time('12:00')
                    self.data.set_voltages((0.12, 3.8, 1.3))
                    self.form_frame.update()

        finally:
            if device is not None and device.is_open():
                device.close()
            self.btn_enable()
Would it on each while loop be a new sensor address and if there was 3 it would stop looping after the 3rd?

Yoriz I think I did not understand the question.
Yoriz I made a Drawing.


I am concerned about the order of the panels. Let's say I am going to indicate that the sensors are going to be located in the panels from right to left to have an order and that when reading them in the graphic interface, I know that the voltage of panel 1 is the one that is most at the left and from there on, panel 2 would be the one that follows.

So I wonder, How does one realize that the data belongs to a particular sensor?
We already know that everyone is going to send the same data, the voltage may be different but that's what the system is for determining what the lowest voltage is haha.

The address of each of the Xbee = sensors = panels, is what identifies them to identify themselves. It's like an ID.

As you are helping me, then I do not want to propose something very difficult or something very complex to do, I only express that I would love to respect the order in order to make the system more accurate, since in the interface it will indicate the panel with the Lower voltage and in this way it will be easier to look for it in the row of panels and change it because I will already know where it is according to the order that I specify at the beginning.

Attached Files

Thumbnail(s)
           
Reply
#27
I am at a loss to know where to go from here, I understand that the current update method returns data that can be split by ',' to get the voltage, date and time.
The while True has no way of exiting so I guess it continues to give readings and the button is never re-enabled, does it need a sleep to pause it, how often does it update.
I don't understand how another sensor data is received, does it need a separate thread and another unique way of calling it to get its data.
If there was a way of detecting the separate sensors the GUI could be adjusted automatically.
Reply
#28
(May-31-2021, 09:09 PM)Yoriz Wrote: I am at a loss to know where to go from here, I understand that the current update method returns data that can be split by ',' to get the voltage, date and time.
The while True has no way of exiting so I guess it continues to give readings and the button is never re-enabled, does it need a sleep to pause it, how often does it update.
I don't understand how another sensor data is received, does it need a separate thread and another unique way of calling it to get its data.
If there was a way of detecting the separate sensors the GUI could be adjusted automatically.

You are right, as soon as I press the button, the message is sent from the PC to the sensors, which activates the sensors to send the signal, after which they begin to send the signal without stopping every 5 seconds until it is of night and turn off.

The idea of ​​sending a message when I click the button is to make all the sensors are synchronized when sending the message.

The next day, I open the program and click again, then the sensors start sending data.
It is a simple way, perhaps it is not the most effective.

Now, If there was a way of detecting the separate sensors the GUI could be adjusted automatically.
I think that something that could make the sensors detect automatically is mechanically.
What does that mean?

That I have the opportunity to enter in the GUI, the addresses of the sensors, so that I know which sensors the address refers to.
So in the future, if I am going to enter a new sensor, first I add the address and then I go and install it in the panel.

It comes to mind that at the time of installation, indicate that the button is not yet scratched, this to prevent the sensors from being out of sync. Once I install the fourth sensor, now I do. Stripo button and all are synchronized.

Likewise, if you have any other way of doing it, you can share it with me, it is always good to hear other types of solutions.
Reply
#29
Is this document of any value for your network?
IgnacioMora23 likes this post
Reply
#30
(Jun-01-2021, 01:26 AM)Larz60+ Wrote: Is this document of any value for your network?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [PySimpleGui] How to alter mouse click button of a standard submit button? skyerosebud 3 5,040 Jul-21-2019, 06:02 PM
Last Post: FullOfHelp

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020