ESP8266 Anemometer

So I have tried to connect this program to Thing Speak for the last several days. I had someone else try it and I was told it worked correctly but yet no matter how many times I try it just does not do what it is set up to do . I purposely left out the credentials , It does compile but does not display correctly on serial monitor. I have tried several baud rates but still the same problem. What happens is that it shows connecting to my Netgear but then all I get is a bunch of ............. I am trying to send data to Thing Speak and display the wind speed on a graph .I have the information saved on the site to display but if I can't see it on my monitor, i can'texpect it will populate Thing Speak . The program is basically Davis Wind Speed . Any help would be appreciated, Also a second program which is the original I was adapting to,which by the way works on the serial monitor.

#include <ESP8266WiFi.h>
#include "secrets.h"
#include <math.h>

#define WindSensorPin 4 // The pin location of the anemometer sensor
volatile unsigned long Rotations; // cup rotation counter used in interrupt routine
volatile unsigned long ContactBounceTime; // Timer to avoid contact bounce in interrupt routine
float WindSpeed; // speed miles per hour

#include "ThingSpeak.h" // always include thingspeak header file after other header files and custom macros

char ssid[] = "YOUR SSID"; // your network SSID (name)
char pass[] = "YOUR PASS"; // your network password
int keyIndex = 0; // your network key Index number (needed only for WEP)

WiFiClient client;
unsigned myChannelNumber = 1172766;
const char * myWriteAPIKey = "API_KEY";

bool incrementRotation = false;

// This is the function that the interrupt calls to increment the rotation count
ICACHE_RAM_ATTR void isr_rotation () {
incrementRotation = true;
Serial.print("ISR");
}

void setup() {
Serial.begin(115200); // Initialize serial
pinMode(WindSensorPin, INPUT);
attachInterrupt(digitalPinToInterrupt(WindSensorPin), isr_rotation, FALLING);

WiFi.mode(WIFI_STA);
ThingSpeak.begin(client); // Initialize ThingSpeak
}
//pinMode(WindSensorPin,INPUT);
//attachInterrupt(digitalPinToInterrupt(WindSensorPin), isr_rotation, FALLING);
// Serial.println("Rotations\tMPH"); //use for debug

void loop() {
// Connect or reconnect to WiFi
if (WiFi.status() != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(SECRET_SSID);
while (WiFi.status() != WL_CONNECTED) {
WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network. Change this line if using open or WEP network
Serial.print(".");
delay(5000);
}
Serial.println("\nConnected.");
}
Rotations = 0; // Set Rotations count to 0 ready for calculations
//sei(); // Enables interrupts

//delay (3000); // Wait 3 seconds to average
//cli(); // Disable interrupts
// convert to mp/h using the formula V=P(2.25/T)
// V = P(2.25/3) = P * 0.75
if (incrementRotation) {
if ((millis() - ContactBounceTime) > 15 ) { // debounce the switch contact.
Rotations++;
ContactBounceTime = millis();
// Write to ThingSpeak. There are up to 8 fields in a channel, allowing you to store up to 8 different
// pieces of information in a channel. Here, we write to field 1.
WindSpeed = Rotations * 0.75;
int x = ThingSpeak.writeField(myChannelNumber, 1, WindSpeed, myWriteAPIKey);
if (x == 200) {
Serial.println("Channel update successful.");
}
else {
Serial.println("Problem updating channel. HTTP error code " + String(x));
}
incrementRotation = false;
}
}

}
}Type or paste code here
Working but not connected to Thing Speak


#define WindSensorPin (2) // The pin location of the anemometer sensor

volatile unsigned long Rotations; // cup rotation counter used in interrupt routine
volatile unsigned long ContactBounceTime; // Timer to avoid contact bounce in interrupt routine

float WindSpeed; // speed miles per hour

void setup() {
Serial.begin(9600);

pinMode(WindSensorPin, INPUT);
attachInterrupt(digitalPinToInterrupt(WindSensorPin), isr_rotation, FALLING);

Serial.println("Davis Wind Speed Test");
Serial.println("Rotations\tMPH");
}

void loop() {

Rotations = 0; // Set Rotations count to 0 ready for calculations

sei(); // Enables interrupts
delay (3000); // Wait 3 seconds to average
cli(); // Disable interrupts

// convert to mp/h using the formula V=P(2.25/T)
// V = P(2.25/3) = P * 0.75

WindSpeed = Rotations * 0.75;

Serial.print(Rotations); Serial.print("\t\t");
Serial.println(WindSpeed);

}

// This is the function that the interrupt calls to increment the rotation count
void isr_rotation () {

if ((millis() - ContactBounceTime) > 15 ) { // debounce the switch contact.
Rotations++;
ContactBounceTime = millis();
}

}
Preformatted text`

I have no idea which controller and modules you are using, but my Crystal Ball indicates a duplicate use of Serial by some (WiFi?) module.

 Sorry, I should know better, Using Arduino IDE 1.8.13, ESP 8266 E12 Lolin pc Window 10 pro 64 bit . 
 So I have tried using the examples/Thing Speak/ direct programming/ single program. It compiles and works in serial monitor. I know it’s not a credentials issue, and I can see my network so that’s working right. 
  The first program listed was configured by Sara Rui of random nerds and she ran it before correcting the code. When she sent it back to me I tried it, it compiled, no issues for the most part but when I opened up serial monitor it shows connecting and ........ across the monitor but never shows connected. Also I go to the Thing Speak site it never gets there either. No surprise there because serial monitor shows it never got that far. Thanks for looking

What happened to your response, it's almost unreadable :frowning:

What is Serial on the ESP?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.