Main source-file for the high-precision logging voltage/current meter project.
More...
Main source-file for the high-precision logging voltage/current meter project.
The code in this project asks two BY56W volt/current meters for measurements, calculates a few additional values (min/max/power/Ah/Wh) with these, prints them to displays and sends them (with time/date values) to a UART port so a Sparkfun OpenLog can log these measurements to a .TXT
file, which can eventually be renamed to a .CSV
so the measurements can be easily plotted.
- Version
- 1.2
- Author
- Brecht Van Eeckhoudt
Versions
- v1.0: Initial version.
- v1.1: Started printing date before time for each measurement-line, removed day-writing in footer.
- v1.2: Compared power floats more reliably.
- Todo:
- Things to do in the near future:
- Check Ah/Wh calculations.
- Check if the power/Ah/Wh calculations are done using wrong/old measurements.
- Handle uint32_t wraparound for time between calculations measurements and waiting time.
- Don't send/do certain functions if one of the meters is powered down.
- Todo:
- Long-term future improvements:
- Add function to stop measurements when the voltage/current is (above/) below a certain value.
- Add external temperature reading functionality.
- Add internal temperature reading functionality (
MX_ADC1_Init();
).
- Add interrupt-logging functionality.
- Add relay-opening functionality.
- Add "manual measurement-mode" to log on up-button press.
- Add "performance-mode" with no display refreshes.
- (sub-page on right display, start/stop with up, beeps for confirmation)
- Add low-battery beeping.
- Add buzzer functionality using TIM2 (
MX_TIM2_Init();
).
- (short beep button-press, longer when measurement taken, add ON/OFF settings page)
- Optimize encoder logic so there is less copy-pasting.
- Add debounce logic to
getSW0();
, getSW1();
and getENCkey();
.
- Use
LL_GetTick();
instead of HAL_GetTick();
?
- Add circular pages for setting day/month/hour/minute/second (
changeDateTime
).
- Add day-checking in function of the month?
- Use defines for circular pages?
- Start using
aBY56W_ContinuousRead
? Send on every meter power-up?
- Only one while-loop (
USART_HandleContinuousReception
) when one meter is connected, way more if both are? Optimize this?
- Add overflow catch if data.voltage/current are negative values?
data.power > 999.999
, data.ah > 9999.999
, data.wh > 9999.999
- Remove all Segger-RTT functionality?
- Store settings in power-down-safe memory.
License
Copyright (C) 2021 - Brecht Van Eeckhoudt
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
A copy of the GNU General Public License can be found in the LICENSE
file along with this source code.
Some methods also use code obtained from examples from STMicroelectronics.
Copyright (c) 2020 STMicroelectronics. All rights reserved.
These sections are licensed by ST under BSD 3-Clause license, the "License"; One may not use these example files except in compliance with the License. One may obtain a copy of the License at: opensource.org/licenses/BSD-3-Clause
Definition in file main.c.