[SOLVED] Migration from Python to Arduino

I am currently running a two-step process where I grab data with an Arduino and then transfer a block of data to a Raspberry Pi running Python using UDP. The Raspberry Pi running Python then uploads the data to Ubidots. My objective is to remove the Raspberry Pi and transfer the data directly from the Arduino to Ubidots.

I started the migration process and found that when using the Arduino library a Device is not specified. I want the transition to be seamless with continuity of the Device and Variables.

What am I missing?

Larry

Greetings, the ethernet shield has a fixed device label, my advise to you is to use the RAW example available at our docs.

All the best

Could you please provide the link to your RAW example.

Larry

Can I create a custom Arduino UbidotsEthernet.cpp (a custom Arduino library) where “new_device_label” is changed to the device label that I use in Python?

Larry

Hey Larry,

You can find multiple tabs for different examples under each documentation category. Just select “Arduino” under the category desired to get the raw example :smiley:

Cheers,
Maria H.

I meant to say UbidotsEthernet.h and that works.

Larry

Greetings, the link is available in my previous message. If you wish to use our library, you also have available the method setDeviceLabel(const char* deviceLabel) to set the device label to be populated by dots at Ubidots, you may reference an example of how to use it below

/********************************
 * Libraries included
 *******************************/
#include <Ethernet.h>
#include <SPI.h>
#include <UbidotsEthernet.h>

/********************************
 * Constants and objects
 *******************************/
/* Assigns the Ubidots parameters */
char const * TOKEN = "Assign_your_Ubidots_TOKEN_here"; // Assign your Ubidots TOKEN
char const * VARIABLE_LABEL_1 = "temperature"; // Assign the unique variable label to send the data
char const * VARIABLE_LABEL_2 = "humidity"; // Assign the unique variable label to send the data
char const * VARIABLE_LABEL_3 = "pressure"; // Assign the unique variable label to send the data

/* Enter a MAC address for your controller below */
/* Newer Ethernet shields have a MAC address printed on a sticker on the shield */
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };

/* initialize the instance */
Ubidots client(TOKEN);

/********************************
 * Main Functions
 *******************************/
void setup() {
  Serial.begin(9600);
  //client.setDebug(true);// uncomment this line to visualize the debug message
  /* start the Ethernet connection */
  Serial.print(F("Starting ethernet..."));
  if (!Ethernet.begin(mac)) {
    Serial.println(F("failed"));
  } else {
    Serial.println(Ethernet.localIP());
  }
  /* Give the Ethernet shield a second to initialize */
  delay(2000);

  // Sets a new device label
  client.setDeviceLabel("my-new-device-label");
  Serial.println(F("Ready"));
}

void loop() {

  Ethernet.maintain();

  /* Sensors readings */
  float value_1 = analogRead(A0);
  float value_2 = analogRead(A1);
  float value_3 = analogRead(A2);
  /* Sending values to Ubidots */
  client.add(VARIABLE_LABEL_1, value_1);
  client.add(VARIABLE_LABEL_2, value_2);
  client.add(VARIABLE_LABEL_3, value_3);
  client.sendAll();
  delay(5000);
}

All the best

Thanks for the suggestion. I thought that would work but haven’t tried it yet.

Larry