Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


lebleaux

12 posts

Geek


#272647 7-Jul-2020 21:12
Send private message

I have a bach in the far north that has a Raspberry Pi controlling a couple of Hue lights - lights come on in various patterns when the place is unoccupied. The bach has no internet access. The north suffers from occasional, short duration, power outages and so it is possible for the time to be lost and therefore the light show may not occur at the right time of day. To compensate for this I have equipped the Pi with a Pico UPS board and so can stand a power outage of about 30 mins before a controlled power down occurs. The Pico board has an onboard realtime clock and so, theoretically, when power is restored the Pi will have the correct date and time. I would like to be able to check this remotely. To this end I have installed a Huawei USB Stick 4G modem and, with the help of some 'programming by google' I am able to send an SMS to the Raspberry Pi and have it respond, via a text message, with its view of the date and time. It will also text me when it is running on battery, when it changes back to mains and if it has rebooted for any reason - all accomplished via some Python code and Node-Red. What I am trying to do now is send the Pi an sms with a date string and have it reset its date and time, just in case a power outage exceeds the time that the battery can keep the rtc working - not likely, but it is now a challenge.  Problem is I seem to be unable to get the Pi to accept a datetime change. If I run 'sudo date -s' with a date and time string I get all the appearance of success but then a simple 'date' command shows nothing has changed. I am now confused. Should I be looking to reset the system time and then synch the hardware clock, or do I target the hardware clock (I assume with 'hwclock') and assume it will then manage the system time. I would appreciate it if someone could point me at the right sequence and save me a lot of googling. Oh, NTP processing has been removed - no internet.

 

Thanks


Create new topic
timmmay
20580 posts

Uber Geek

Trusted
Lifetime subscriber

  #2518780 7-Jul-2020 21:34
Send private message

If this is for the fun of it, great, good to learn, but sounds like a difficult way to turn your lights on and off.

 

A few thoughts:

 

  • I'd save myself some time and just buy a bigger battery - 30AH should last a good long time without running it too low. Just get a 12V to USB converter from ebay, and a battery charger, problem solved.
  • Another approach could be to share the 4G connection via WiFi somewhere and control the lights from elsewhere - but I don't know much about those lights, it might not be practical.
  • I also use $10 digital timers from Mitre 10 that have a battery in them that lasts days or weeks without power but charges when there is power. Plug a regular lamp into those, set a schedule, problem solved cheaply and easily.



lebleaux

12 posts

Geek


  #2518782 7-Jul-2020 21:41
Send private message

Yep you got it in one. If I simply wanted to turn lights on and off I could find cheaper and easier ways to do it for sure - I just wouldn't learn a whole lot. In truth, I could probably ask my neighbours to keep an eye on the place when I am not there and not do anything. But where is the fun in that. So yes, I admit it, it is something of an intellectual challenge now ... game on.


frankv
5680 posts

Uber Geek

Lifetime subscriber

  #2519137 8-Jul-2020 12:25
Send private message

lebleaux:

 

If I run 'sudo date -s' with a date and time string I get all the appearance of success but then a simple 'date' command shows nothing has changed.

 

 

I suspect that this is something to do with the arcane art of quoting on the Linux command line. The 3 quote styles (" ' `) all have different meanings. From this, I think that you have to put the string into double-quotes, but I'm not up with this enough to know exactly what the right answer is, sorry. But hopefully it gives you an area to work on.

 

Or maybe it's because sudo will ask for a password on the console? Possibly you need to run the session as root rather than as a user and doing a sudo. Or (better) grant your user permissions to set the date?

 

 




tchart
2380 posts

Uber Geek

ID Verified
Trusted

  #2519270 8-Jul-2020 13:58
Send private message

I wrote an android app many years ago to do just this (with my Limitless LED bulbs). Its no longer available on the app store (Google got a bit heavy handed regarding apps that read text messages).

 

I'd recommend getting a cheap android phone ($50?) and using something like tasker or IFTTT, probably way less hassle.


littlehead
214 posts

Master Geek


  #2519387 8-Jul-2020 15:36
Send private message

Not an answer for the issue but would it be possible to get the time from the cell phone network, like how phones can get time from the cell network, and then update the Pi with that rather than manually send the time via SMS? You could then run that periodically via a CRON job and on reboot, so if it lost power and the time  sync, it could automatically sync to the correct time.


lebleaux

12 posts

Geek


  #2519565 8-Jul-2020 20:30
Send private message

Thanks all for the suggestions. I think I have cracked it now. I need to do a 'sudo date mmddhhmmyyyy' followed by a 'sudo hwclock -w'. Have successfully reset the clocks a couple of times via text but my code is a little flakey and so I will work on that now. I will also look into getting the time from the GSM system as well. I accept that what I doing is perhaps a little obsessive, but boy am I learning heaps. 


richms
28187 posts

Uber Geek

Trusted
Lifetime subscriber

  #2519572 8-Jul-2020 20:39
Send private message

Why not a GPS dongle and use that for time sync? The one I have was only about US$4 and gets enough signal inside to get the time ok within a few mins of powerup.





Richard rich.ms

 
 
 

Move to New Zealand's best fibre broadband service (affiliate link). Free setup code: R587125ERQ6VE. Note that to use Quic Broadband you must be comfortable with configuring your own router.
ghettomaster
387 posts

Ultimate Geek


  #2519574 8-Jul-2020 20:41
Send private message

lebleaux: I accept that what I doing is perhaps a little obsessive, but boy am I learning heaps. 



What you’re doing is really fascinating. Glad you’re having fun. This has been the most interesting topic today.

lebleaux

12 posts

Geek


  #2519693 8-Jul-2020 21:22
Send private message

Thanks for the encouragement and thanks for the GPS suggestion. I own a USB GPS receiver and am very familiar with handling the associated NMEA messaging - didn't even enter my head to use it for this exercise.

 

Hopefully this will be my last post until the next hurdle arises. My flakey code has turned out to be more a function of the fact that I ran out of prepay money on the sim card in the middle of this and had to do a topup, detecting that ahead of time might be fun.

 

Hopefully you might have guessed that there is potentially more to this than turning a couple of lights on and off. The basic skeleton I have now should allow me to develop the ability to do a whole lot more - turn on water heating, check tank levels, reset burglar alarms etc etc. The thing I wanted most of all was the ability to ask the Pi questions and have it respond with selected data, which I now have a framework for.

 

Best wishes to all


lebleaux

12 posts

Geek


  #2924475 9-Jun-2022 21:51
Send private message

Just thought I would provide an update if anyone is interested.

 

My bach burglar alarm has failed and so I thought I might as well make my own using the Pi that is already installed controlling lights. So ... a couple of RF Door Sensors and a 'hat' for the pi and I now have an SMS controlled burglar alarm - well a prototype anyway ... at this stage. Idea is that, upon locking the place up, I send a text to start monitoring the door sensors. If a sensor sends an 'open' message then on come all the lights and I get an SMS (as does Mrs Lebleaux). Can also stop monitoring with another SMS. Prototype is working fine, just looking into adding a siren.

 

Happy to share if anyone is interested.


Technofreak
6530 posts

Uber Geek

Trusted

  #2924490 9-Jun-2022 22:08
Send private message

I know you're well down your current track. However have a look at Home Assistant which runs on a Pi. I've just started playing with it. There's a whole heap of integration you can use and adapt for your requirements especially for alarm systems, monitoring water tank levels etc. It very customisable.

I'm very much a novice. With the basic set up we were able to arm/disarm the alarm and open /close the garage door from our phones and be notified if the alarm went off. I've just added functionality to monitor the open/closed state of the automatic garage door. More stuff like that to come.

I fully understand where you're coming from in so far as doing what you're did about resetting the date/time rather just buying a bigger battery.




Sony Xperia XA2 running Sailfish OS. https://sailfishos.org The true independent open source mobile OS 
Samsung Galaxy Tab S6
Dell Inspiron 14z i5


michaelmurfy
meow
13252 posts

Uber Geek

Moderator
ID Verified
Trusted
Lifetime subscriber

  #2924500 9-Jun-2022 22:34
Send private message

I do appreciate how you're doing automation in hard mode but sometimes it is a good idea to step back and work out a simpler way of doing it.

 

You mention no internet - but 2degrees on their Carryover Plans allow for data sharing to up to 5 devices. You can then grab a 4G Wireless Router (available for next to nothing - I even saw some at the tip shop the other day) and data share to a prepay sim in that (free!) - you'll be able to get both the Pi and the Hue Bridge online and just use good ole NTP.

 

Comes in handy if you want to pop up some cameras too!





Michael Murphy | https://murfy.nz
Referral Links: Quic Broadband (use R122101E7CV7Q for free setup)

Are you happy with what you get from Geekzone? Please consider supporting us by subscribing.
Opinions are my own and not the views of my employer.


fe31nz
1232 posts

Uber Geek


  #2924524 10-Jun-2022 00:16
Send private message

lebleaux:

 

Prototype is working fine, just looking into adding a siren.

 

 

You need to be aware of the rules for sirens on security systems - they have to turn off after a maximum time so that the neigbours do not have to call noise control on you.  I think this is in an NZ Standards document somewhere.  This needs to be fail safe - the siren should not come on if there is a fault in the system.


johno1234
2806 posts

Uber Geek


  #2924548 10-Jun-2022 08:12
Send private message

richms:

 

Why not a GPS dongle and use that for time sync? The one I have was only about US$4 and gets enough signal inside to get the time ok within a few mins of powerup.

 

 

That was my thought too... as long as the device is near a window and gets a bit of sky view.

 

Plug both GSM and GPS dongles into the raspberrypi USB ports and not only will it know the time, you can ask your bach if it is still in the same place! :-D

 

 


Create new topic





News and reviews »

Air New Zealand Starts AI adoption with OpenAI
Posted 24-Jul-2025 16:00


eero Pro 7 Review
Posted 23-Jul-2025 12:07


BeeStation Plus Review
Posted 21-Jul-2025 14:21


eero Unveils New Wi-Fi 7 Products in New Zealand
Posted 21-Jul-2025 00:01


WiZ Introduces HDMI Sync Box and other Light Devices
Posted 20-Jul-2025 17:32


RedShield Enhances DDoS and Bot Attack Protection
Posted 20-Jul-2025 17:26


Seagate Ships 30TB Drives
Posted 17-Jul-2025 11:24


Oclean AirPump A10 Water Flosser Review
Posted 13-Jul-2025 11:05


Samsung Galaxy Z Fold7: Raising the Bar for Smartphones
Posted 10-Jul-2025 02:01


Samsung Galaxy Z Flip7 Brings New Edge-To-Edge FlexWindow
Posted 10-Jul-2025 02:01


Epson Launches New AM-C550Z WorkForce Enterprise printer
Posted 9-Jul-2025 18:22


Samsung Releases Smart Monitor M9
Posted 9-Jul-2025 17:46


Nearly Half of Older Kiwis Still Write their Passwords on Paper
Posted 9-Jul-2025 08:42


D-Link 4G+ Cat6 Wi-Fi 6 DWR-933M Mobile Hotspot Review
Posted 1-Jul-2025 11:34


Oppo A5 Series Launches With New Levels of Durability
Posted 30-Jun-2025 10:15









Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.