-- Leo's gemini proxy

-- Connecting to ew.srht.site:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

2021-05-08

Easy Addition of Solar Energy Supply to Homebrew Project

tags: hardware forth TheStack


These days I received some more parts for tinkering. Yes, all environmentally questionable electronics. The better news is probably, that I did put a solar charge controller to use, after having it for many months. And the good news is: it actually just worked.


Solar Energy, medium size


The charger is a thing offered by crowdsupply.com[a]. It has its price, but already setting the thing up was so nice, that for me it is already worth every cent. The charger controller is accessible via i2c. The documentation is top notch[b], the firmware, code for the Pi and Arduino projects are available, too. Very nice.


I added a 12V/10W Solar panel and a 10Ah battery (these are the new items).


Controller


The project that the above is providing energy for, is a Atmel Atmega644pa controller plus some periphery to serve as a remote sensor station. It features:


controller board from my "TheStack" project[c]

rfm12 radio (434 MHz ISM band) from HopeRF

a Geiger counter from AATiS[d] similar to the mighty Ohm[e]


Firmware


The controller cannot do anything at all unless enhanced by a bit of machine readable code. The most common languages for this kind of endeavour seems to be C. However, due to some unforseen quirk of spacetime along my personal trajectory, I prefer Forth, with the occasional sprinkle of AVR Assembly language. More precisely I use AmForth[f].


So the firmware for this particular controller does actually very little, it sleeps most of the time:


After starting up execution enters a loop.

When idle, the controller goes to sleep.

The controller wakes up from sleep every 8 seconds triggered by a clock crystal and Timer/Counter2.

Once every 8 cycles (64 seconds) the data of the available sensors is collected and sent (indvidually) over the radio link.

Sensor 1: the voltage of the battery as reported by the charge controller.

Sensor 2: the impulse count from the Geiger counter, which is collected in Timer/Counter1 even during sleep. Send the accumulating 16 bit count as is, don't worry about wrapping (which happens after approximately 2 days).

Sensor 3: the difference to the accumulated count reported 8 cycles ago is sent as a separate sensor reading.

Sensor 4: uptime of the controller in days (this is sent only once per day or 1350 intervalls of 64 seconds each).

The format of the record sent via radio is very simple: 1 byte StationID, 1 byte SensorID, 2 bytes data, 2 bytes fletcher16 checksum.

Between individual radio telegrams wait 20 ms.

Go back to sleep.


Yes well, this could be done differently, of course. And no, the data records are not signed, and not secured in any way against spoofing or denial of service. But the format is simple. And I decided a long time ago, that I will just collect this data for visual inspection. No automated action is derived other than the data collector (a perl script) sending an email message, if a given station ceases to report for more than one hour.



Easy?


The main reason why I write this mostly uninteresting event down, is this: In the past weeks I spent more than 20 hours to get to grips with a Bosch Sensortec BME280 sensor. Using this with C firmware is not difficult. But the official code and documentation leaves much to be desired by me. Remember, I chose Forth over C. So I have to understand all the quirky bits about going from the raw readings to human readable physical dimensions. The C compiler does an outstanding job to select the correct (signed or unsigned, for any given length) operations on the raw data. I failed to see everything I needed and gave up on the calculation of the pressure. I managed to get plausible results for temperature and relative humidity. Never before have I seen such an awkward interface --- oh well. Yes there are working implementations in Forth. I found one for msp430, but I didn't understand the code in sufficient detail, sorry!


However, talking to the charge controller was a breeze and I got the values I wanted and understood them in something like 2 hours. Very nice! Thanks!



Cheers,

Erich


References


[a] makerPower Solar on crowdsupply.com

[b] user guide on github

[c] home of TheStack on sourcehut.org

[d] AATiS Homepage (German), AS622 Bausatz

[e] The Mighty Ohm Geiger counter project

[f] AmForth project


See also

/en/2019/20190324-TheStack-first-prototypes.gmi


Home

-- Response ended

-- Page fetched on Wed Oct 20 20:33:46 2021