Skip to content

Instantly share code, notes, and snippets.

@etix
Created August 24, 2020 09:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save etix/b9cb44590614e08897dc618cf63a00a6 to your computer and use it in GitHub Desktop.
Save etix/b9cb44590614e08897dc618cf63a00a6 to your computer and use it in GitHub Desktop.
Mini Ultra Pro V3 with RFM95: 18μA in standby (stock, without external component)
#include <SerialFlash.h>
#include <RTCZero.h>
#include <SPI.h>
#include <RH_RF95.h>
//#include <RH_RF69.h>
// ***** CONSTANTS *****
const int radioDio0 = 2;
const int flashChipSelect = 4;
const int radioChipSelect = 5;
// Choose correct on-board radio
RH_RF95 radio(radioChipSelect, radioDio0);
//RH_RF69 radio(radioChipSelect, radioDio0);
RTCZero rtc;
/* Change these values to set the current initial time */
const uint8_t seconds = 0;
const uint8_t minutes = 00;
const uint8_t hours = 10;
/* Change these values to set the current initial date */
const uint8_t day = 20;
const uint8_t month = 2;
const uint8_t year = 17;
// ***** VARIABLES *****
unsigned char pinNumber;
void setup()
{
// ***** Put unused pins into known state *****
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
// D7-D13, A0(D14)-A5(D19), SDA(D20), SCL(D21), MISO(D22)
for (pinNumber = 7; pinNumber <= 22; pinNumber++)
pinMode(pinNumber, INPUT_PULLUP);
// RX_LED (D25) & TX_LED (D26) (both LED not mounted on Mini Ultra Pro)
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
// D30 (RX) & D31 (TX) of Serial
pinMode(30, INPUT_PULLUP);
pinMode(31, INPUT_PULLUP);
// D34-D38 (EBDG Interface)
for (pinNumber = 34; pinNumber <= 38; pinNumber++)
pinMode(pinNumber, INPUT_PULLUP);
// ***** End of unused pins state initialization *****
if (!radio.init()){}
radio.sleep();
SerialFlash.begin(flashChipSelect);
SerialFlash.sleep();
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, HIGH);
delay(15000);
// RTC initialization
rtc.begin();
rtc.setTime(hours, minutes, seconds);
rtc.setDate(day, month, year);
// RTC alarm setting on every 15 s resulting in 1 minute sleep period
rtc.setAlarmSeconds(15);
rtc.enableAlarm(rtc.MATCH_SS);
rtc.attachInterrupt(alarmMatch);
digitalWrite(LED_BUILTIN, LOW);
USBDevice.detach();
rtc.standbyMode();
}
void loop()
{
// Initialize USB and attach to host (not required if not in use)
USBDevice.init();
USBDevice.attach();
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
// Detach USB from host (not required if not in use)
USBDevice.detach();
// Sleep until next alarm match
rtc.standbyMode();
}
void alarmMatch()
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment