After playing with an AUTONOMO for a few weeks i just want to share in one post some snippets of code and info i’ve been gathering around that will help you save some time!. The idea is to update this as much as i can. Got any questions? let me know!
- READING BATTERY VOLTAGE
//These constants are used for reading the battery voltage, you will get one serial post every 5s
#define ADC_AREF 3.3
#define BATVOLTPIN BAT_VOLT
#define BATVOLT_R1 4.7
#define BATVOLT_R2 10
Void Setup()
{
}
Void loop()
{
SerialUSB.println((String)GetBatteryVoltageMV());
Delay(5000);
}
float GetBatteryVoltageMV()
{
uint16_t batteryVoltage = analogRead(BATVOLTPIN);
return (ADC_AREF / 1.023) * (BATVOLT_R1 + BATVOLT_R2) / BATVOLT_R2 * batteryVoltage;
}
-
TIME MANAGEMENT, RTC
Use this library mod by Gabriel Notman with the EPOCH functions! https://github.com/GabrielNotman/RTCZero
AUTONOMO RTCZero wake-up/sleep cycles -
BOARD RESET IF YOU MESSED UP WITH A SLEEP SKETCH
just press the reset button twice to enter into bootloader mode -
TEST SKETCHES & EXAMPLES
https://github.com/GabrielNotman/AutonomoTesting -
GPRSBee (SIM800H) Test Sketch
#include <GPRSbee.h> #include <Sodaq_GSM_Modem.h> #include <Sodaq_OnOffBee.h>
#define APN "yourapn" #define APN_USERNAME "yourapnUSER" #define APN_PASSWORD "yourapnPWD" void setup() { //Wait until the serial monitor is ready/open while(!SerialUSB);
//Start the Bee Serial port initially Serial1.begin(57600); //Switch on the VCC for the Bee socket digitalWrite(BEE_VCC, HIGH);
gprsbee.initAutonomoSIM800(Serial1, BEE_VCC, BEEDTR, BEECTS); gprsbee.setDiag(SerialUSB);
}
void loop() { char buffer[512];
memset(buffer, '\0', sizeof(buffer)); bool retval = gprsbee.doHTTPGET(APN, APN_USERNAME, APN_PASSWORD,
“http://httpbin.org/get”, buffer, sizeof(buffer));
SerialUSB.println(retval); SerialUSB.println("GET result: ");
//Lets be safe in case result length > 247 for (int i=0; i<strlen(buffer); i++) {
SerialUSB.print(buffer[i]);
}
} `