Magnetometer (Aurora detector) to Thingspeak

Hi all this is my first post. My knowledge of coding is limited. Here is what I wish to do.

I am using an Uno R3 which is connected to a FGM 3 fluxgate Magnetometer. The magnetometer puts out a PWM 5 Volt square wave which the frequency directly corresponds to the Earths magnetic field.

I am using Freqcount to measure the signal which is working perfectly (data on pin D5) via the serial.

I have an ESP 01 and would like to send the data to Thingspeak

Can anyone help with what code to add to Freqcount to achieve this?

Your help is appreciated
Carl

Wow nothing not even a steer in the right direction.

What a useful forum...

What I need to do is get the serial output (count) from FreqCount to the second program to send to Thingspeak using the ESP8266 01. Freqcount uses the D5 pin to read and outputs a 5 digit frequency in serial.

The second sketch is a voltage example which works the ESP8266 ok.

I just cannot get past the valSensor or getSensorData bit and update once a minute.

/* FreqCount - Example with serial output

void setup() {
Serial.begin(57600);
FreqCount.begin(1000);
}

void loop() {
if (FreqCount.available()) {
unsigned long count = FreqCount.read();
Serial.println(count);
}
}

To this example,

#include <SoftwareSerial.h>
#define RX 10
#define TX 11
String AP = "WIFI_NAME"; // CHANGE ME
String PASS = "WIFI_PASSWORD"; // CHANGE ME
String API = "YOUR_API_KEY"; // CHANGE ME
String HOST = "api.thingspeak.com";
String PORT = "80";
String field = "field1";
int countTrueCommand;
int countTimeCommand;
boolean found = false;
int valSensor = 1;
SoftwareSerial esp8266(RX,TX);

void setup() {
Serial.begin(9600);
esp8266.begin(115200);
sendCommand("AT",5,"OK");
sendCommand("AT+CWMODE=1",5,"OK");
sendCommand("AT+CWJAP=""+ AP +"",""+ PASS +""",20,"OK");
}
void loop() {
valSensor = getSensorData();
String getData = "GET /update?api_key="+ API +"&"+ field +"="+String(valSensor);
sendCommand("AT+CIPMUX=1",5,"OK");
sendCommand("AT+CIPSTART=0,"TCP",""+ HOST +"","+ PORT,15,"OK");
sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");
esp8266.println(getData);delay(1500);countTrueCommand++;
sendCommand("AT+CIPCLOSE=0",5,"OK");
}
int getSensorData(){
return random(1000); // Replace with
}
void sendCommand(String command, int maxTime, char readReplay[]) {
Serial.print(countTrueCommand);
Serial.print(". at command => ");
Serial.print(command);
Serial.print(" ");
while(countTimeCommand < (maxTime*1))
{
esp8266.println(command);//at+cipsend
if(esp8266.find(readReplay))//ok
{
found = true;
break;
}

countTimeCommand++;
}

if(found == true)
{
Serial.println("OYI");
countTrueCommand++;
countTimeCommand = 0;
}

if(found == false)
{
Serial.println("Fail");
countTrueCommand = 0;
countTimeCommand = 0;
}

found = false;
}

Regards Carl