add missing records, then report and exit

150 views
Skip to first unread message

Tomás

unread,
Jun 19, 2024, 9:43:19 PMJun 19
to weewx-user
Hello, I have a weatherlink and a raspi working with weewx doing a good job for two years. The raspi is turned on for 5' for5-6 times daily, downloads the data from the console and reports to wunderground mainly. I'd like the routine to stop after finished, so I can turn off the raspi as soon as posible.

I have not found through weectl device or database an option to download only missing records.

Is there a way to do this? I could save some more miliamps this way.

Thanks!

vince

unread,
Jun 19, 2024, 10:56:41 PMJun 19
to weewx-user
Geez how much do you spend for power?  Why would you possibly want to do this ? 

Even at $0.30 per kwh a pi4 would only cost $0.02 per day to just leave it on..,

michael.k...@gmx.at

unread,
Jun 20, 2024, 6:43:31 AMJun 20
to weewx-user

vince you may have not thought about the problem getting the the needed energy there. If there is no grid-based power supply it may be hard to run a raspberry pi continuously at that location. Anyway, knowing more about the use case could lead to more ideas to solve the real problem.

vince

unread,
Jun 20, 2024, 12:33:43 PM (14 days ago) Jun 20
to weewx-user
That was what I was asking.   "Why would you possibly want to do this?"

The answer can't be money because any solution such as a smart switch or downgrading to a pi-zeroW would cost more than the annual savings in energy.

Greg Troxel

unread,
Jun 20, 2024, 1:20:54 PM (14 days ago) Jun 20
to weewx-user
Indeed the real goal is important.

I can certainly see having weewx have some kind of status output (a MIB
:) that indicates whether it has successfully processed all the archive
records and written the database (and run reports), so that a supervisor
process can shut it down.

I do not see most people wanting to spend time on that, so the OP has
some code to write.

vince

unread,
Jun 20, 2024, 1:37:08 PM (14 days ago) Jun 20
to weewx-user
Here's the problem...
  • shutting weewx down does nothing to save power
  • shutting the pi down saves 'almost' nothing because it draws so little
  • the WLL is still on and using power to act as a datalogger in the interim
  • and internet connectivity requires 'some' hardware powered on as well
  • and any hardware solution will cost more than you'd save in power in 3+ years probably
So I'm not seeing any use case making any sense at all here to even bother trying to over-optimize the 1-3W a pi draws.

michael.k...@gmx.at

unread,
Jun 20, 2024, 3:13:02 PM (14 days ago) Jun 20
to weewx-user
You still don't know the problem, but state, there is no such.

I can think of one: 1-3W x 24h = 25 - 72Wh is quite another category of a problem to solve, without a grid backed power source, than 5-6 x 5 min x 1-3W = 0.42 - 1.5Wh would be. One LiFePO4 18650 battery holds about 6Wh, so the difference between "always on" and "turning on only when needed" is one vs. 24 such batteries for the same running time. Now that's what I call a use case. Still, without knowing the problem, my idea of a use case isn't any better in terms of a possible solution than stating, that there isn't even a problem to solve.

Tomás

unread,
Jun 23, 2024, 12:36:46 PM (11 days ago) Jun 23
to weewx-user
Thanks Michael

Currently the pi is powered by a 7ah AGM battery plus a solar panel. The system is installed 5000 feet above sea, and the panel gets covered by snow now and then. In this scenario the battery (with performs poorly due to low temperatures) holds on for 1Ah at the most. 

Pi consumes around 250mAmps plus a 4G modem that takes another 250mA, battery runs for 2 hours...  second counts, plus the setup would be neater!

Currently it went offline.

Sorry for catching up later I had notifications turned off.

Thanks for the interest, hope I find a way!

tguo...@gmail.com

unread,
Jun 23, 2024, 12:47:46 PM (11 days ago) Jun 23
to weewx-user
Thanks Greg! this should be achievable knowing the code. Would really help!

(had to google it MIB: Management Information Base)

vince

unread,
Jun 23, 2024, 2:10:05 PM (11 days ago) Jun 23
to weewx-user
Wow - very interesting setup. A lot of questions come to mind:
  • what model pi are you running ?
  • have you stripped the os down to the bare minimum number of processes running ?
  • have you stripped down the services weewx runs to the minimum ?
  • what is the power savings you measure by killing weewx ?
  • do any of those changes have measurable impact on power consumption ?
For a pi-only software solution I'd just use bash and cron periodically:
  • check if weewx is running or not
    • if not, start weewx up and await it running the WU upload after the first archive period
  • watch the weewx log to see if the WU upload has logged that it has completed its upload.  You could do this with a custom rsyslog.conf entry and log only WU stuff to a particular file
  • when the WU log is populated, rotate that logfile (for the next run) and kill weewx and exit
  • (and use cron to periodically start the script of course)
Basically your script would watch for the WU-only logfile to be non-zero size with a particular content in it saying the upload was complete.

For a hardware solution I'd look for a hardware-only way to use an arduino or pi pico to actually power the raspi down completely, but then you'd need a RTC in the weewx pi (another battery needing to work in low power).  One interesting link I found with pointers to some others is https://stfn.pl/blog/34-pico-power-consumption-solar-panels/ if that helps any.  The author there has a lot of links and there are pointers to some adafruit boards that might help if you wanted to try a hardware solution.

FWIW - I fiddled with deepsleep etc. on a pico when they came out but didn't have anything that could measure how little power they sip when deep sleeping.  I do know that a pi itself still draws a lot of power when powered off although you can edit the os setup to minimize this.  See https://www.jeffgeerling.com/blog/2023/reducing-raspberry-pi-5s-power-consumption-140x for details. I can confirm his blog solution works on a pi5 and pi4 but never tried it on a pi3 or zero or old model-B so I don't know there.....

michael.k...@gmx.at

unread,
Jun 23, 2024, 3:33:07 PM (11 days ago) Jun 23
to weewx-user
After optimizing the power consumption, consider using an LTO (Lithium Titanate Oxid) battery, it should outperform the AGM in every aspect. The downside is you need a rather sophisticated battery management and for LTO batteries, there isn't really much to find. Depending on how low the temperatures really get, LiFePO4 batteries should also do the job, and there are lots of BMS on the market. 

tguo...@gmail.com

unread,
Jun 24, 2024, 8:00:30 AM (10 days ago) Jun 24
to weewx-user
Im using Pi 3B+, currently an external timer powers up the pi for 5 minutes, sufficient to wait for the NTP server, and start weewx to download the console and upload to wu. But if I miss a couple of days then there's too much data, and 5 minutes isn't enough, something smarter should be done.

As you were saying,  I'm getting an RTC to start periodically my weewx, but I need another process to shut it down. Will try to understand your proposal.

tguo...@gmail.com

unread,
Jun 24, 2024, 8:07:13 AM (10 days ago) Jun 24
to weewx-user
Lithium would be the way! Already studying a solution this way.

But I need a process to download the console and shutdown the pi. I could also do without the weewx's LOOP, something with weectl.

vince

unread,
Jun 24, 2024, 1:57:18 PM (10 days ago) Jun 24
to weewx-user
If you use rsyslogd for logging, here is a /etc/rsyslog.d/weewx config file snippet that logs anything WU related to a separate file

# log wunderground to other file
if $msg contains '
Wunderground-PWS: Published record' then /var/log/weewx/weewx-wunderground.log
Reply all
Reply to author
Forward
0 new messages