Nothing here.
You removed the 3.3V regulator from the pro mini and then you want to power it at 4.5V from 3xAAA batteries? Doesn't sound good for that board.
As for the RTC, it interrupts the arduino every second which wakes it up. That is the slowest frequency for the RTC to do that. It can wake it up much more often, but not less.
I would strongly suggest you temporarily set aside all your power hacks and battery concerns and start with something simple like getting the RTC to work correctly and "simulate" turning the valves on/off at the right time.
AFTER you code is working, then focus on how to can reduce power and move to batteries.
Way to much stuff to make sense of, start at the very beginning, a bare bones processor and start adding stuff bit by bit.
Components interact in ways you will not expect, you cannot assume that just switching stuff off will result in the lowest sleep current. There are particular issues with bus based devices such as thaose using SPI or I21C.
Meanwhile I have some NPN logic level MOSFET
NPN and PNP are for bipolar transistors, MOSFETs are P channel and N channel.
Can I use the RTC module with the VCC disconnected, powering the module only by I2C and GND or can it be unstable?
You cannot use (access\program) the RTC with no power connected to VCC. If you want it to keep time when its off, you need a voltage on the VBAT pin, see the DS3231 datasheet.
FYI I’ve been using those Hunter Valves for about 6 months and I can tell you they use more than 20mA to kick open. Opening and closing that often the 9V won’t last longer than 3-4 months probably.
Check out this post. It should help you if all you want to do is open/close the valve. Then you can add your OLED and then optimize.
http://vanderleevineyard.com/vineyard-blog/arduino-control-for-vineyard-irrigation
I thought the ATmega328 without the regulator could run between 3.3v and 5v. If all the other components I'm using also work in this range I thought that would be no problem.
I first assembled the instructable project using only the RTC and OLED and checked that it was working as it should. From there I inserted the hbridge and tested to control the valves at alarm time, and then I started to look for how to reduce the power consumption of the pro mini and my RTC module. And only then did I look into how to turn off the components with a MOSFET. I do not understand why you're saying that my RTC is not working correctly?
Thanks for the correction about the MOSFETs!
I thought I had read here in the forum some of the moderators saying that it would be possible to use the RTC3231 only with the I2C and GND lines connected, I tested this and in my ignorance it works. I can change the alarm and wake the arduino. - YouTube
I also do not think that consume just that, this was what I could measure with my multimeter. Hunter has a controller that only runs on a 9v battery and is said to last for a year.
The link that you posted is exactly the link that I found months ago when I was researching on the subject and exactly like I did in my code:
void SwitchVal()
{
digitalWrite(HB_POWER, HIGH); // Power up hbridge
delay(100);
if(Val1_STAT == 1)
{
digitalWrite(IN2, HIGH); // Turn the valve off (HIGH is the voltage level)
delay(10); // Wait 10 milliseconds
digitalWrite(IN2, LOW); // End drive pulse by making the voltage LOW
Val1_STAT = 0;
EEPROM.update(Val1_EE, Val1_STAT);
}else
{
digitalWrite(IN1, HIGH); // Turn the valve off (HIGH is the voltage level)
delay(10); // Wait 10 milliseconds
digitalWrite(IN1, LOW); // End drive pulse by making the voltage LOW
Val1_STAT = 1;
EEPROM.update(Val1_EE, Val1_STAT);
}
delay(100);
digitalWrite(HB_POWER, LOW); // Power off hbridge
delay(100);
}
bernabap:
@srnet
I thought I had read here in the forum some of the moderators saying that it would be possible to use the RTC3231 only with the I2C and GND lines connected
Can you provide a link to those comments ?
Where in the DS3231 datasheet does it say it can be used with no VCC connection ?
srnet:
Can you provide a link to those comments ?Where in the DS3231 datasheet does it say it can be used with no VCC connection ?
I found it, but I may have misinterpreted it: DS3231 High Power Consumption - #2 by CrossRoads - General Electronics - Arduino Forum
I thought that as my RTC module has a battery (CR2032) the DS3231 chip is never turned off, and that way it works even without applying any voltage to the VCC pin of the module.
Hunter has a controller that only runs on a 9v battery and is said to last for a year.
Hmmm... I guess that may be possible with a dedicated battery to the solenoid. I would suggest adding a voltage divider (or some other circuit) to read the voltage on that battery and keep an eye on it.
Having said that, I can almost guarantee that they are using a larger capacitor to kick open those solenoids. I would suggest you buy one of their controllers and reverse engineer it. I ended up adding a two large capacitors (4700uF) in parallel to reliably kick open that solenoid. I could do it with 1, but I added another for peace of mind. I'm also using 1 battery to power both (uC and valve) not a separate battery for the valve.
bernabap:
I thought that as my RTC module has a battery (CR2032) the RTC3231 chip is never turned off, and that way it works even without applying any voltage to the VCC.
The DS3231 detects the loss of VCC and goes into low current shutdown mode, with VBAT keeping the clock running. This is mentioned on the first page of the datasheet.
If the DS3231 is in permanent shutdown mode, because you ommit a connection to VCC, how to ever expect to be able to program it ?
When active (so you can program it) the DS3231 only takes circa 250uA, so VCC could be supplied with a logic pin.
I certainly plan to monitor the 2 batteries, I've made a voltage divider for the 9V and I'm using the internal reference voltage to measure the VCC. Do you know if there is any problem in measuring 2 batteries at the same time in this way, having the GND of both connected?
If the capacitors that already come in my hbridge module are not enough I will try to increase. I thought about buying a NODE100 but I would end up using it instead of trying to reverse engineer it, that is beyond my abilities, maybe I would be able to at least identify the capacitors they use. I've searched several times for some photos of this NODEs disassembled but I've never found anything.
I removed the VCC pin from the RTC module and even then It seems that I can wake the DS3231 from shutdown mode when I wake up my arduino. This only works with the RTC module that I removed the pull ups resistors, EEPROM chip, battery charge resistor and the power led. I have another identical module that I removed only the resistor from the battery charging circuit and the power led and this module does not work without the VCC connected. I took a test to measure the RTC's battery consumption while I use: - YouTube
I am setting Bit 6 (Battery-Backed Square-Wave Enable) of control register 0Eh to 1 to force the wake-up alarms to occur when running the RTC from the back up battery alone.
I would take a look at this video. I don’t know if you can distinguish weekend. The rtc has an alarm trigger that can be set for once a minute, hour, day, etc. you might be able to use 2 rtc’s to trigger Saturday and then Sunday.
Anthony
Btw - on my rtc, I removed the charge trace. I ran an unmodifed pro mini on 3aa batteries with it turning on every minute for 10seconds and lighting the led on the pro mini. The batteries lasted about 5-6 weeks. I also removed the led on the rtc. This was just a rest circuit for a project that will turn on once per day and send a text. That project will have a lipo battery and will probably be on only a couple of seconds. The kicker will be the energy to send the text.
Anthony
aiannar974:
I don’t know if you can distinguish weekend.
Hi Anthony,
To differentiate the weekends has to be done by code. I'm trying to do this by creating a array to store a flag for each day of the week, which indicates whether to repeat the alarm on that day or not. Every time the alarm triggers from the start time I only update the alarm hour to the end time of the program. When the end time triggers I change the alarm hour back to the start time of the program and check the flag for the next day if should repeat or not, until I find a day of the week that is enabled.
// P1_DAYS[1] is Monday, P1_DAYS[2] = Tuesday, P1_DAYS[3] = Wednesday, etc...
uint8_t P1_DAYS[8] = {0,1,1,1,1,1,1,1}; // Flags to indicate witch day of week the program should repeat, first one not used.
const int P1_MoEE = 4; // EEPROM program 1 Monday flag storage location
const int P1_TuEE = 5; // EEPROM program 1 Tuesday flag storage location
const int P1_WeEE = 6; // EEPROM program 1 Wednesday flag storage location
const int P1_ThEE = 7; // EEPROM program 1 Thursday flag storage location
const int P1_FrEE = 8; // EEPROM program 1 Friday flag storage location
const int P1_SaEE = 9; // EEPROM program 1 Saturday flag storage location
const int P1_SuEE = 10; // EEPROM program 1 Sunday flag storage location
// Read stored program 1 week days flags and initialize at first run or on error
tempset = 1; // Start at array index 1
for(int count=P1_MoEE; count<=P1_SuEE; count++){ // From EEPROM address 4 to 10
P1_DAYS[tempset] = EEPROM.read(count); // Read each day flags
if (P1_DAYS[tempset] != 0 && P1_DAYS[tempset] != 1){ // If not initialized
P1_DAYS[tempset] = 1; // Set flag to enabled
EEPROM.write(count, P1_DAYS[tempset]); // Write flag back to EEPROM
}
tempset = tempset + 1;
delay(10);
}
// When alarm triggers
if(DS3231_triggered_a1() && wake_SET == 1){ // If alarm triggered and enabled
DS3231_clear_a1f(); // Reset alarm flag
if(P1_STAT == 1){ // If program 1 is running
wake_HOUR = wake_HOUR - P1_DURATION; // Update alarm hour variable with program 1 start time
setNextAlarm(t.wday + 1); // Check program 1 settings for next alarm
P1_STAT = 0; // Set program 1 flag to not running
}else{ // Program 1 not running
wake_HOUR = wake_HOUR + P1_DURATION; // Update alarm hour variable with program 1 end time
set_alarm(); // Write the alarm setting back to the RTC
P1_STAT = 1; // Set program 1 flag to running
}
sleepFlag = 1; // Set flag to sleep
}
// Function to set next alarm
void setNextAlarm(int day){
int flag = 0;
for(int i=day; i<8; i++){ // Count from day until Sunday
tempset = P1_DAYS[i]; // Set flag to temp variable
if(tempset == 1){ // If flag enabled
wake_DAY = i; // Set next wake day to alarm variable
set_alarm(); // Write the alarm setting back to the RTC
flag = 1; // Flag to indicate next alarm is set
break; // Exit
}
}
if(flag == 0){ // Run if hasn't set next alarm yet
for(int i=1; i<day-1; i++){ // Count from Monday until last day
tempset = P1_DAYS[i]; // Set flag to temp variable
if(tempset == 1){ // If flag enabled
wake_DAY = i; // Set next wake day to alarm variable
set_alarm(); // Write the alarm setting back to the RTC
flag = 1; // Flag to indicate next alarm is set
break; // Exit
}
}
}
}
Are you turning the arduino totally off or putting it into sleep and triggering it to wake up?
The RTC keeps track of day of the week, can you use that info instead of writing to eeprom?
Anthony
aiannar974:
Are you turning the arduino totally off or putting it into sleep and triggering it to wake up?The RTC keeps track of day of the week, can you use that info instead of writing to eeprom?
Anthony
I'm just sleeping the arduino and waking when the RTC alarm trigger or when the user press a button.
I'm only writing to the EEPROM a flag (0 or 1) for each day of week that indicates if that day should trigger the alarm. I use this flag to set the next alarm.