[SOLVED] How to send data generated by Arduino using ESP8266?

Basically my project consists of a simple counter that resets after a while due to certain requirements. I have the sensor hooked up and code up and running in the Arduino.

What I need to do next is to send this data to Ubidots using an ESP8266-01. I coded the ESP8266 to send data, but all it sends so far is just -1.

I followed Ubidot’s own tutorial for this, but so far I haven’t succeeded. I used the coding from their tutorial. (Link: https://ubidots.com/docs/devices/ESP8266-arduino.html#get-one-value-from-ubidots) I need a way to get the ESP to read the value stored in the counter variable (preferably from the Serial Monitor) and send that data over to Ubidots. Is it possible, and if so, how? Or do I need some other hardware/software?

Code on the Arduino

const int sensorPin = A1;    // pin that the sensor is attached to
int sensA;                      //    Declaring VARIABLES
int thresh;
int ctr=0;
int state=LOW;
int lastState=LOW;
int count=0;
void setup()
{

Serial.begin(9600);
pinMode(4, INPUT);
pinMode(A1, OUTPUT);
state=digitalRead(4);
}

void loop() 
{
sensA = analogRead(sensorPin);        // Read sensor value
thresh = 835;   // Change the value of threshold according to ambient light
if(sensA<thresh)
{
ctr=1;                                      
delay(1);

if (state==HIGH && lastState==LOW){
count++;
Serial.println(count);
analogWrite(A0, count);
}
lastState=state;
state=digitalRead(4);
delay(10);
}
else{ctr=0;
count=0;

}

}

Code on ESP8266

#include <UbidotsMicroESP8266.h>
#include <SoftwareSerial.h>


#define SSID "SSID"
#define PASS "Password"


#define TOKEN "Token"
#define ID "variableID" // Replace it with your Ubidots' variable ID

Ubidots client(TOKEN);

void setup() {
  Serial.begin(9600);
  client.wifiConnection(SSID,PASS);
}
void loop() {
  float value = Serial.read();
  client.add(ID,value);
  client.sendAll();
  delay(1000);
}

I am using 2 IR sensors, and the coding for those is giving me the results I want. I want to send the output from these two, i.e. my count value, to the dashboard.

(P.S. I’m a noob to this so please forgive any horrendous errors or if I’ve overlooked something, and do tell me if it is so)

Hello @mayflower15,

Regrettably, the guide followed by you is outdated. Please, reference to the new version of the library, then reference to the documentation in order to avoid any issue the progress.

All the best
Maria C.