This is a project I had in university in the third year at the Java and Python Programming course. This course was taught by Conf. Dr. Ing. Victor Constantin.
After parsing and creating the CSV with the data from the sensors in Java, I had to plot that data in different windows for each type of data (one graph for temperature, one for humidity, one for presence and one for velocity). The plotting had to be on a different thread. Here I had a problem with plotting and I had to show images instead. I used OpenCV for it and so I checked if there exists an image already and deleted it if so, after that I created a domain for the image, show it for one second and close the domain. I did this because plt.show() could not work properly through the thread.
For bonus points there were two more tasks, one to connect to the microcontroller and send the data on a separate thread and another one to connect with TCP/IP port at the Python application in a separate thread. To do that so I created a class "conexiuneArduino(Thread)" which had the functions "get_data()", "connect()" and "run()", the connect function returned 1 if it could connect to Arduino, else if it couldn't open the serial port it would return 0, the function get_data would sleep for 0.2 seconds if the port was waiting and would read on the port until timeout otherwise, the run function would run the function get_data on a separate thread. For the TCP/IP connectivity I created two classes "server(Thread)" and "client(Thread)". The server class would be on the IPv4 IP address localhost 127.0.0.1, listening on the TCP port 5005 and a buffer size of 20 (we want it to be fast, in normal case it should be 1024), the client class tries to connect to the server, encode the data (in this case it's a string "Respect") and send it to the server. I also have a class "thread_checker(Thread)" which is looking for alive threads.
-
Notifications
You must be signed in to change notification settings - Fork 0
brittleru/Multithread-Sensor-Data
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
About
Arduino and TCP/IP (local host) connection and plotting sensor data CSV.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published





