-
Actually, that's not a bad idea. The battery will be unplugged when not in use anyway (regardless of a toggle switch in).
So I could use BTN1 to start and stop the logging and go into deep sleep when not logging. That would then give the signal to close files and unmount the SD card before power is removed. Would also mean I don't need to put a toggle switch in.
That sounds really sensible and deep sleep is something I've not used before (as an Arduino user) so would be good.
As you say, if everyone was having problems, you'd be flooded with issues.
I'll try this new process and see how I get on.
Thank you Gordon, really appreciate it.
Cheers
Ian
-
Hi Gordon,
Thanks, sounds like a possibility so tried the following.
Ok, card is freshly formatted as FAT32. Put card in Espruino and power up via LiPo battery. Let the above code run for 30 or so seconds. Disconnect power. Eject SD card and put in reader.
I have eight files all called "Test.txt". If I open them all individually they all contain the same values, I.e. Few lines into log the getTime() values are all 2 seconds apart.
I've checked the files again on a Mac (in case PC was problem) and its the same. Strange.
I'll try a different card first, but if that doesn't help, can you advise if there is a better way to do this? Ideal situation for me would be:
- Apply power. Code runs automatically starting in the onInit() function.
- Once GPS has acquired a 3D fix, create a file named from the date/time from GPS module.
- Every time a new GPS position fix comes in (it's set at 1Hz), capture values from the three weather sensors and write position, date/time and sensor readings to this file as a single string.
- Repeat everytime the GPS sends a new position sentence.
- Remove power to end the logging.
Applying power and removing power will be a simple toggle switch in the +ve line from Lipo to Espruino. This would allow multiple flights (and date/time labelled files) to happen from just cycling the power.
Guess I just need a way to ensure a flush and dismount between each file write?
I'm rambling here, I'll try a different card first.
Cheers
Ian
- Apply power. Code runs automatically starting in the onInit() function.
-
And to add to this, it appears to be running at half speed when it writes to the file if you look at the data. It should be once a second but after the first few values, it very accurately writes every two seconds.
5.00040340423 6.00036048889 8.00035190582 10.00035953521 12.00035476684 14.00034523010 16.00034523010 18.00039958953 20.00035858154 22.00036430358 24.00035572052 26.00037193298 28.00035285949 30.00035285949 32.00035858154 34.00038909912 36.00037765502
I moved to the Espruino from an Arduino to have built in SDcard logging and more pins. And I thought integrating the sensors was going to be the hard bit, but that has been super easy. :)
-
Hi All,
I'm building a sensor data logger with my Espruino 1.4 board with latest firmware.
Reading the reference (couldn't find a tutorial), if I wanted to write data to the onboard SDCard once a second, it looks to be as simple as:
function onInit () { var sdCard = require('fs'); setInterval(function () { sdCard.appendFileSync("Test.txt", getTime() + "\r\n"); }, 1000); }
And I should get a single file named "Test.txt" containing a list of system times.
However, if I let it run for a while, disconnect power and put the SDCard in a reader, I actually end up with around (it varies) 8 files all called "Test.txt" all which contain the same information, mainly. This is strange because I can certainly not create two files with the same name via a PC.
I'm guessing from this that I missing a step, like closing a file, flushing etc. But reading the reference this looks like it should be synced.
Can someone advise please. The data logger will fly on a multicopter for atmospheric monitoring so would like any data to be written to the file as it is collected rather then storing in memory, then writing due to the inherent risks of flying these small craft.
Cheers
Ian
-
Over a year later...
With the BMP180 (Adafruit) the module works fine @ltj, thanks for the code.
On a much older BMP085 (Hobbytronics) I'm getting odd I2C timeout error, maybe every 20 samples. But just increasing the sampling pauses by 10ms solves that.
Works very well.
Cheers
Ian
-
Hi All,
New to all this. I'm a software developer by trade and rarely touch hardware.
But I'm interested in the Espruino with a view to connecting a BMP180 barometric pressure sensor to log pressure reading.
Has anyone used this combo? Or could you advise if there is any reason it wouldn't work? Looking at using this one: http://www.adafruit.com/products/1603
Cheers
Ian
So simple but elegant solution. Always helps to have a second pair of eyes on an issue. Thank you Gordon.
(Yes, my mindset is still arduino loop)
Cheers
Ian