Hi Spark Community,
This thread is dedicated to providing and discussing information on alternative power sources for the Spark Core. Although using the built for spark battery shield is recommended, some projects and hobbyists are better served by alternative products that are more compact, conservative, etc. Please use this thread to discuss any such products that you have found helpful in powering your projects, giving as many essential details as you can (cost, recharge time, battery life, etc). Thanks all for continuing to be awesome Sparkans!
Hi Spark Community,
The_Anthony, a lot has been discussed in this topic started by timb. You may find all your answers there including details on timb’s upcoming NEW battery shield with battery charging and solar input.
One solution I used this past week was a Powerocks Magicstick:
I think I got it as a freebie at some conference but Amazon sells them. I am using it to power my ‘Internet of Things Physical Like Machine’ aka a wireless candy dispenser. I needed a stand-alone power source that fit into a CD-R spindle/case. You can just see the Magistick on the bottom level of this photo:
It seems to successfully power the Sparkcore, the motor relay and dispensing motor itself long enough for table top demos. The relay requires 5 volts so it connected that to the VIN pin.
OT question - is powering a small, 5V sealed relay from the VIN pin dangerous to the SparkCore itself? Nothing bad has happened for several days but am I running the risk of bricking my Core?
I don’t think the danger from the relay is due to the voltage per se, but driving relays (or other inductive elements) is tricky because when you stop driving them they try to continue with the current they had flowing when you were driving them and this can lead to voltage spikes. That is why relay drivers normally have a diode across the coil going “backwards” so that these voltage spikes don’t harm the circuit driving the relay. Here’s a schematic I found online–the 1N4001 is the diode.
If this is how you are driving your relay, you will be fine.
I had been talking to @The_Anthony on Twitter a bit about this, based on a little remote temperature sensor that I had made with my Spark. I used this:
I previously had it (and still use it for) charging my cell phone when away from home for extended periods of time. It’ll drive a spark reading a tmp36 temperature sensor every 30 seconds and echoing the computed temp to a UDP port on the local network for about eight hours.
Related - does anyone know if there are any techniques to decrease power consumption?
There’s a few main factors for power consumption (some are general)
- Speed of the processor.
core is on 72Mhz. Going lower reduces power consumption but up till a certain Mhz you will have issues with
delay() etc. Mainly those stuff using clock signal.
As long as you know what to be tweaked, you can still get stuff running! I used to do that to save power on my project which needs to stay outdoor for weeks and not doing intensive stuff.
Changing all this requires local compiling for now though…
- Wifi tx/rx
The main bulk of power consumption comes from the Wifi module. Like 200-300ma during active connections
If you don’t need instant monitoring (sounds weird for temperature monitoring), you can turn of the Wifi and only connect once every few XXX and transmit one shot. Something like 30mins and above intervals would be nice or you end up using more power turning on and off the Wifi module.
- External devices
If you’re only having the temp sensor then there’s probably nothing irrelevant to be removed
- RGB led status
Never underestimate the leds! They use up power quietly… Use the Spark functions to get em turned off and on it using code occasionally to check on the status. Or just use D7 as the indicator (blink, fast blink, X number of blink etc)
pthread, you may wan to look at this topic:
To save power, the idea is to sleep between read/send activities. So you read the temperature, open a UDP port, send your data, close the port and go to sleep for 30 seconds. After 30s, the Spark wakes up and the process starts over. During sleeps, the power consumption drops to below 20ma so that should extend your power considerably.
Wow thanks so much (also @peekay123 below!). Both amazing responses!
I just got back from a climbing trip and wished that i had a GoPro to video the journey + a core logging the entire route i took and the pressure…temperature…etc.etc…
Time to prepare before my next adventure…
How do I turn wifi off. My code is interrupt driven and my cite contacts a server when an event happens. So I don’t need wifi when no event has been triggered.
To turn off Wifi and/or Spark.connection at startup:
To turn Wifi on/off in your loop():
To check Wifi status:
WiFi_Status_TypeDef current_wifi_status = WiFi.status(); //save in current_wifi_status
The conditions available for WiFi.status()
To connect to Spark.cloud on/off in your loop():
Perfect. Thanks much for the reply. Is this documented somewhere. I wonder what else I’m missing …
Not really in the official docs yet but yeah…
This way of connecting and disconnecting is under active development by the Spark team so they are going slow on doc’ing this. The concepts are the same, but the names are likely to change in the future and they didn’t want to put this in the doc and deprecate it a few weeks later.
Hey @kennethlimcp, I’m trying to turn wifi on and off in my code but the spark build doesn’t compile the WiFi.on() method, any ideas?