Arduino Nano plus ESP8266-01plus Ubidots IoT Platform

Hi there,

I’m trying to connect an arduino nano to Ubidots Cloud via the WiFi module ESP8266-01. I was following the instructions in this article:
Connect the ESP8266 as a telemetry unit with Ubidots | Ubidots Help Center .
It outlines how we can connect an arduino board as a logger to the Ubidots cloud by using ESP8266 as a telemetry unit. The ardunio nano has one hardware serial, but based on the article, it cloud still be used as a logger. The only difference would be that I could not visualize the response.

Could someone please help me make the necessary modifications to the code so that it works with the arduino nano?

Hi @Burnz

Let me understand your problem first.
When you mean logger, It refers to watch in the Serial Monitor the responses from the ESP8266 as plain text, also, you want to be able to communicate with the ESP8266 through the same serial port?.

If so, your case got my attention, I would like to help you through the process of your concern, I will take it for granted that you have some experience with libraries and electronics if it isn’t let me know and I can keep solving your doubts.

There is a library SoftwareSerial is given by Arduino that acts as a Serial interface with the remaining pins you got, therefore you could have the Physical serial interface connected to the computer, and the SoftwareSerial interface connected to the ESP8266, being able to see and interact with the WiFi module.

Thanks so much for your response.

Basically, having tried the codes from the article, the problem I am currently faced with is getting the arduino nano to communicate effectively with the esp01 wifi module.

I do have some amount of experience with libraries and electronics.

I think I understand your suggestion. I tried to replace Serial1 in the code with an AltSoftSerial and then a SoftwareSerial. I did get some feedback form the serial monitor, but in each case it was junk message. See the screenshot below.

See also the adjustments I made to the code under "Send command via serial-Manual"Logger__a__T1.ino (905 Bytes)

Just realized the file wouldn’t open for you. See the code below with the adjustments in bold.

#include "SoftwareSerial.h"
/****************************************

  • Define Constants
    ****************************************/
    char command[128]; // command
    char answer[100]; // answer from server
    SoftwareSerial esp(8,9);

/****************************************

  • Main Functions
    ****************************************/
    void setup() {
    Serial.begin(115200);
    esp.begin(115200);
    }

void loop() {

int i = 0;
int j = 0;

if (Serial.available()){
while (Serial.available() > 0) {
command[i++] = (char)Serial.read();
}
/* Sends the command to the telemetry unit */
esp.print(command);
i = 0;
}

if (esp.available() > 0) {
/* Reading the telemetry unit /
while (esp.available() > 0) {
answer[j++] = (char)esp.read();
}
/
Response from the server */
Serial.print(answer);
j = 0;
}
}

Well, according to the output given by the serial monitor, seems like your Arduino Nano is being bitten by the watchdog, this normally is caused due to a wrong implementation inside the loop or setup function.

I would recommend you to use variables within the scope of the while loop you are implementing inside the “loop” method, perhaps that’s the problem that is causing the crash of the nano.

I think you could find useful this post from the Arduino Docs Reference Serial.readString() - Arduino Reference

Basically, you can read the whole string from the serial interface without iterating over a char array, and defining a String variable to hold the information from each interface, thus you can print it.

1 Like

Hey, thanks for that suggestion. Since we last spoke though, I was able to work around it. I changed the firmware of the esp8266-01 wifi module to NodeMCU.

The current problem I have is that whenever I send a command( e.g. init#ONLINE?#final ) to the esp8266-01 via that arduino nano logger I’m getting this message “Wrong command. Verify the command and send it again.” Any suggessions?

Hi @Burnz

If you are using the stock firmware I would suggest you test with the AT commands. Link