IxD IoT

sending your data to Ixd IoT

This page provides you with instructions on how your device sends data to the IxD IoT database.

The data that your device sends through to the IxD IoT database is stored on a UQ server. However, access to that data is openly available for others to use.

Blocks to be added to your code

Here are the key blocks to be added to your photon's code:

	
	String payload = "";
	
	String ownerID = "pete_w"; // your id without any spaces
	String deviceName = "crazy_pizza"; // the name of your photon
	
	long randreading;
	
	
	void setup() 
	{
	    registerDevice(ownerID, deviceName);
	    Particle.publish("alive");
	}
	
	void loop() 
	{
	    // this block is just a sample - you would add the code you need for your 
	    // sensor here
	    randreading = random(40, 220);
	    
	    /*
	    use this line to push your data to the IxD IoT database
	    options:
	    1. The reading or event that you are sending through
	    2. The type of data - either "Reading" for a number value or "Event" for a 
	    description such as "open"
	    3. Description - for example "temperature" or "gate opened" 
	    */
	    publishData(randreading, "Reading", "Sound level");
	}
	
	// this function sends your device's data to the IxD Iot database
	void publishData(int reading, String readingType, String description)
	{
	    payload = "{\"ownerID\": \"";
	    payload += ownerID;
	    payload += "\" , \"deviceName\": \"";
	    payload += deviceName;
	    payload += "\" , \"type\": \"";
	    payload += readingType;
	    payload += "\" , \"description\": \"";
	    payload += description;
	    payload += "\" , \"value\": \"";
	    payload += reading;
	    //payload += "\" , \"extra\": \"";
	    //payload += "nothing to see here";
	    payload += "\"}";
	   
	    Particle.publish("ixdiotadddata", payload, 60, PRIVATE);
	    
	    delay(10000); // wait 10 seconds - don't do any value less than 10000
	
	}
	
	// this function registers your device in the IxD IoT database
	void registerDevice(String ownerID, String deviceName)
	{
	    payload = "{\"ownerID\": \"";
	    payload += ownerID;
	    payload += "\" , \"deviceName\": \"";
	    payload += deviceName;
	    payload += "\"}";
	    
	    Particle.publish("ixdiotregister", payload, 60, PRIVATE);
	    delay(5000);
	}