<?xml version="1.0" encoding="UTF-8"?> | |||||
<project version="4"> | |||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" /> | |||||
</project> |
<module type="PYTHON_MODULE" version="4"> | <module type="PYTHON_MODULE" version="4"> | ||||
<component name="NewModuleRootManager"> | <component name="NewModuleRootManager"> | ||||
<content url="file://$MODULE_DIR$" /> | <content url="file://$MODULE_DIR$" /> | ||||
<orderEntry type="inheritedJdk" /> | |||||
<orderEntry type="sourceFolder" forTests="false" /> | <orderEntry type="sourceFolder" forTests="false" /> | ||||
</component> | </component> | ||||
</module> | </module> |
# projektarbeit_duelger_waldhauser_caliskan | # projektarbeit_duelger_waldhauser_caliskan | ||||
repository to manage all files related to the makeathon farm bot project (Software + Documentation). | |||||
repository to manage all files related to the makeathon farm bot project (Software + Documentation). | |||||
To use the same module versions in backend and raspi communication, a conda environment was created | |||||
Basic conda usages: https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html |
import paho.mqtt.client as mqtt | |||||
def on_connect(_client, userdata, flags, rc): | |||||
print("Connected with result code " + str(rc)) | |||||
client.subscribe("test/topic") | |||||
def on_message(_client, userdata, msg): | |||||
print(msg.topic + " " + str(msg.payload)) | |||||
client = mqtt.Client() | |||||
client.on_connect = on_connect | |||||
client.on_message = on_message | |||||
client.connect("localhost", 1883, 60) | |||||
client.loop_forever() | |||||
"""In this example, we create a new instance of the mqtt.Client class and set up the on_connect and on_message | |||||
callback functions. The on_connect function is called when the client successfully connects to the broker, | |||||
and the on_message function is called when a message is received on a subscribed topic. | |||||
Then, we call the connect method to connect to the MQTT broker running on the local machine on port 1883, and set the | |||||
keepalive value to 60 seconds. | |||||
Finally, we call the loop_forever method to start the client and begin processing incoming messages. This method | |||||
blocks the program execution and runs the client loop in a loop until the client is disconnected. (ChatGPT)""" |
hallo |