DS3231 RTC with EEP...
 
Notifications
Clear all

DS3231 RTC with EEPROM, Square wave and alarms.  

Page 2 / 2
  RSS

dxj
 dxj
(@dxj)
Eminent Member
Joined: 6 months ago
Posts: 25
2020-03-03 7:44 pm  
Posted by: @dxj

I'll leave it powered down overnight to see if it drains completely again. 

I turned the power off on the breadboard and there was no drain or loss of time on the RTC. Seems the diode did the trick.

ds3231 serial wiring

 


ReplyQuote
dxj
 dxj
(@dxj)
Eminent Member
Joined: 6 months ago
Posts: 25
2020-05-26 2:43 pm  

Just checking in to say that I'm healthy and employed during the Coved-19 pandemic. Hope all of you are healthy and coping too.

I recently picked up my autonomous sprinkler project again; started by playing with a bi-stable latching water solenoid. Meh, not thrilled with it because it limits flow pretty significantly and I can't regulate the flow like I can with a ball valve, for example ... so I revisited Bill's excellent tutorial on stepper motors and easily incorporated the 28BYJ-48 and UNL2003 controller into my project to create an electric ball-valve driven by the stepper. I also ordered a worm-gear set and misc hardware for the valve.

I'll post an updated diagram, sketch and pictures when I work through all the details. For now, I'll post a code snippet that turns off the stepper pins (to conserve battery power) after the stepper reaches it's desired position. The Adafruit stepper library is lacking an "off" function, so I posted a solution below.

It's really quite obvious and simple:

void stepperPowerOff () {
digitalWrite(STEPPER_PIN1,LOW);
digitalWrite(STEPPER_PIN2,LOW);
digitalWrite(STEPPER_PIN3,LOW);
digitalWrite(STEPPER_PIN4,LOW);
}
This post was modified 2 months ago 4 times by dxj

ReplyQuote
dxj
 dxj
(@dxj)
Eminent Member
Joined: 6 months ago
Posts: 25
2020-05-28 2:20 am  

This prototype is meant to simulate the opening of a ball valve, going to sleep and then turning the ball valve off again after being woken up by an alarm clock.

I added the UNL2003 breakout board to control the stepper motor. The stepper is moved one turn clockwise prior to system sleep and 1 turn counter-clockwise after the system is woken up by RTC interrupt. The steppers hold-power is turned off after each operation to conserve battery. 

Code for the sketch can be found here.

Please refer to Bill's excellent tutorial on stepper motors for the stepper library setup.

New functions I wrote to control the stepper:

void motorTurn (int motorSteps) {
char buff[100];
snprintf(buff, sizeof buff, "Turning stepper hold-power on.\nStepper executing %04d steps.", motorSteps);
Serial.println(buff);
Stepper steppermotor(STEPS_PER_REV, STEPPER_PIN1, STEPPER_PIN3, STEPPER_PIN2, STEPPER_PIN4);
steppermotor.setSpeed(STEPPER_SPEED);
steppermotor.step(motorSteps);
motorPowerOff();
}

void motorPowerOff () {
Serial.println("Turning stepper hold-power off.");
digitalWrite(STEPPER_PIN1, LOW);
digitalWrite(STEPPER_PIN2, LOW);
digitalWrite(STEPPER_PIN3, LOW);
digitalWrite(STEPPER_PIN4, LOW);
}

Breadboard diagram below.

ds3231 with unl2003 serial wiring

 Limit switches will be added next.


ReplyQuote
Page 2 / 2