rszimm / sprinklers_pi

Sprinkling System Control Program for the Raspberry Pi
GNU General Public License v2.0
310 stars 100 forks source link

Feature Req: Change Time #47

Closed Stifler6996 closed 8 years ago

Stifler6996 commented 8 years ago

I want to build one of these for the family. Since they are not 'networked' as such, I will set the Pi up as an access point for them to 'connect to'. It would be nice to have the ability to adjust the time in settings.

Perhaps a 'daylight savings' check box, and the ability to change the time manually.

Good work!

DrTron commented 8 years ago

Use a RTC module for the pi. Those are really cheap, have a backup battery and communicate via I2C. If you set your timezone correctly (raspbian setup tool) the daylight savings time is corrected automatically.

Stifler6996 commented 8 years ago

Thanks, Dr Tron. So what am I missing? I have one of those, but it takes over 3 GPIO. Is there a work around I am unaware of? I still need the full 16 outs. (New to Pi, Old School Electronic Engineer here!)

DrTron commented 8 years ago

Not really, what RTC do you have? I2C always needs the following pins, but you can use those for several I2C devices as every device has its own address on the bus: Pin 2 5V Pin 3 SDA Pin 5 SCL Pin 6 GND True, Pins 3 & 5 are GPIOs, but the Raspi has enough of them. Especially the Raspi 2.

Stifler6996 commented 8 years ago

I have this model: http://raspberry.piaustralia.com.au/collections/crusts-add-ons/products/mini-rtc-module

It sits over pins 1,3,5,7,9 on the header, so uses up 3,5 and 7 GPIO.

Did you see my other request to 'adjust' which GPIO is used for what? As I said not much C++ here, but point me in the right direction if it can be done. Ill work it out :)

Thanks

DrTron commented 8 years ago

Rewire it. Remove the 5-pin-socket and solder wires directly to the pins on the RTC. You can then place it wherever you want. As an I2C device, it only needs Pins 3 & 5 and a power supply plus ground from somewhere. C++ is not my field, either. But what do you desperately need to connect to 3 & 5? I use I2C devices, too, and use them on those two pins.

Stifler6996 commented 8 years ago

Thanks for the reply. I think we are on the same page, but there must be something I am missing.

So on the main header, physical pin (3) is either GPIO 2 or SDA, which translates to WiringPi 8. Pin (5) is GPIO 3 translating to WiringPi 9. So if I enable I2C, then they are no longer available for GPIO. Therefore I lose "Zone 8" and "Zone 9" as working outputs.

The same happens if you want serial (GPIO 14 and 15, which become TxD and RxD).

So I guess this might be related to my other request: How do I use different GPIO (or WiringPi) outputs to drive the relays? Is there a mapping somewhere, or is it 'automatic' etc?

Example, How do I use GPIO 24 (physical pin18) to drive (WiringPi-8) Zone 8 relay ?

Thanks for helping me understand this :)

DrTron commented 8 years ago

So you got some software using wiringPi which uses WiringPi 8 & 9 and can't configure it differently? Not very smart software, if you ask me. You'd need to ask the programmer how to change the mapping, I don't know if WirinPi can do it by itself.

Stifler6996 commented 8 years ago

Errr. You are aware that sprinkler_pi does in fact use WiringPi right?

That is all I am trying to do.

DrTron commented 8 years ago

Yes, but I haven't used in a while so I'm not aware which pins it uses and I don't know which relay board you have. I use the OSPI board, which allows me to control my sprinklers as well as run I2C devices without conflicts. If you use one GPOI per relay, that may get difficult.

rszimm commented 8 years ago

Stifler, look for ZoneToIOMap in the file core.cpp. It defines which wiringpi Pin is used for each zone. You should be able to map around the pins that do SPI if that's what you want assuming you have spare io somewhere else. You may not need an rtc though. Make sure ntp or ntpdate is installed and your pi should sync itself on reboot. If you set the time zone, daylong savings should all be automatic.

DrTron commented 8 years ago

I think his Pi is connected to a local network which doesn't have internet access. Sure, you could run a timeserver somewhere in that local network, but that might be pushing things ;-)

Stifler6996 commented 8 years ago

Hi Richard, Thankyou you answered my question. To answer yours; (1) I will be installing this in a remote location, it will be set up as an Access Point. NTP server would have been trivial however no wifi in the middle of a farm!! Using a phone or tablet to connect and configure. (2) In a timezone that no one can get right, with respect to daylight savings! (3a) Firstly I wanted to use RTC, to keep the clock correct for when generators go down, So I need to skip over those GPIO. (3b) GPIO 14 (WiringPi 15) starts out as TxD for serial. Whilst I have defined my own device-tree-overlay at boot (https://www.raspberrypi.org/documentation/configuration/device-tree.md), for the first second or so, the TxD still outputs causing the relay to chatter. So I could implement a hardware timer to delay 5V to relays, or I can skip that GPIO entirely.

Thanks, I'll close this out.