Just a short summary of my Project: I am a brutal beginner with using Python as I am learning it while learning and applying MQTT Protocol. So please excuse some problems that may be obvious.
I have a Raspberry Pi witch is running a Python script, controlling two actuators. The actuators are supposed to follow a certain profile. The profile is given by an excel sheet on my Laptop.
So now I want to get the data from my Laptop to the Raspberry Pi using Cayenne.
My status right now: I can publish the data to Cayenne but I don’t get how to transfer the data form my “Laptop device” to the “RPI device”.
Can I directly publish and subscribe to a topic “ignoring” the device structure? And how?
I’m open to suggestions and different approaching methods as long as its fulfilling the purpose.
Thank you for any kind of help, ask for more information if its unclear.
well, this is not possible. What kind of data are you trying to transfer from laptop to pi. there will be some other way to do it.
ok. So the data is a speed value (a simple int or string)
is it just that you want to transfer file from laptop to pi. or you want to show it on cayenne?
Most importantly I need the file on the pi. You are supposed to be able to upload a file with the speed data over the time from an external device (Laptop) which the pi can process on its own. Showing it on cayenne is another part but I guess as soon as the data is on the pi, I could just publish it to a channel and review it in Cayenne, right?
the transfer of data from laptop to pi is not possible with cayenne. you are looking at the totally wrong place.
For publishing data from pi to cayenne is possible and use the python library.
ok, got it. Then I’ll try to implement it with the standard paho mqtt library.
Thank you very much for your help and your fast response! Have a nice day!
can paho MQTT transfer a file?
No. Its not about the file. It is about the data. I have a python script which extracts the values as a string from an excel sheet and then sends the strings column by column.
Sorry, its a bit hard to explain
this is my code, maybe that helps
import pandas as pd
#access excel file
excel_file = 'CayenneTestExcel.xlsx'
#put data into a dataframe
mydata = pd.read_excel(excel_file, index_col=0)
#print value in [*rownumber*] as string (virtual wirte only accepts string/int/..)
# Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
MQTT_USERNAME = "..."
MQTT_PASSWORD = "..."
MQTT_CLIENT_ID = "..."
client = cayenne.client.CayenneMQTTClient()
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)
# For a secure connection use port 8883 when calling client.begin:
# client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID, port=8883, loglevel=logging.INFO)
timestamp = 0
if (time.time() > timestamp + 1):
timestamp = time.time()
i = i+1
but why are you sending the data from laptop to pi? is there some purpose for it?
It is for a university project. The requirement is that you are supposed to be able to control the raspberry pi form all over the world. This also means giving the inputs from different devices/locations.