#include #include "SIM800L.h" #define SIM800_RX_PIN 10 #define SIM800_TX_PIN 11 #define SIM800_RST_PIN 7 SIM800L* sim800l; const char APN[] = "TM"; String BASE_URL = "http://2.238.194.8/index.php?"; //String BASE_URL = "https://postman-echo.com/get?"; String s = ""; char URL[100]; int anemometerPin = 6; int anemometerVal = 0; int anemometerState = 0; unsigned long anemometerDuration = 0; unsigned long startime = 0; unsigned long timer = 0; int windSpeed = 0; int northPin = 4; int eastPin = 5; int southPin = 2; int westPin = 3; int timerLimit = 3000;//300000; // 5 minutes bool printSensorsData = true; String windDirection = ""; void setup() { // Initialize Serial Monitor for debugging Serial.begin(115200); while(!Serial); // Initialize a SoftwareSerial SoftwareSerial* serial = new SoftwareSerial(SIM800_RX_PIN, SIM800_TX_PIN); serial->begin(9600); delay(1000); // Initialize SIM800L driver with an internal buffer of 200 bytes and a reception buffer of 512 bytes, debug disabled sim800l = new SIM800L((Stream *)serial, SIM800_RST_PIN, 200, 512); // Setup module for GPRS communication setupModule(); } void loop() { windDirection = ""; anemometerVal = digitalRead(anemometerPin); if ((anemometerState == 1) && (anemometerVal == 0)) { anemometerDuration = millis() - startime; startime = millis(); windSpeed = 2500.0/anemometerDuration; } anemometerState = anemometerVal; if(millis() >= timer) { Serial.println("--------------------------"); Serial.println("Sending..."); timer = millis() + timerLimit; if(digitalRead(northPin)) {windDirection = windDirection + "N";} if(digitalRead(southPin)) {windDirection = windDirection + "S";} if(digitalRead(eastPin)) {windDirection = windDirection + "E";} if(digitalRead(westPin)) {windDirection = windDirection + "W";} if(printSensorsData) { Serial.print("Wind speed:\t"); Serial.print(windSpeed); Serial.println("Km/h"); Serial.print("Wind direction:\t"); Serial.println(windDirection); } sendRequest(); } }