Skip to main content

Connexion mqtt et enregistrement des données dans un fichier csv

Project description

#mqttdatalogger

Enregistrement des données issues d'un serveur MQTT dans un fichier csv.

Exemple d'utilisation :

import getpass
import mqttthreaddatalogger as MQTT

Username = input('Entrez votre identifiant MQTT : ')
pwd = getpass.getpass('Entrez votre mot de passe MQTT :')

auth = {
'username':Username,
'password':pwd
}

crée le thread transport tcp ou websockets

m = MQTT.mqttthreaddatalogger("url_mqtt",portmqtt,auth["username"],auth["password"],"tcp")

topics auquel on s'abonne

m.selectTopic(["node_iot2020/arduino/out/"])

selection des clés des données voulues , les données seront dans m.data[0], m.data[1],...

m.selectKey(["['ecl']","['temps']"])

ou pour Lorawan, après le # se trouve le nom du champ qui sera utilisé dans le fichier csv,...

m.selectKey(["['uplink_message']['decoded_payload']['temperature']#temp","['uplink_message']['rx_metadata'][0]['gateway_ids']['gateway_id']#Id_gateway","['end_device_ids']['device_id']#ID_device"])
Après le # on rajoute le nom de la 1ère ligne du fichier de données
>

m.selectNomFichier("testdonnees.csv")

pour afficher ou non les info sur la console

m.affichage_console(True)

démarre le thread, (exécution indépendante du programme principal)

m.start()

time.sleep(1)
#publication d'un message vers MQTT
#m.client.publish("votretopic/test/in/",payload="{"pression":1024}",qos=0)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mqttthreaddatalogger-1.6.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

mqttthreaddatalogger-1.6.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file mqttthreaddatalogger-1.6.0.tar.gz.

File metadata

  • Download URL: mqttthreaddatalogger-1.6.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for mqttthreaddatalogger-1.6.0.tar.gz
Algorithm Hash digest
SHA256 ade038fbb1155a0a19e6c9cf45d9a6a145909318e73614d433655afe1486f345
MD5 dc85a7b18d134f41b5346f9d291e5c83
BLAKE2b-256 fb224a155adfafeed491012ae39f5f7cc8aa59327e613e694d0105c3fab1fb83

See more details on using hashes here.

File details

Details for the file mqttthreaddatalogger-1.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mqttthreaddatalogger-1.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f326e6567d3dc37f2888752923c9348cabd61808b14c3847f568f469d7458e3
MD5 1d5b9349968c11087ac8d29218ad222d
BLAKE2b-256 b637cfaf380e21b205304794908e762f67c9e3b63f2c0f70030da7fd873ecee3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page