Temperature from file to dashboard

I m need send temperature from file to dashboard
in file.txt i have “Temperature=22.1”
How to send this temperature to dashboard from bash and refresh any 10 sec

you can send it using python GitHub - myDevicesIoT/Cayenne-MQTT-Python: Python Library for Cayenne MQTT API

yes but where can i put my data :

import cayenne.client
import time

Cayenne authentication info. This should be obtained from the Cayenne Dashboard.


The callback for when a message is received from Cayenne.

def on_message(message):
print("message received: " + str(message))

If there is an error processing the message return an error string, otherwise return nothing.

client = cayenne.client.CayenneMQTTClient()
client.on_message = on_message

For a secure connection use port 8883 when calling client.begin:


timestamp = 0

while True:

if (time.time() > timestamp + 10):
client.celsiusWrite(1, i)
client.luxWrite(2, i*10)
client.hectoPascalWrite(3, i+800)
timestamp = time.time()
i = i+1

in this code ??

what is your data?

in file.txt i have “Temperature=22.1”
and i need push data (22.1) from file to dashboard temperature sensor
is raspbian

is there a code which reads the temperature or just a random temperature number.

just a random temperature number

Try this code and see if you get the temperature string and then you have to parse the value and add it to cayenne python code.

stringToMatch = 'Add your string'
matchedLine = ' '

f = open("file.txt","r")
for line in f:
        if stringToMatch in line:
                matchedLine = line
                print matchedLine

$ python 1.py

in 1.py

stringToMatch = ‘Temperature=’
matchedLine = ’ ’

f = open(“file.txt”,“r”)
for line in f:
if stringToMatch in line:
matchedLine = line
print matchedLine

now you need to add this code in cayenne code and parse the 22.1 value to be send using client.virtualWrite(1, 22.7)

now i have :
config = ConfigParser.ConfigParser()
tempp = config.get(“zmienne”, “var_a”)

while True:

if (time.time() > timestamp + 10):
client.celsiusWrite(1, tempp)
timestamp = time.time()
i = i+1

how to refresh tempp if something is change in file ??? thx

i am not understanding what you are trying to do. you first said you have a random temperature number in file.txt which needs to send to cayenne. Now you are saying you need to know if the something has changed. So is it sensor that will change the temperature value in file.txt?
Anyways, to see if there is a change you need to call the function which reads the file every interval.