2 Replies Latest reply on May 2, 2017 4:01 AM by mneumann RSS
    kstar Newbie

    How to transfer data from many different raspberries to thingworx

    How to transfer data from many different raspberries to thingworx,We want to measure the temperature and humidity through the raspberry pi, and then upload it to the thingworx, we do not know how to build the thingworx platform and how to send raspberry pi data.We known how to get a raspberry pi to upload data to thingworx,so i need help.

      • Re: How to transfer data from many different raspberries to thingworx
        Ankit Gupta Ninja

        Hi king star,

         

        Homepage - Developer Zone : ThingWorx is the best place to start with.

        After registering please navigate to http://developer.thingworx.com./guides/thingworx-raspberry-pi-quickstart?page=1 for Step by Step guide on Connecting ThingWorx EMS with Raspberry Pi Quickstart.

         

        Do let us know if you face any issue.

        • Re: How to transfer data from many different raspberries to thingworx
          mneumann Creator

          For simple transfer I'm using a pyton script that sends updates via a REST API in a loop

           

          #!/usr/bin/python
          
          import sys
          import json
          import time
          import logging
          import requests
          import Adafruit_DHT
          
          sensor = Adafruit_DHT.DHT11
          pin    = 4
          
          appKey = "<yourAppKey>"
          url    = "http://<server>/Thingworx/Things/<Thingname>/Properties/*"
          
          try:
              import http.client as http_client
          except ImportError:
              import httplib as http_client
          http_client.HTTPConnection.debug = 1
          
          # The following lines are for troubleshooting
          # logging.basicConfig()
          # logging.getLogger().setLevel(logging.DEBUG)
          # requests_log=logging.getLogger("requests.packages.urllib3")
          # requests_log.setLevel(logging.DEBUG)
          # requests_log.propagate=True
          
          while 1 > 0:
          
              humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
              
              if humidity is not None and temperature is not None:
              
                  headers = {'Content-Type': 'application/json', 'appKey': appKey}
                  payload = {'Temperature': temperature, 'Humidity': humidity}
                  
                  response = requests.put(url, headers=headers, json=payload, verify=False)
                  
              time.sleep(60)