Here is a way to kick-start your hardware project and start working on it even if the parts have not arrived yet. If you are like us I am sure it happened to you also: getting excited about an idea, ordering some parts then wanting to start on the software side at least until you get the goodies in the mail.
So if your project includes a cloud part for data storage or remote control and we cannot imagine any hardware project lately not to take advantage of this, you need an IoT platform to cover your needs. DeviceHub.net offers both data in and data out in the form of gathering data from sensors and remote control devices by defining actuators on the platform first and then linking them to the hardware by using the API.
The platform offers both a REST (request based) and MQTT(real time communication) options. While real time communication is always better in our opinion sometimes for testing purposes or some specific requirements the HTTP requests can also be used.
In this project you will see how easy is to do this with only your browser. The mainstream ones like Chrome or Firefox have some cool extensions to do this. For example Postman (chrome) is the most polished and reliable but you can also use RestClient if you prefer Firefox. We will present for both this useful extensions how you can test a REST Api.
The first step is to register on the platform and create a Device as an entry point for your data on the cloud. You can do that here https://dashboard.devicehub.net/register and follow the wizard there to create your device.
I created a device with all the data types the platform offers Sensors (analog, digital, string, map) and Actuators (digital, analog). All data types have means of both sending data to the platform and retrieving it. Every Device has a unique id (UUID) and an associated API key of the project it resides to make sending data secure and reliable.
Lets take an Analog Sensor for example. Let's say you want to measure the temperature in your house and have a device to send this value in the cloud and you want to log it over time and if needed to take action and start another device to control it.
In your device you added the sensor and now you are ready to make a request to push a sample data.
Replace 4612 with your Project Id, 8a4aa981-ad13-4749-b829-4f22a745e482 with your Device Id and AnalogSensor with the exact name of your sensor.
Add two headers:
X-ApiKey : f087b5ef-d918-436b-ace8-eaeebeb76ded
Replace this api key with the one from your project.
Content-Type : application/json
In the body zone add this:
Replace the value with whatever value you want to send. If you use other sensor types check the API Documentation for the structure.
Press Send and check the response. You should see something like this (or an error message if something is wrong):
Congrats you emulated a device and send data to an IoT platform. The same code can be used when you have the hardware and you covered already some good ground towards your prototype.
If you were lazy and did not change the requests from this tutorial you can check the result on this link https://dashboard.devicehub.net/project/4612/device/8a4aa981-ad13-4749-b829-4f22a745e482/public/81a9e883-44d6-4386-9e53-8dc7774e40c8 this being the shared project in a sandbox account :)
Be advised: it is not a good practice to post API keys on the internet. We only did this to explain this concept and yes you can send values in the sensors from this demo account because it is not connected to an actual device.
To make it easier for you I made collections of requests for all datatypes with Postman that you can download and import. All you have to do is change the unique information like id's and API keys and you are set to go.
If you have any questions let me know,