Cool stuff for Raspberry Pi, Arduino and all electronics hobby projects
Notifications
Clear all

[Solved / Archived] Zero2Go Omini rev2 - can firmware modification change start behavior to watch single input?

8 Posts
2 Users
0 Likes
248 Views
(@johnfreundracing)
Posts: 6
Active Member Customer
Topic starter
 

Hi, I picked up a zero2go omini rev2 to see if it could work for a project of mine.  The behavior goals for me are:

1) would like to have two voltage inputs to the board, one on Input B and one on Input C, where Input B is used as a start signal only, and Input C supplies input power.

2) the board only starts the pi only if Input B is above a configured threshold (say > 5V).  

After reading the manual, and reviewing the high level circuit diagram in the manual, I'm unsure if this is possible.  I can tell out of the box the system is not built to let me select which input governs the start behavior, instead having the highest voltage of the inputs used.  What I couldn't tell is if the power to the Pi is governed through purely electrical circuitry (thus not likely allowing me to pick one input for the start logic), or if the MCU has control over it (and thus hopefully I can change behavior in the firmware to let me pick Input B to control start).  I tried looking over the firmware and I'm really not a good programmer, so am uncertain if what I want is possible via modification (though I'm still looking at it).  

Is it possible to modify the firmware to gain the behavior above, where power/start-up for the Pi is only triggered/connected based on one of the three voltage inputs compared to the configured threshold?

 

 

 
Posted : 02/02/2025 9:06 pm
(@johnfreundracing)
Posts: 6
Active Member Customer
Topic starter
 

I forgot one other goal:

3) while system is in off state (Pi is powered down and input voltage B is below threshold) the system draws minimal power from Input C

After staring at the firmware and getting some better understanding it does appear the firmware controls the comparison of input voltages, and the power to the Pi.  So with that key piece I think I have some rough ideas on how some of the goals are possible:

1)  for shutdown behavior modify loop() so voltage comparison for shutdown is only looking at vb (could just change "float vmax = vb;").  

2)  for startup behavior modify sleep() so it doesn't care about the button, and only watches vb for startup

not sure I understand how to do 2 yet.  I have zero arduino experience.  It looks in sleep() there is some interrupt driven behavior with the button that wakes up the cpu, does a voltage check, and starts up only if the voltage comparison is good.  I see a sleep_cpu call that I'm guessing is to reduce power draw, and I'm guessing that's broken by the interrupt triggered I'm guessing via the button.  I could call the sleep_cpu still, but I'm not sure how then to wake periodically for a voltage check, or if that's even the smartest idea to keep power consumption low.  Could the awakening of the cpu be ADC triggered?  

 
Posted : 02/02/2025 10:23 pm
(@admin)
Posts: 587
Member Admin
 

Zero2Go's firmware is rather simple (compares to Witty Pi's).

Your ideas are basically correct, and you just need to have things done correctly.

The sleep_cpu() function puts the MCU into sleep mode, for saving energy.

The MCU will be waken up by watchdog timer with a fixed interval. Although the watchdog interrupt routine function does nothing, the wakening will happen for every 1, 2, 4 or 8 seconds (share the setting for blinking LED). The sleep_cpu() function will return in such case, do some checkings, if no action need to be done, it goes back to sleep by calling sleep_cpu() again.

You will need to setup your Arduino IDE for compiling the new firmware. You may read this page for the how-to: https://github.com/uugear/Witty-Pi-3/wiki/How-to-compile-the-firmware It is for Witty Pi 3 but I believe it also works for Zero2Go's firmware.

Considering you are new to Arduino, it is recommended to test your new firmware without attaching Raspberry Pi on it. You can use multimeter to confirm the input and output voltages, make sure the logic is correct before using it with Raspberry Pi.

 
Posted : 03/02/2025 9:32 am
(@johnfreundracing)
Posts: 6
Active Member Customer
Topic starter
 

Thank you for the key information!

After thinking it over and learning from what you shared, I think I literally only need to change the vmax lines in both sleep() and loop() so that they are "float vmax = vb" so vb is my only measured value for the comparison to the thresholds, and then enable low voltage threshold and recovery voltage thresholds to my needs.  Then I need to just modify the daemon.sh to execute my shutdown actions when the shutdown signal is suggested via the GPIO.  

 
Posted : 16/02/2025 7:50 pm
(@johnfreundracing)
Posts: 6
Active Member Customer
Topic starter
 

I have a small issue trying to verify my code.  I added the 1.2.4 analogComp library to my IDE but am getting  a "#error Sorry, microcontroller not supported!".  Did you use perhaps a different library?  mine came from https://github.com/leomil72/analogComp/releases/tag/1.2.4

 
Posted : 16/02/2025 7:59 pm
(@admin)
Posts: 587
Member Admin
 

@johnfreundracing We use the same library, but I think we use the previous version (1.2.2). 

I don't think the version actually maters: either version doesn't claim to support ATtiny841. However ATtiny841 is considered as a improved version of ATtiny84, which is supported by this library. Choosing ATtiny84 in the menu and you should be fine.

 

 
Posted : 17/02/2025 6:33 am
(@johnfreundracing)
Posts: 6
Active Member Customer
Topic starter
 

Ah the version did matter.  Per your manual I needed to get this codebase from orangekucing, not the one from leomil72: 

 
This one worked just fine.
 
I was then able to upload my custom firmware and initially it didn't work as I'd hoped, waiting on a button press.  After looking more at the code I realized that initial startup won't occur based on voltages unless the button is pressed first.  However I noticed if I set the default for I2C_LV_SHUTDOWN, the register indicating low voltage shutdown happened, to 1, then I get into the behavior loop I get the system to start up if the voltage is presented to input B that is above my default threshold.
 
Now I have to set up my version of the daemon.sh code in the pi OS to trigger shutdown, verify shutdown happens if I lose voltage on input b, and then also if the system will start back up if voltage is restored to input b.  crossing my fingers...
 
 
Posted : 23/02/2025 7:49 pm
(@johnfreundracing)
Posts: 6
Active Member Customer
Topic starter
 

So this all works on my test bench as hoped!  Now to just test in a real world automotive electrical environment.  

 
Posted : 25/02/2025 11:54 pm
Join Waitlist We will inform you when the product arrives in stock. Please leave your valid email address below.