Hey all, I'm very new to the whole Arduino/teensy/electricity game so I apologize in advance if these are eye-roll worthy questions.
I'm currently working on a Teensy that essentially controls power within a CAN logging system.
The basic layout is as follows;
Teensy reads voltage
if car voltage is high charge the internal battery
if car voltage is low switch to only internal battery
if internal battery is low turn off the logging and switch to a low power mode (as to avoid killing the battery if the system is left on while the car is off)
The problem I'm consistently running into is that once the teensy goes to sleep it either never wakes up, or wakes up instantly on loop. I'm sure this has something to do with the CAN requirements at startup, but my lack of knowledge is getting in the way of actually figuring it out.
The teensy is running at 48 MHZ as a keyboard USB (to turn off the logging system)
I'm leaving out A LOT of code that isn't important to the issue.
There's some variable setup that goes in here but doesn't impact the snooze issues.
A lot of code goes in the loop including the analog reads and logic statements that decide what the teensy should do and the functions that actually control things like outputs to relay switches and keyboard commands to the computer, I'm leaving that stuff out because it's working fine and isn't overly important to the actual problem.
Any advice would be greatly appreciated!
Also, huge thank you to Duff for making such an awesome snooze library, even with my inability to code I can see how awesome the work he's put into it is
I'm currently working on a Teensy that essentially controls power within a CAN logging system.
The basic layout is as follows;
Teensy reads voltage
if car voltage is high charge the internal battery
if car voltage is low switch to only internal battery
if internal battery is low turn off the logging and switch to a low power mode (as to avoid killing the battery if the system is left on while the car is off)
The problem I'm consistently running into is that once the teensy goes to sleep it either never wakes up, or wakes up instantly on loop. I'm sure this has something to do with the CAN requirements at startup, but my lack of knowledge is getting in the way of actually figuring it out.
The teensy is running at 48 MHZ as a keyboard USB (to turn off the logging system)
I'm leaving out A LOT of code that isn't important to the issue.
Code:
#include <Snooze.h>
SnoozeAlarm alarm;
SnoozeUSBSerial usb;
SnoozeBlock config(alarm,usb);
#include <FlexCAN.h>
#include <kinetis_flexcan.h>
static CAN_message_t msg;
Code:
void setup() {
while (!Serial);
delay(100);
Serial.println("Starting...");
delay(100);
alarm.setRtcTimer(0, 0, 10);// hour, min, sec
Can0.begin(500000);
analogReadRes(12);
idx = 0;
}
Code:
void loop() {
int who = 0;
Can0.end();
delay (200);
Serial.print("NAPPING FOR: ");
delay(5);
Serial.print(TimerLength);
delay(5);
Serial.println(" SECONDS");
delay(10);
who = Snooze.deepSleep(config);
Can0.begin(500000);
TimerLength=TimerLength+1;
delay (200);
}
Any advice would be greatly appreciated!
Also, huge thank you to Duff for making such an awesome snooze library, even with my inability to code I can see how awesome the work he's put into it is