大约88个循环后,Arduino Uno停止执行

时间:2019-07-17 08:31:23

标签: arduino arduino-uno

我有一个气象站,我使用了DHT11,BMP180和GSM Sim808模块,每5分钟发送一次短信。 88发送void loop()函数停止后出现的问题。在两次成功的循环之后,此停止的原因可能是什么? 下面是我的代码:

//Sim808//d
#include <DFRobot_sim808.h>
#include <SoftwareSerial.h>
#define PHONE_NUMBER "0660121981"
#define PHONE_NUMBER2 "0660121983"
#define MESSAGE  "karim"
#define PIN_TX    10
#define PIN_RX    11
SoftwareSerial mySerial(PIN_TX, PIN_RX);
DFRobot_SIM808 sim808(&mySerial);
#include <Wire.h>
#include <Time.h>
//BMP180//
#include <SFE_BMP180.h>
SFE_BMP180 bmp180;
float comp;
int Altitude = 11; //current altitude in meters
//DHT11//
#include "DHT.h"
#define DHTPIN 5     // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
//SDL Weather//
#include "SDL_Weather_80422.h"
#define pinLED     13   // LED connected to digital pin 13
#define pinAnem    3  // Anenometer connected to pin 18 - Int 5 - Mega   / Uno pin 2
#define pinRain    5  // Anenometer connected to pin 2 - Int 0 - Mega   / Uno Pin 3 
#define intAnem    1  // int 0 (check for Uno)
#define intRain    0  // int 1
SDL_Weather_80422 weatherStation(pinAnem, pinRain, intAnem, intRain, A1, SDL_MODE_INTERNAL_AD);
//Declaration//
uint8_t i;
float currentWindSpeed;
float currentWindGust;
float totalRain;
int sending =1;
int counting=0;
void setup()
{

  //Begin//
  Serial.begin(57600);
  mySerial.begin(9600);
  dht.begin();
  bool success = bmp180.begin();
  //PIN//
  pinMode(7, INPUT);           // set pin to input
  digitalWrite(7, HIGH);
  ////
  Serial.println("-----------");
  Serial.println("WeatherArduino SDL_Weather_80422 Class Test");
  Serial.println("Version 1.1");
  Serial.println("-----------");


  weatherStation.setWindMode(SDL_MODE_SAMPLE, 5.0);
  //weatherStation.setWindMode(SDL_MODE_DELAY, 5.0);
  totalRain = 0.0;
  //******** Initialize sim808 module *************
  while (!sim808.init()) {
    delay(1000);
    Serial.print("Sim808 init error\r\n");
  }
  Serial.println("Sim808 init success");

  //******** define phone number and text **********

  sim808.sendSMS(PHONE_NUMBER, "Bienvenue sur Safetrack Station Meteo");
  //sim808.callUp(PHONE_NUMBER);
}
void loop()
{
 if(counting>=2){
  counting=0;
  delay(1000);
  asm volatile ( "jmp 0");
 }
  currentWindSpeed = weatherStation.current_wind_speed() / 1.6;
  currentWindGust = weatherStation.get_wind_gust() / 1.6;
  totalRain = totalRain + weatherStation.get_current_rain_total() / 25.4;
  //DHT11//
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  //BMP180//
  char status;
  double T, P;
  bool success = false;
  status = bmp180.startTemperature();

  if (status != 0) {
    delay(1000);
    status = bmp180.getTemperature(T);

    if (status != 0) {
      status = bmp180.startPressure(3);

      if (status != 0) {
        delay(status);
        status = bmp180.getPressure(P, T);

        if (status != 0) {
          comp = bmp180.sealevel(P, Altitude);

        }
      }
    }
  }
  //Serial//
  String str = "Vitesse vent:" + String(currentWindSpeed*1.60934,2)+"KPH\r\n"+"Direction:"+String(weatherStation.current_wind_direction())+" Degre\r\n"+"Humidite:"+String(h)+" %\r\n"+"Temperature:"+String(t)+" C\r\n"+"Pression:"+String(comp)+"hPa\r\n"+"Pluie:"+String("0.00 mm");
  char copy[150];
  str.toCharArray(copy, 150);
  sim808.sendSMS(PHONE_NUMBER, copy);
  sim808.sendSMS(PHONE_NUMBER2, copy);
counting++;
delay(300000);
}

我有一个气象站,我使用了DHT11,BMP180和GSM Sim808模块,每5分钟发送一次短信。 88发送void loop()函数停止后出现的问题。在两次成功的循环之后,停止该停止的原因是什么?

0 个答案:

没有答案