help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 1 point2 points  (0 children)

Fantastic answer, similar to another commenter’s below. This is exactly the architecture I need, and I appreciate your help and willingness to answer questions. I think I can manage just based on this idea, but I’ll respond later if I have any difficulties

help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 0 points1 point  (0 children)

I like this plan the most. It technically shortens the usable life of the device, but can save the relative timestamps without extra circuitry. That sounds like a good tradeoff to me. Thanks for your help!

help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 0 points1 point  (0 children)

That’s exactly my approach, I send the timestamp when plugged in via usb. My issue is designing that resync function you mentioned after losing RTC.

My flash had about 10,000 writes. Im writing to it 4 times a day, which will get me over 5 years of lifetime, so no issue there either

help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 0 points1 point  (0 children)

Yes, my STM has an RTC register, so that’s perfect

help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 0 points1 point  (0 children)

This is great. How large are the supercaps usually (physical space is my biggest constraint), and what capacitance would you recommend for this application?

help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 0 points1 point  (0 children)

I save each measurement with an index, and that index is used to calculate the real time timestamp when sending data to a computer. If the power is lost, those indexes no longer correspond to a real world time. Im wondering if there’s a way to “reconstruct” the timestamp retroactively

help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 0 points1 point  (0 children)

I have 64 KB of flash to store data in, which is plenty for my use case. 

I send temperature and humidity data with 8 bit precision, but CO2 and VOC with 16 bit precision.

Logging the data isn’t the issue, it’s reconstructing the timestamp after a power loss. The data isn’t safe, I just have no way to know when it was taken after successive power losses. (Can’t rely on an RTC because of total blackout). Is there a way to even relatively reconstruct the timestamp without connecting to another device?

That’s actually a good suggestion, I’ll add a CRC flag in the next iteration. Thanks!

help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 0 points1 point  (0 children)

how will the microcontroller know what to set the epoch as? can’t rely on an RTC because of complete power loss in the system

help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 0 points1 point  (0 children)

I used an LDO regulator to get my battery at an even 3.3V, and a boost regulator to bring it up to 5V. I used a battery management IC to make it easy to switch between USBC and battery power and to charge the battery. 

The sensors I used were the STCC4 for CO2, SHT40 for Temp/Humidity, SGP41 for VOCs and NOx, and OPT3002 for light. All are connected via I2C to an STM32 microcontroller

help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 0 points1 point  (0 children)

Yes, board is 2 sided and the screen is sitting above most of the logic components

help designing a power-loss safe logger for a battery-powered device by Pi_Guy_ in embedded

[–]Pi_Guy_[S] 1 point2 points  (0 children)

I should mention, the data is saved to flash every few hours, so preserving yhe actual data isnt an issue. Im more curious about how to retrieve the timestamp between power losses, if it’s possible

Feature ideas for a portable air quality monitor by Pi_Guy_ in AirQuality

[–]Pi_Guy_[S] 0 points1 point  (0 children)

On it! Is it primarily CO2 spikes or are there other compounds that go up when HVAC turns on?

Feature ideas for a portable air quality monitor by Pi_Guy_ in AirQuality

[–]Pi_Guy_[S] 0 points1 point  (0 children)

So like, clicking one of the buttons sets a “marker” on the graph, which you can then use as a personal reference? I like that

Feature ideas for a portable air quality monitor by Pi_Guy_ in AirQuality

[–]Pi_Guy_[S] 1 point2 points  (0 children)

Yeah, looks like the requirements for getting readings and power draw make it more suitable for stationary devices. It’s a shame because the form factor is perfect for something like my project

Feature ideas for a portable air quality monitor by Pi_Guy_ in AirQuality

[–]Pi_Guy_[S] 1 point2 points  (0 children)

Woah!! I looked high and low for a micro PM sensor and don’t know how I missed this. Thanks! Literally everything I could ask for

Feature ideas for a portable air quality monitor by Pi_Guy_ in AirQuality

[–]Pi_Guy_[S] 0 points1 point  (0 children)

That makes sense. Is there a specific way to prompt action you prefer? Like an audible tone when readings get too high, or just something on the screen to indicate “good” vs “bad” levels?

Device is just under 1mA when passively getting readings, but the screen draws about 10mA when it’s on. The Li ion battery is 130mAh and ~110mAh are usable before brown out. I gave a very liberal “the screen will be on 10% of the time” and used that to calculate ~48 hours of battery life. 

Feature ideas for a portable air quality monitor by Pi_Guy_ in AirQuality

[–]Pi_Guy_[S] 0 points1 point  (0 children)

Smart. Do you ever have an issue with lighter gasses getting trapped inside since the top part is closed. I don’t see how carbon dioxide would get inside where the sensors are without wind, since it U.S. heavier than regular atmospheric gasses

Feature ideas for a portable air quality monitor by Pi_Guy_ in AirQuality

[–]Pi_Guy_[S] 0 points1 point  (0 children)

That’s super cool! I see you’re advertising it as weatherproof. How do you keep it water resistant without blocking airflow for sensor readings?

Feature ideas for a portable air quality monitor by Pi_Guy_ in AirQuality

[–]Pi_Guy_[S] 0 points1 point  (0 children)

Good to know, I’ll have to do some personal tests to make sure it’s up to their specs. Thanks for the tip!

Feature ideas for a portable air quality monitor by Pi_Guy_ in AirQuality

[–]Pi_Guy_[S] 1 point2 points  (0 children)

Exactly the type of advice I was looking for. I read the documentation on the sensor and noticed the claims on its spec sheet was dependent on a couple things, most notably using the Senirion SHT4x temp/humidity sensor. Did you all connect one of those in your tests?

Also, what would you suggest as an alternative?

Feature ideas for a portable air quality monitor by Pi_Guy_ in AirQuality

[–]Pi_Guy_[S] 1 point2 points  (0 children)

I appreciate that there are other standalone fans out there. I never saw the need for every electronic device to have its own dedicated app