Hello,
I would like my MKR NB 1500 card to acquire data and send it via GSM every hour. I use Arduino Cloud. Between the two measurements, let the card go to sleep.
Not successful with RTCZERO and Arduinolowpower.
Do you have any ideas ?
Thank you in advance
#include "thingProperties.h"
#include "DHT.h"
#include "HX711.h"
#include "OneWire.h"
#include "DallasTemperature.h"
//#include "ArduinoLowPower.h"
//#include <RTCZero.h>
//RTCZero rtc; // initialisation de la librairie de l’horloge
//bool matched = true; // booleen condition alarme
const int sensorPin = 0; //D0
const int ONE_WIRE_BUS = 1; //D1
// HX711 circuit wiring
const int LOADCELL_DOUT_PIN = 4; //D4
const int LOADCELL_SCK_PIN = 5; //D5
HX711 scale;
DHT dht(sensorPin, DHT22);
//Création d’une instance OneWire
OneWire oneWire(ONE_WIRE_BUS);
//Transfert des informations du capteur étanche
DallasTemperature sensors (&oneWire);
void setup() {
pinMode (sensorPin, OUTPUT);
pinMode (ONE_WIRE_BUS, OUTPUT);
// Initialize serial and wait for port to open:
//--Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
//--delay(1500);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(6, OUTPUT); // LED_BUILTIN
digitalWrite(6, LOW);
pinMode(7, INPUT_PULLUP);
pinMode(8, OUTPUT); // SPI - MOSI
digitalWrite(8, LOW);
pinMode(9, OUTPUT); // SPI - SCK
digitalWrite(9, LOW);
pinMode(10, INPUT_PULLUP);
pinMode(13, INPUT_PULLDOWN);
pinMode(14, INPUT_PULLDOWN);
dht.begin();
//rtc.begin(); // initialisation horloge
sensors.begin();
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
scale.set_scale(-19.64585); //renter la valeur de la tare
scale.tare(); // reset the scale to 0
// Defined in thingProperties.h
initProperties();
// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
//--setDebugMessageLevel(2);
//--ArduinoCloud.printDebugInfo();
}
void loop() {
//if (matched){ // condition : si booleen "matched" vrai
//matched = false; // booleen devient faux
ArduinoCloud.update();
dhtSensorReading();
sensors.requestTemperatures();
capteur_temp = sensors.getTempCByIndex(0);
//Serial.println(scale.get_units(10), 0);
masse = scale.get_units(1);
//int alarmMinutes = rtc.getMinutes(); // enregistre l’heure (minutes)
//int alarmHours = rtc.getHours(); // enregistre l’heure (heures)
//alarmMinutes += 0; // reglage de la prochaine alarme (intervalle)
//alarmHours += 1;
//if (alarmMinutes > 59) { // boucle empechant les minutes de depasser 60
//alarmMinutes -= 60;
//alarmHours += 1;}
//if(alarmHours > 23) { // boucle empechant les heures de depasser 24
//alarmHours -= 24;}
//rtc.setAlarmTime(alarmHours, alarmMinutes, 00); // regle la prochaine alarme
//rtc.enableAlarm(rtc.MATCH_HHMMSS); // active l’alarme
//rtc.attachInterrupt(alarmMatch); // alarme = change booleen "matched"
//rtc.standbyMode();} // mise en veille
//delay(55000);
//LowPower.sleep(8000);
}
void dhtSensorReading(){
temperature = dht.readTemperature();
humidity = dht.readHumidity();
}
//void alarmMatch(){ // fonction changeant "matched" en "true"
//matched=true;
//}>