Help with Python coding to make the goTenna stay on

Is there anyone out there experienced in writing Python code? I have no experience in this realm as those that do can probably tell by my question below.

In an experiment to make the GTM re-boot remotely in a solar powered setting I ordered some parts from Adafruit including a mini push-pull solenoid, a mosfet and a Trinket microcontroller. I thought I would figure out the programming part easy enough but am realizing I am in over my head there. I have zero experience and capacity in writing code.

My planned experiment is to use the Trinket and a mosfet to control the power to the solenoid to push the GTM button for 2 seconds to restart the GTM after a power failure.

I plan to use a solar panel and voltaic V44 with always on feature. As long as the sun is out all is well. When the external battery and the GTM batteries die the system will shut down. When the sun comes out and charges the external battery I’d like the Trinket to wait 5-10 minutes after it senses power for the GTM to get a slight charge and then activate the solenoid for 2 seconds. This would reset the GTM into pairing mode. (I guess if it worked really well we could get it to triple tap the button twice to enter relay mode but I want to keep it simple for now and can live with the extra power consumption.) After that the Trinket could hibernate if possible until the next power interruption.

One thing I haven’t confirmed is if the V44 returns to always on mode after being depleted and power is restored. If that doesn’t work I’ll use a traditional battery with a low voltage disconnect. I know I could use a larger battery/panel combination trying to maintain constant power but I’d like to keep these as discrete as possible fitting inside the smallest Harbor Freight Apache hard case. Also the option to leave them out year round thru ice and snow is very enticing. My relays are high on mountain tops that take several hours to reach if they need attention. I can live with some down time while the sun is away if the GTM would just restart itself when the sun comes out!

Can someone get me started with some code that will let me test my experiment? thank you

The V15 does, so I think the V44 is likely to act the same way.

Sorry, can’t help with the code, but interested in what you are able to do with this.

The solenoid approach seems a bit powerhungry. If you’re recasing your GTM, you’re probably better off cracking it open and going with an opto-isolator on the back of the button pins like some people have been doing.

I’ve been working on this kind of deal, also with a Trinket M0. My plan is to poll the device using the opto-isolator-on-button method, reading the pulses with a photoresistor. My layout is going to look something like this, with the photoresistor on the bottom. It’ll be stuck on top of the EMI shield where the LED is.

I was going to do the code in C though, because I’m kinda used to that.

I’ll post my repo once I have something that compiles to give you an idea. Still waiting on a few parts to make this happen.

2 Likes

Here’s what I have that runs so far. Using LEDs to simlate the opto-isolators for the power button and 5V feed, it seems like it would do what it’s supposed to do.

Timing is probably very off, I’ll be writing a little tool that uses the opto-isolator to time the pulses on the GoTenna.

2 Likes

Thanks for the reply. I am very interested in your project and I took a look at your code. Unfortunately I might as well been trying to read Chinese! My brain is apparently missing the portion that deals with this stuff! I’ve got a couple questions I’m hoping you don’t mind putting into ultra-layman terms…

By powerhungry do you mean the solenoid, the Trinket or GTM in pairing mode?

I really only need the solenoid to run for 2 seconds and that is it. I don’t really need the Trinket to be powered the entire time, will it go into sleep mode?

I tested the GTM in pairing mode (white light flashing, not paired to a device) and found it uses about twice the power it does in relay mode. It stayed on for around 13 hours. I also get about 6 days of use from a Voltaic V44 when the GTM is in pairing mode. I can size my solar panel accordingly and really don’t need them to be 100% dependent if the sun isn’t out. My primary purpose is communication for wildland firefighters; if it’s rainy/gloomy we aren’t usually busy. I plan to have my relays assigned a GUID (it’s paired device is out of bluetooth range so I don’t also have to power the device) so I can ping/message them to ensure they are working. If this setup works really well I suppose it would be feasibl for the Trinket/solenoid to be able to handle the triple tap necessary to activate relay mode but for now I’d like to keep it simple.

I don’t plan to crack the case but was hoping I could carry out a physical press of the GTM button on any unmodified GTM.

I’ve done a basic test on the mini solenoid and it physically can press the button. A quick cycle of power seems to be about right to get the GTM activated. I will build or 3D print some sort of contraption to hold it all together and keep things aligned.

Is there any chance you could write me some code to get this started?

Thanks for your time either way!

3 Likes

IMG_1612

Here is a crude experiment to test the solenoid side of things. Switching the 5V manually I was able to turn on the GTM as well as activate relay mode. Sorry I couldn’t upload the video.

I think this will work if I can get the programming of the Trinket figured out.

2 Likes

The restart portion of the code would would perfectly fine with you setup if you decided to just power back on your GTM, I can cook it up for you so that it runs once after a certain power-on delay, triggering the solenoid once and then basically just freewheeling from there. On the hardware portion of it, with a properly sized opto-coupler, it really doesn’t matter if you’re bridging pins or using it as a relay, the prinicipal of operation stays the same: it’s essentially a relay, and could operate the solenoid.

My concern is that your whole project revolves around the idea of bring the GTM back to life from a state where it’s built-in battery AND the external battery bank are exhausted. From this scenario, you’d have a solar panel charging the whole ordeal, and when charge voltage becomes sufficiently high, you’d have:

  1. The GTM’s charge circuit pulling from the battery bank to charge it’s own internal battery (I haven’t looked this up, but most devices charged if not powered on)
  2. The Trinket powering on
  3. An inductive load from your solenoid
  4. The GTM powering on

All that on a battery that’s just barely charged. If draw of all these things is greater than than what your solar panel provides, or if the solenoid causes voltage to drop too much, we could end up in a scenario where your entire setup would discharge and essentially fall in a boot loop of sorts, even if the sun is shining.

We could configure a longer startup delay in the trinket, or compensate for this with electronics (a separate battery just for the solenoid, some capacitors before the solenoid maybe?).

Can you take real-world measurements of your panel’s typical output capacity and the power consumption of the whole setup booting up with the solenoid actuated?

Otherwise I can provide the code for sure, the hard part is trying to read the flashes, not pressing the button. You might even be able to do something with just hardware (a 555 timer chip and a few other components) although that’s a bit out of my wheelhouse.

Those are some good points. I’m sure there are lots of better ways to get this done but I think this method has potential and I am not one to sit still when there’s a problem to solve!

I’m sorry I don’t have a means of measuring power consumption. I believe the solenoid can draw 1.1A at 5v but I’ve tested it on the .5A of a computer usb output and it works fine. I am very limited in experience in electronics. If I remember correctly the GTM will only draw around 300mah while charging.

I was hoping the V44 battery I plan to use would delay the output power until its charged enough to avoid a power failure loop. The V44 has a 1A and 2A output. I would imagine looping would be a real problem with an undersized solar input. I’m leaning towards using a 12v 10w panel as I’ve seen some really quick recharge times on the smaller V15. If I have to I’ll put a 50w panel on it or whatever it takes! I think delaying the trinket for 15 minutes would be a good starting point.

I’ll be back at this on Monday and hopefully have it working! Thanks for the help with the code!

2 Likes

It works!

Check out the attached video to see this concept activating relay mode. In the video I powered on the V44 manually but in a solar situation I’m hoping this will happen as the power returns with the sun using the V44’s always on mode. Off to test that out next!

It appears the V44 has plenty of power to run this system as I’ve tested it at least 50 times with no change battery level as indicated by the lights on front.

3 Likes

Excellent! :fireworks:

1 Like