How to measure power / voltage from solar panel using Espruino

Posted on
Page
of 2
Prev
/ 2
  • Just a few details about sd cards and data logging:
    a-All SD cards have an internal controller that, totally transparently, manages, eventually bad flash sectors, as well as strategies to speed up apparent writes to the card. It does take time to finish the writes internally. They, for instance, can be grouped by this controller.
    Furthermore, there is no way for the 'host' MCU to now about the real moment the operations ended. So the worst thing to do is to cut off power, or pull out the sd card, too soon: You get randomly unreliable results because the writes were not really finished by the controller.

    A delay of a few seconds, somes wrote 30 s, seems to solve it.

    The Raspberry Pi forum has tons of discussions about it.
    I solved it, on a Raspberry Pi, by using:
    1-an overlayfs which places a ramdisk for writes only, and some sub-trees only, above the flash memory,
    2-a crontab task that copied, every 4 hours, the overlayfs ramdisk to the SD card..... Which means that I accept to, eventually, loose 4 hours of data measurements.

    b-Another problem is consequent of the 10 000 maximum writes on the same flash sector: It systematically happens when you append to the same file. The directory containing this file is updated at each and every write to the file.
    This kills very efficiently an SD card in a few days, 8 to 10 days on my Raspberry Pi. Raspbian, ext4fs, groups writes per 5 seconds blocks. This parameter can be increased but it becomes system wide which is not safe at all.

    A simple solution is to use sub-directories which are written to a limited number of times to their contained files. Indeed, this is why photo cameras are using /DCIM/xxxx/yyy.jpg tree structure for saving to the SD card.

  • Thanks for the info - on the Espruino board the SD card's power comes straight from the 3.3v line - so turning off the power too quickly isn't going to be a problem for it...

    I think it's most likely a voltage level problem...

  • I was just considering the frequency (10 s) at which data were logged.
    Also, just powering out is a problem, it really is a matter to keep power on for the SD card's controller.
    In case of power outage, or pulling out the power cable, a few seconds after a write you might find some symptoms like those described by Espruino_user_dk.

    Of course an unreliable power supply is a problem more critical.
    By the way, some SD cards do need almost 200 mA during writes or there too.
    Wifi SD such as Toshiba's Flashair are also requiring 200 mAsustained during all of their connection but this is due to Wifi itself and these are not microSD.

  • Yes, and the voltage regulator will only handle 150mA (larger Vregs waste way more current). It could be a problem but personally I haven't had troubles with it for SD cards - only WiFi where the chip does draw a lot of power.

  • Clearly, beeing battery operated does imply some compromises for the Espruino board itself as the key point is autonomy.

    Sandisk specs, in my previous post, specify 2.7v to 3.6v and 100 mA at 25 MHz (200 mA at 50 MHz) which could be compatible with 3 AA rechargeable batteries for instance (3 * 1.2 v) directly connected after the voltage regulator. This could, on a battery operated mode, supply far more than enough mA for an SD card.

    This is also compatible with the STM32F1 voltages and Amperes.

    So the problem is that, either you slow down the writing speed to the SD card, and then it needs only 100 mA at write time, or, you are lucky to get an SD card that doesn't need so much power: No one reads or writes the spec's mA required for a particular SD card maker/model at least not until you got some failure.

    Could this be a software only improvement suggestion?

  • The filesystem currently only runs SPI at 1M baud, so that's unlikely to be the problem. You can actually already set the baud rate manually just by using the filesystem once, then just running SPI2.setup again with the new baud rate.

    I still think not using the voltage regulator is a bad idea. A fully-charged NiMh battery (which could be likely if charging from solar power) is around 1.4v, so 3x = 4.2v which may well destroy your SD card (and which is also too high for the STM32).

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

How to measure power / voltage from solar panel using Espruino

Posted by Avatar for Espruino_user_dk @Espruino_user_dk

Actions