Jump to content









Photo

How to send data from Carriots platform to an Arduino device

IoT Arduino

  • Please log in to reply
3 replies to this topic

#1 dmonrabal

dmonrabal

    Member

  • Members
  • PipPip
  • 12 posts

Posted 03 January 2018 - 05:59 PM

Hello
 
I'm working in an IoT project related with plants and agriculture. In this project I read some variables like temperature and humidity from sensors, then I process these parameters in an Arduino device using an algorithm with fixed timers. Once I've calculated the result, I send the values to Carriots platform. I've have done several tests with different Arduino devices and  technologies: Ethernet, Wifi, GSM and Sigfox. The main aim is analyze the advantatges and disadvantanges of each one. At the moment, I send data to Carriots platform from each device successfully.
 
But now I need get beyond in my project. I need to change the behaviour used in the algorithm. In fact, I have to calculated these values using configurable timers defined by the user. 
 
The question is: ┬┐How can I define a property in my Carriots device, which can be modified by an user in the control panel and returned to the Arduino  device in order to continue with the process?
 
I supose that the solution of each scenario can be different, I mean that the process of send data has been different depending on the technology. For example in a medium like Ethernet or Wifi , I've used a Mqtt library. To send data across GSM medium I've used HTTP requests, and  to send data across Sigfox infrastructure, I've used a specific Sigfox library.
 
I've been thinking about "properties device", but I don't know how read this from arduino device. I would appreciate some example.
 
Thanks.
 


#2 jpastor

jpastor

    Development leader

  • Administrators
  • 176 posts

Posted 08 January 2018 - 10:36 AM

Hi dmonrabal

You can use the device "properties" for that purpose.
The properties are special fields that you can use/define for your own purpose. You can create, modify and get these properties using the control panel or the API.
 
For example, use only one property called "method" with different values (wifi, sigfox, ....) or different properties with true or false (wifi: false, sigfox:false, ethernet: true, ...). Of course it is only a suggestion, you can use the names or values that you need.

Example:
- I have one device with several properties:

 

- I can make a GET request from arduino and recover all device info and of course the properties:

 

Request:

GET https://api.carriots.com/devices/defaultDevice@testCarriots.testCarriots/

 

Response:

 

{
    "_id": "51XXXXXXXXXXXXXXXX5",
    "updated_at": 1515406494,
    "type": "Arduino",
    "owner": null,
    "id_group": "defaultGroup@testCarriots.testCarriots",
    "frequency_stream": 5,
    "sensor": "thermometer",
    "before_status": "ok",
    "status": "disconnected",
    "description": null,
    "id_developer": "defaultDevice@testCarriots.testCarriots",
    "frequency_status": 5,
    "properties": {
        "address": "sintest10",
        "alarmFired": "true",
        "email_message": "alarm fired",
        "email_subject": "alarm",
        "email_to": "demo@carriots.com"
    },
    "name": "defaultDevice",
    "checksum": "XXXXXXXXXXXX",
    "created_at": 1362934748,
    "enabled": true,
    "time_zone": "Europe/Madrid",
    "updater": "testCarriots",
    "lon": -3.625802,
    "lat": 40.438847
}


Hope it helps!



#3 dmonrabal

dmonrabal

    Member

  • Members
  • PipPip
  • 12 posts

Posted 09 January 2018 - 07:06 AM

Thank you very much.

 

I will test it.



#4 dmonrabal

dmonrabal

    Member

  • Members
  • PipPip
  • 12 posts

Posted 11 January 2018 - 03:31 PM

Eii!!

 

I've test it and works perfectly!! I can read the value of this variable declared  by a user in the Control Panel. But now I have another question... 
 
How can I update this same property from arduino. My aim is define a property in my device that can be readed and modified from arduino. The role of this propety is notify to the arduino when must it start one task, and when this has finished, update this property to the original value.
 
I've done some tests throwing http requests with PUT method, but I don't how to define the payload field. Can you show me some example, please?
 
Thank you very much





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users