The software for Data Logger based on a super handy WebIOPi Internet of Things framework. I would suggest to check their website for more details. We will use version 0.7 of the framework.
I will omit all WebIOPi installation details (see their website). From the WebIOPi config standpoint, we need to configure two GPIO ports to automatic pull-up in OUT mode. This two ports will be used in low-power detection logic. The state of this two ports will be periodically analyzed, and if port 18 is "0" - the Data Logger will start playing an annoying alert beeps (means the battery is low), and right after the port 23 will get to "0" (means the battery is almost dead) - the Data Logger will loudly announce the "initiate of shutdown sequence" and power off.
Also we need to configure and enable two ADC devices. The reference voltage is 2.5 V.
# Initialize following GPIOs with given function and optional value
# This is used during WebIOPi start process
18 = OUT 2
23 = OUT 2
adc0 = MCP3008 chip:0 vref:2.5
adc1 = MCP3008 chip:1 vref:2.5
We will supply our own custom python script which runs by WebIOPi framework and register it in the WebIOPi config in "[SCRIPTS]" section. The script implements several mandatory methods: setup(), destroy() and loop() which are called by WebIOPi at script loading, at server shutdown, or periodically. Also we have to add in this script a several REST endpoints as a python macros (annotated as @webiopi.macro) in code:
- getAvailableSpace() - return a free space in MB on Raspberry Pi;
- toC() - serialize a user configuration settings on file system;
- getDate() - return a local date and time on Raspberry Pi;
- getTempSimple() - return a current set of values from Temperature ADC in JSON format;
- getVISimple() - return a current set of values from Voltage/Current ADC in JSON format;
- startRead() - enable reading and serialization of values from both ADCs;
- stopRead() - disable reading and serialization;
The menu system on Status screen is very simple. The Export option allows you to download the CSV file with the collected data. Note that when a configuration gets updated on Configuration screen, the CSV files are rewritten, so you always get a latest data. If you need to keep the recording results for future - make sure that you export the data before updating configuration.
If on Configuration screen for Starting Mode you selected "Start Menu on Status Screen" (like on the screenshots), you will get one additional menu option named "Action". There you can pick "Start" or "Stop" option to control the logging process manually.
The last moment worth to mention is that the Data Logger also works as a Wireless Router and Access Point, since the easiest way to get the data from it is to use Web UI over Wi-Fi. For the detailed instructions I'll redirect to the nice article which I followed with a small variations. The Raspberry Pi is a regular Linux box, so basically it should have a DHCP server, Wireless Access Point, Routing and IP-Forwarding services configured. With a proper (Realtek-based) Wi-Fi dongle it work flawlessly in the field, and can provide internet to your tablet, laptop or phone in lab if you plug Ethernet cable from your cable or modem in the Raspberry Pi jack.