[SOLVED] Cloning Multiple Devices - is this possible ? (using Arduino Mega with Ethernet shield)

Hi there - my project is an Arduino micro controller that senses water temperatures in a Solar Heating System to operate a valve that allows water to flow from solar pods to a swimming pool. It has been operating successfully for several years. Data is sent over the internet to the Xively service fro remote monitoring and analysis.

Recently, I have been looking for a better dashboard service and tried Ubidots. I am enjoying the experience and thinking of converting my devices from Xively. To that end I successfully added a simple function in my code to send data to the Ubidots service. It works just fine from an existing Arduino test device using 5 variables and the Ubidots library for Arduino.

Now I want to replicate the entire device to Ubidots for a second, production deployment version. Is there a quick way to create a second clone of the device in Ubidots … obviously with a unique ID but with exact same sensors?

I originally posted this question on the the interactive chatline and got the following response from David:

"That’s actually a great idea, we don’t have that feature to clone a Device but I’ll add that to the roadmap.
Now, a good way to do that meanwhile could be creating a script in Python (or the language you prefer) to extract information from your actual Device and then creating another Device with that extracted information. You could use our HTTP API for that."

I don’t fully understand this answer but this sounds like I might need to code a stand-alone tool of some kind to extract data and then replicate it. Or I might have to hack the UbidotsEthernet library and I would rather keep things standard and simple. So, I also read quite a lot of the online documentation and the following item seemed quite promising:

FAQs and Troubleshooting > Where can I find the Variable ID? - which says:

"… The benefits of using labels are:

If you have thousands of devices, you can flash the same firmware to all. Just make sure you use a unique ID for the device API label (for example the MAC address or Serial number of the device)."

Other entries in the various FAQs and API documentation also seem to imply that devices/variables will be created automatically if you supply Ubidots with a unique Token. For example, in the REST API Reference, under Send Values it states, “If the specified Device or variables do not exist, they will be automatically created.”

So, with these fragments of information I went ahead and created a new TOKEN for my second device but left all the variables defined the same as the original. The response from Ubidots is:

Posting your variables
HTTP/1.1 200 OK
Server: nginx
Date: Wed, 17 May 2017 15:01:28 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: close
Vary: Accept-Encoding
Vary: Accept, Cookie
Allow: POST, OPTIONS

6e
[{“status_code”: 201}, {“status_code”: 201}, {“status_code”: 201}, {“status_code”: 201}, {“status_code”: 201}]
0

As you can see the 5 variables being sent do not seem to be authorised (201) - I guess since I hadn’t created them manually under the new Token/Device ID. So the variables were not ‘created automatically’.

In summary, I am pretty confident that if I manually created an entirely new device with unique variables then the data would flow. However, I am looking for a simpler solution particularly to support the cloning of existing devices to newly deployed sites where I can then monitor the sensors.

Many thanks for your interest and support. :slight_smile:

Hello @taylopj,

Firstly, we’re so happy to read the good comments about the platform! We work every day to build the better things for your amazing projects!:smiley: :heart_eyes:

In the case of your project, if you desire use an unique code for all the devices, the rigth way to do it is assigning the MAC address of the Ethernet Shield as API Label (As you read in the article).

Regrettably, the last version of the Arduino Ethernet Library works with the variables ID, so the only way that you can send the data to Ubidots is creating the variables to assign the variable ID into the code… so you can’t use the same code for all the devices because each variable ID is different, but don’t worry about it! At the moment we’re working on new versions of the libraries, we’re adding new functions, changing the old method of use variables ID to API label, so the variables will be creating automatically, also assigning the MAC address of the devices as API label of the device to make it unique on the platform. So, if you can wait for a couple of weeks for the new version of the library would be awesome!:smiley: :+1:

Btw, I’m currently work on sample code to POST data to Ubidots over HTTP, it will create the variables automactically using the variables API label, maybe it will help for now… so I’ll let you know any advance, I will share you the code!

I hope this would help you!
Best Regards,
Maria C.

Many thanks for the encouraging reply Maria.

I would be very happy to see any sample POST code that you have and I look forward to the new release of the Arduino Ethernet Library.

A small point on the Arduino Ethernet shield, they don’t all come with a MAC address - by convention the MAC address is often assigned by developers to DE:AD:BE:EF:FE:ED ‘dead beef feed’ so, hardly unique. This is not insurmountable but may be worth considering.

I did examine the library and can indeed see that it uses the Variable ID. However, I do have a suggestion about that. Why not allow Variable IDs not to be unique? If the Variable IDs sit hierarchically under a unique TOKEN (per device) then the Variable IDs could be the same … and therefore devices could easily be cloned by assigning a unique TOKEN.

The concept would be analogous to a house number within a street, e.g. in a town the streets all have unique names, and the house numbers repeat many times across the town, but are unique to the street.

This is just an idea and I confess that I may have misunderstood some concepts. Perhaps the Ubidots architecture, or the underpinning web services, would not tolerate this - however, it seems logical to me and I’d be interested in your views.

Thanks once again for your rapid and thorough reply. Best Wishes, Phil T

Greetings @taylopj, the arduino library is in our plans to be updated as other libraries from our repositories, the variable ID was the first concept at Ubidots to make easy to send data but as we begin to have more and more makers we developed the concept of device-label and variable-label to make easier to send data and to do what you say with a flexible variable ID to be applied to the device and variable label.

Now, if you need to have an unique firmware to be burned on your devices, this is very easy if you follow our API, you should create in your routine an unique random device label (remember that device label is different to device name, the last one is only for visualization purposes and can be customized directly at Ubidots by the user) and to send data to a harcoded variables to that device.

Meanwhile the arduino library is updated by our engineers, if you need to probe asap you can construct your own library too using MQTT to send data for example, in this tutorial you can know how to make that.

Regards