sparkfun / OpenLog_Artemis

The OpenLog Artemis is an open source datalogger the comes preprogrammed to automatically log IMU, GPS, serial data, and various pressure, humidity, and distance sensors. All without writing a single line of code!
https://www.sparkfun.com/products/15846
Other
88 stars 47 forks source link

Software reset #105

Closed alino93 closed 2 years ago

alino93 commented 3 years ago

Hi @PaulZC, I have been using the Slowlogging feature to reduce the power consumption of the boards at night and normal (fast) logging during the day. The boards are powered by a Lipo battery.

My problem is that if the battery dies, OLA does not turn on again automatically even after being charged by a wall adapter. The only way to turn it on again is the reset button or connecting to a computer. I give these sensors to very old people and it would be a lot easier to have a software solution to turn the board on again. Could we have a software solution to reset OLA? Like after fully charged? or at certain times of the day?

Thank you, Ali

PaulZC commented 3 years ago

Hello Ali (@alino93 ),

Unfortunately, the feature you are asking for is difficult to implement.

When the main battery dies, the Artemis goes into a very low power state which keeps the Real Time Clock (RTC) running. The only way to wake it from that state is with a reset.

The only safe way to keep the RTC running is to leave things as they are now.

I am happy to keep discussing this, but I do not think it is possible to give you the feature you need.

I think the simplest solution might be to ask your patients to make sure they recharge the OLA every night?

Best wishes, Paul

alino93 commented 3 years ago

Hello Paul (@PaulZC),

Thank you for the clarification.

I ask the patients to charge the OLA every night but unfortunately, they usually forget.

Ok, a scheduled reset is not going to work because the RTC will reset and there is no easy way to generate a reset when recharged.

Is there anything that I could add to the charger to reset the OLA every time they connect it to? (like when we connect the OLA to a computer)

Regards, Ali

PaulZC commented 3 years ago

Hi Ali,

Humm... A standard USB-C charger would not generate the reset. But maybe we could design a very simple board which you could plug in-line to generate the reset after a few seconds... I shall think more about this!

Best wishes, Paul

alino93 commented 3 years ago

Paul,

Thank you very much, that would be great!

Best, Ali

alino93 commented 3 years ago

Hi Paul (@PaulZC) I, unfortunately, lost two patients this past month because of this issue. Could you please help me to solve this issue or tell me to look where if I want to do this? Thank you again, Ali

vicgwee commented 3 years ago

Hi Ali,

I'm really sorry to hear that.

If I'm not wrong, this board that Paul suggests would need to act as an USB Host, so it can connect with the CH340E chip to tell the OLA to reset. I'm not sure whether anything like that exists on the market right now.

Just wondering, would it be possible to tell the patients to press the reset button when they charge it? That could be a stopgap solution.

Victor

PaulZC commented 3 years ago

Hello Ali,

I am very sorry to hear about your patients.

We have not forgotten about your request, but we are a small team and we are working on many other projects at the moment.

As Victor (@vicgwee) says, you need something which can: deliver power to the OLA via USB; and act as a "USB Host". The "USB Host" emulates a computer, and would need to open a serial connection to cause the OLA to reset.

SparkFun do offer a USB Host Shield and that may do what is required. It would need to be connected to a "RedBoard". You would also need a standard power supply or wall adapter (with a 5.5/2.1mm power jack) to connect to the RedBoard. I do not have one of these boards, but I will try and get one to test.

There are other possibilities, such as this small board from Hobby Electronics: https://www.hobbytronics.co.uk/usb-host-board-v24 . Again, I do not have one of these boards, but I will order one to test. It may work on its own, or it may have to be connected to a microcontroller to open the serial connection. Again, it will need a separate power supply.

If either of these is successful, then - with some design effort - it would be possible to make a compact version dedicated to your project.

I will let you know when I have more news.

Very best wishes, Paul

PaulZC commented 3 years ago

Hello Ali,

I have ordered both boards. I will let you know when I have more news.

Best wishes, Paul

alino93 commented 3 years ago

Hi Paul,

Thank you very much, that would be great please keep me updated. As Victor suggested I have tried to add a reset button and asked the patients to press it every morning but they tend to forget, also pressing it when the battery is empty resets the RTC.

Best, Ali

PaulZC commented 3 years ago

Hello Ali,

I have tested both the Hobby Electronics board and the SparkFun USB Host Shield.

The Hobby Electronics board is a very nice little product, but it can not (currently) generate the RTS reset pulse needed to wake the OLA. I have reached out to the Hobby Electronics team to see if it would be possible to add this feature.

I have had limited success with the SparkFun USB Host Shield. I was able to adapt some code which someone else has written to support the CH340 (the USB interface chip on the OLA):

So, right now, I do not have a fully-working solution for you.

I know you want to keep your OLA assembly as compact as possible, but would it be acceptable for you to include a Real Time Clock module? I could alter the OLA code so it would:

Please let me know if that would be an acceptable solution for you.

Best wishes, Paul

alino93 commented 3 years ago

Hi Paul,

Thank you for testing and working on a solution. So it seems the USB host shield is not working for me because the Redboard always should be kept on. What about a raspberry pi board, could we program it to open a serial port and reset the OLA?

About the RTC module, should I add this module to the OLA assembly? Or could it be outside and ask the patients to connect the Qwiic cable to do its job?

Best, Ali

PaulZC commented 3 years ago

Hello Ali,

Raspberry Pi is another possibility. It would need (e.g.) a Python script which: runs on start-up; keeps checking for a CH340 connection on USB; if it sees one, toggle the RTS pin to reset the Artemis. It should all be feasible / possible but I have not written that type of Python code before.

The RTC module would be permanently connected to the OLA via a short Qwiic cable. It would not affect the battery life - it’s current draw is very low. But it will of course make each logger larger.

If your patients cannot remember to press the reset button, I do not think they would be able to remember to connect a Qwiic cable during charging?

Best wishes, Paul

PaulZC commented 3 years ago

There are some good suggestions here on how to detect if a serial device is connected / still connected:

https://stackoverflow.com/a/49450813

alino93 commented 3 years ago

Paul,

Yes connecting the Qwiic cable is not a good solution and pressing a button seems a better idea. But the assembly is already large and I do not want to make it even larger. I think this way the thickness of my assembly would increase at least 1.5 times which is too bulky to mount on the body (I use 5 sensors on each person).

I will do some research about the Raspberry Pi solution and let you know.

Thank you, Ali

PaulZC commented 3 years ago

pySerial includes a function called rts which can be used to set the state of the RTS pin.

And here are suggestions on how to run a script on start-up: https://learn.sparkfun.com/tutorials/how-to-run-a-raspberry-pi-program-on-startup

Best wishes, Paul

alino93 commented 3 years ago

Thanks Paul, this helps. Best, Ali

alino93 commented 2 years ago

Hi Paul, I managed to solve the issue a while ago using a Raspberry Pi by installing the CH340 driver on it and creating a autostart for a small script. I have explained what I did here for the record.

I was thinking maybe I can use the Raspberry pi to set the RTC every time it is connected to the OLA (update with the Pi's time). Or other things like downloading the data, etc.

I think we can close this issue. Thanks, Ali