Capacitive FOG sensor to Thingspeak

From emboxit
Jump to: navigation, search
 TODO: Add relaxation oscillator schematic




System setup

File:Fogmon system 1.jpg


600px600px


Relaxation oscillator frequency

400px400px400px


Frequency to thingSpeak

400px400px400px400px400px400px


3 water levels

400px400px400px


Details of capacitive probe

400px400px400px

mbed code

<cpp>

  1. include "mbed.h"
  2. include "rtos.h"
  3. include "ThingSpeak.h"
  4. include "EthernetInternet.h"
  5. include "FrequencySensor.h"

InternetInterface* internet;

ThingSpeak thingspeak( "7JG4EJ1Y7KUEAR09" ); // Replace with correct ThingSpeak Write API Key

FrequencySensor freq_sensor( p30, &thingspeak, 1 ); // Pin must be p29 or p30. Third parameter is ThingSpeak field number

void ReadSensorsIntoQueueThread(void const *){

   while(1){
       freq_sensor.ReadIntoQueue();
       Thread::wait(1000);
   }

}

void ThingSpeakUploadThread(void const *){

   Thread::wait(15000);
   while(1){
       thingspeak.UploadQueuedReadings();
       Thread::wait(30000);
   }

}

int main(){

   internet = new EthernetInternet;
   internet->Connect();
   
   Thread t1( ReadSensorsIntoQueueThread );
   Thread t2( ThingSpeakUploadThread );
   
   while(1);

} </cpp>