The program's name I'm testing with is called "enviromon". Replace that with your own. The combination of openocd and gdb to debug works great. To flash to µC only openocd is needed with a commandline: $ openocd -f /usr/share/openocd/scripts/board/stm32f4discovery.cfg -c 'program ./target/thumbv7em-none-eabihf/release/enviromon verify reset exit'

To see the size of the binary (release version, not debug): $ cargo size --bin enviromon --release --verbose -- -A

During techinc.nl's Electronics Friday, I was having trouble with getting to Binky with a STM32 board I had laying around. It was the first time working with this board, and ARM in general. The trouble was writing to the STM micro. I've tried stlink but not much luck there.

void loop() { // put your main code here, to run repeatedly: digitalWrite(MYPIN , HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(MYPIN, LOW); // turn the LED off by making the voltage LOW delay(1000);}

On the board I need to change the Resistors marked R1 and R2The boards "R1" is between Solar+ and pin6 (MPPT) called R3 in the Application CircuitAnd "R2" of the board is between Gnd and pin6 (MPPT) which is called R4 in the Application Circuit.

The MPPT pin (pin6 on the NC3791) regulates so that there's 1.205V on that pin. So, for there to be 1.205v on MPPT pin, there needs to be ( (R1+R2)/R2*MPPT = (178+45.3)/45.3*1.205= ) 5.93V on Solar+ . So, yea. that makes sense for the 6V variant.

We want it to be at 1.205v when there's 15v and I'd rather only change one of the resistors. 15v to 1.205 is a ratio of 12.45 (6v has a 4.92 ratio). Lets day that ratio is X. So, taking our formula of (R1+R2)/R2=x we can transform it into R1=(x*R2)-R2. Or (12.45*45.3)-45.3=518.7. So We'll need to replace R1 with a 519KOhm resistor. Neat.

Unfortunately I don't have a 519KOhm resistor laying about. I only have the famous R12 series. But there's http://www.qsl.net/in3otd/parallr.html which helps find a good combination of common value resistors to make the value you need. Best values for 518.7K are: two in parallel: 680000 || 2200000 = 519444.444 (0.144 %) andtwo in series: 470000 + 47000 = 517000 (-0.328 %)

I've been looking a bit into supercaps (capacitors in the >1F range) and they are now readily available. While the Available Farads keep going up, prices are dropping as well. Since they have often have low voltage ratings (2.7v is common), you'll need to put a few in series for most applications.

Unfortunately, when uploading the device reports "Track Truncated". THis means that the track contains more points then the device can handle. On my Vista can only read tracks that have up to 500 points, it can however, write 10k points to the sd-card, So I need to reduce the number of points. gpsbabel can do this as well by filtering the file

But I preferred to use the bikehike service where you can up and download gpx files and allows to reduce the number of points and check the result. To reduce the number of points, it is the "options" setting.

Uploading new mapsGrab them from garmin.openstreetmap.nl If you want to make bike routes, select the "Routable Bicycle (Openfietsmap Lite)" type of map. Select the tiles or countries, download the .zip and drop the contained .img file into the "garmin" directory of the device.

Using an old SHT11 part I had laying around. The SHT11 is an obsolete part, having been replaced by the Sensirion SHT3x line. But even that doesn't seem to be widely used in hobbyist market anymore, places like Sparkfun now use use other Chips. Probably because of this, I couldn't find an ESP32 library for this. I could find a Raspberry-PI python, one for Arduino and a version for ESP32 (also in C++).

I've decided to try to port the Python for the rPI as it seems to need the least changes.

After a bit of messing about, writing a few shims was the quickest solution, and it works, even if it's not the cleanest.

This will connect to port 2300 of machine '192.168.8.129' (DNS names are also valid here) and write "foobar\n" to the socket before closing the connection. To test this, the nc/netcat application can help like so

For the Solar powered ESP32 project, I want to keep track of solar and battery voltages. To track them, we use the ADC (Analog to Digital Converters) of the Micro Controller.

The ESP32 has 18 (!) 12bit ADCs channels and their normal operation is between 0 to 1.1volt. You can set the input to attenuate the input to other ranges as well (up to 3.3 volt), but since a voltage divider is needed already, I can just as well attenuate to between 0 and 1.1 volt already.

At 1.1v and with 12bits resolution, (2^12 = 4095 steps) the each value of the ADC represents (1.1v / 2^12=) 0.269mV. Pretty awesome resolutions. But the expectations is that the least significant bits will be dancing all-over and the 1.1V voltage reference will not be that accurate, limiting the absolute accuracy.

Both battery and Solar inputs have voltages greater then 1v so we need to scale them. The simplest is to use a simple voltage divider where the middle pin goes to the ADCs pin.

The battery voltage goes up to 4.2V when charging. adding 100mV of margin should prevent ever "topping out" the scale. So we need to scale 0-4.3V to 0-1.1V. What values to use? The formula is R1/(R1+R2); where R1 is the value you will measure over and the R2 is the other value. An awesome combination is R1=1, R2=3.3, which is (1/(1+3.3)=) 1/4.3. So, if the input value is 4.3V, the output would be exactly 1V. a good match. Also because 3.3 is a value in the standard resistor series . Another reason is that even in the case of gross overloading, the absolute maximum 3.6V of the ESP32 is far far away, making it safer.

Okay, but power wise we'd have 4.3v going through 4.3Ohm, running 1A of current and burning 4.3W of power. Not at all ideal for a solar project. If we multiply both R1 and R2 by 100K, we get 100K and 330K resistors. Still standard values and only using 10µA. Much better.

The ESP32's ADC's pin will also draw some current. The spec doesn't specify how much, except that it's "high". Which generally means "A couple of Mega-ohms at least". We'll measure later how much it really is. But since I don't currently know how much, having 10µA is a safer choice then going for even higher resistor values.

So, to test it, hooked up the divider from 3.3V pin to ground. Measuring the voltage with a multimeter, I get 3.298V from the 3V3 Pin and the divider midpoint gives 0.755V. Great. well within the 1V range. So lets hookup the midpoint to Pin36.

For the solar panel voltage the maximum expected voltage is 8V. So a reasonable value for that voltage divider is R1=100K and R2=680K... at 8V this would give 1.027V on the ADC. Which fits works fine. To damage the ESP, the solar voltage would need to be in the 28V range, so that's quite safe even on the sunniest of days.

There is a Led on the sparkfun esp32 thing that the software can turn off and on. This is Pin 5. It's capable of both a GPIO and PWM.

To control it:

>>> import machine>>> from machine import Pin>>> p5 = Pin(5, Pin.OUT)## The Led will now turn off>>> p5.value(1) # Turn it on>>> p5.value(0) # and off.>>> from machine import PWM>>> pwm5 = PWM(Pin(5))>>> pwm5.freq(1) # The led blinks on and off in one second. >>> pwm5.duty(10) # The on part is much shorter now.>>> pwm5.freq(30) # Around 30 cycles per second, Persistence of vision takes over.

After realizing that i'm more and more using Aliexpress' "ordered" list as the source for what parts I have available, I've decided to sink the time into getting Partkeepr available for myself and Techinc hackerspace. To keep the service maintainable the trick is to install the service from a vanilla Debian box. I had tried that before, but got stuck on wanting to auto-config the partkeepr as well. @realitygaps gave the hint to just use the whole Partkeepr app and database as the data to backup and just run the standard update-setup process when a new version is released. So, that's what's prepared now. There are installation and backup Ansible playbooks. https://github.com/chotee/parts

So, I have a system I need, and even if nobody but me uses the installation, I can help others by exposing what parts I have available at cost.

Integrating the inventory in techInc would clearly be a more interesting project... but first, I need to master the tool by itself.