im having a lot of trouble compiling several codes into one sketch. my main goal is trying to get the device to send an sms when the right data is gethered from the sensors(anemometer,rain gauge, dht11, siren, gsm module) the code seems to have many errors

so far the code i have come up with, although very incomplete is:

#include <EEPROM.h>
#include "dht.h"
#include <SoftwareSerial.h>
#define dht_apin A0 // Analog Pin sensor is connected to
dht DHT;

//SIM800 TX is connected to Arduino D8
#define SIM800_TX_PIN 8

//SIM800 RX is connected to Arduino D7
#define SIM800_RX_PIN 7

// *** Customizable Parameters ***{
int period = 10;                // (300 seconds = 5 minutes)
int fanSampleRate = 10; // How many milliseconds between taking windspeed readings (Needs to be small enough to capture the peak of the analog waveform)
int fanPin = A1;

// *** Globals ***
int highest = 0;     // Keeps track of the highest windspeed over a period
int seconds = 0;     // Keeps track of how many seconds have passed within a period
int promAddr = 0;
// Current index in EEPROM memory

const byte interruptPin = 3;
const int interval = 500;
volatile unsigned long tiptime = millis();

int a = 0;
int b = 0;
int c = 0;
void timer1_init() {
  // Used the Arduino Timer Calculator at to generate this code

  // TIMER 1 for interrupt frequency 1 Hz:
  cli(); // stop interrupts
  TCCR1A = 0; // set entire TCCR1A register to 0
  TCCR1B = 0; // same for TCCR1B
  TCNT1  = 0; // initialize counter value to 0
  // set compare match register for 1 Hz increments
  OCR1A = 62499; // = 16000000 / (256 * 1) - 1 (must be <65536)
  // turn on CTC mode
  TCCR1B |= (1 << WGM12);
  // Set CS12, CS11 and CS10 bits for 256 prescaler
  TCCR1B |= (1 << CS12) | (0 << CS11) | (0 << CS10);
  // enable timer compare interrupt
  TIMSK1 |= (1 << OCIE1A);
  sei(); // allow interrupts

   Interrupt Service Routine (Timer 1)

   This is called by Timer 1 once a second.
ISR(TIMER1_COMPA_vect) {         // timer compare interrupt service routine

  // This section increments the seconds counter each time the interrupt handler is called.
  // Once the number of seconds reaches the period length, we run this block of code and reset.
  if (seconds >= period) {
    seconds = 1;
    Serial.print("Highest: ");
    EEPROM.write(promAddr++, highest); // Write the highest windspeed of the period to EEPROM
    highest = 0;
  void setup() 

    delay(500);//Delay to let system boot
    Serial.println("DHT11 Humidity & temperature Sensor\n\n");
    delay(1000);//Wait before accessing Sensor
    // Set up our digital pin as an interrupt
    pinMode(interruptPin, INPUT_PULLUP);
    attachInterrupt(digitalPinToInterrupt(interruptPin), count, FALLING);
    pinMode(A4, INPUT);
    pinMode(A3, INPUT);
    pinMode(A2, INPUT);
  void loop()

  Serial.print("Current humidity = ");
  Serial.print("%  ");
  Serial.print("temperature = ");
  Serial.println("C  ");

  int newReading = analogRead(fanPin);

  if (newReading > highest)
    highest = newReading;

  delay(fanSampleRate); // Time in between taking readings from anemometer (fan)

  void count()
  // Grab the current ms count for common calculations
  unsigned long curtime = millis();

  // Make sure we don't record bounces
  if ((curtime - tiptime) < interval) {

  // How long since the last tip?
  unsigned long tipcount = curtime - tiptime;
  tiptime = curtime;

  // Calculate mm/hr from period between cup tips
  double rainrate = 914400.0 / tipcount;

  Serial.print("Cup tip: ");

  Serial.print("Rain rate: ");
  int r = digitalRead(A1);
  int s = digitalRead(A0);
  int t = digitalRead(A2);

if (highest>=00 && highest<=00 && rainrate>=00 && rainrate<=00

this is about all i was able to come up with.
any help will be much appreciated

dht_11.ino (723 Bytes)

anemometer.ino (2.82 KB)

gsm.ino (1.38 KB)

rain_gauge.ino (919 Bytes)

water_level_sensor.ino (777 Bytes)

siren.ino (194 Bytes)

the code seems to have many errors

…which you couldn’t be bothered to share?

What is normally the very first thing you see after “void loop ()”?

it ends pretty abruptly as well…if (highest>=00 && highest<=00 && rainrate>=00 && rainrate<=00and what’s the deal with the two 0 ?

still doesnt work "a function-definition is not allowed here before '{' token" .
and is still havent edited it yet just put it as 00 for blank

still doesnt work

sure...make sure all functions have their {} balanced and no code lives outside a function...

press ctrl-T in the IDE to indent the code... might make things more obvious

Please note, for future reference, if it doesn’t compile say “it doesn’t compile”.

If you change something, and it still doesn’t compile, post the new code.

What is normally the very first thing you see after "void loop ()"?

When you launch the IDE, a blank sketch appears with the following two functions with their respective opening brace ({) and closing brace (}).

void setup()


void loop()


Check that your sketch contains these two function in the same style. All other user defined functions are expected to come after after the loop() function having comment line like this //--------------------- among the individual functions for clear readability.