I’m a beginner at this, so please bear with me.
I have two IR sensors connected to an Arduino Uno, which I am using as a counter. The sketch for the counter is working as expected. The Arduino prints the counter value in the serial monitor.
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
thresh = 835; // CHANGE THE VALUE OF THRESHOLD ACCORDING TO THE 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;
}
}
I now need the ESP8266-01 to read the counter value (maybe from the Serial Monitor, I don’t really know), and send it to a dashboard online. I’m using Ubidots for this.
I used Ubidots’ tutorial (Link: https://ubidots.com/docs/devices/ESP8266-arduino.html) but the ESP is sending -1 only.
#include <UbidotsMicroESP8266.h>
#include <SoftwareSerial.h>
#define _rxpin 2
#define _txpin 3
SoftwareSerial readerSerial( _rxpin, _txpin ); // RX, TX
#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);
}
Can you please tell me how to go about this? I am new to this (clearly) so I don’t know what to do next. Is there some other way to get the ESP to read the Arduino output?