Need help with remote vehicle start

Good idea on the USB battery pack, in fact I think I’d recommend you do it that way anyway and the Spark board will thank you for it. Most USB packs have a micro USB input for charging and a full USB socket as output, so you could leave it plugged in constantly and it will charge from the lighter socket when the car is running. I think off the shelf battery packs universally have overcharge/discharge protection.

One final thing to consider if you go that route: You might want to do the maths on Spark current draw vs. the longest time your car is likely to be off. Bear in mind that when a USB battery pack says something like “3000mAh”, and the Spark drawing 300mA max doesn’t mean you’ll get 10 hours of life out of it. The pack rating is usually the rating of the internal LiPo cell, @ 3.7v, so after stepup and conversion losses you can probably count on about 50-60% of that.

Good luck!

Additionally, if you decide to go this route I would be very tempted to setup one of the Spark’s ADCs to measure the “incoming” voltage from the car so you can tell when the car is “off”. That way you can intelligently estimate remaining back life and conserve power. It may turn out that you very rarely turn you car back on within say 5 hours of turning it off. You core could sleep during that time and perhaps survive till morning. Just a thought

A USB battery is a great idea. Many cars won’t start if the battery voltage drops below 12V and you shorten the life of it the longer it stays below about 70% capacity. You’ll be amazed at how fast you can drain a 50-60A car battery low enough to not start.

I received my Core and have it connected to my phone and am able to turn the onboard tiny LED on and off. I have attempted to start to code a program for my remote start by editing the remote control car example, but I know it won’t work. Hopefully you can see what I’m attempting to do with this code.

I’ve created a Github account and pasted the code there: https://github.com/CodyET/Remote-Start/blob/master/Remote%20Start

Thanks,
Cody

1 Like

Looked it over and added my take. I issued a pull request: https://github.com/CodyET/Remote-Start/pull/1 for your repo. Let me know what you think

Thanks for the help.

Everything you had looked reasonable to me, so I have updated my code to match what you had.

I then flashed the code from the build page to my Core. And now I’m stuck again. I had thought that the Tinker app could be used to set up buttons to press, but now I realize that isn’t the case. So how do I go about getting a user interface created with buttons for me to press?

Thanks,
Cody

1 Like

I can hack in tinker support later tonight if you’d like.

Otherwise I don’t know of a tutorial offhand, I’m on mobile so it’s hard to search. Here’s a link to a report for a project I did which has a functional webapp. perhaps take a look at that? http://hhj.me/rgblibrarydemo the github repo link is in the top right

Thanks for the link to your webapp. I’ve taken a look at it and started editing it for my purposes. Here’s what I have so far http://codyet.github.io/ The repository is: https://github.com/CodyET/codyet.github.io/blob/master/index.html

I’ve got it setup to display how I’d like with the four buttons, but I really don’t know for sure what I’m doing in the script. I’ve tried to edit it for my project, but I’m sure it needs fixing.

The script is supposed to push the buttons defined in the Core code, right?

Good start! I think you have have been a bit too overzealous to make the button bigger and tore out too much code so it didn’t work as expected. I think I’ve gotten it to a state to work. I just shot you a pull request. Give it a try and let me know

Thanks for making those edits. I merged your changes into the webapp. However, I gave it a try and it isn’t working for me. When I try to send a command to the Core the webapp says “Sending…” for about 20-30 seconds then comes back with “Command Failed!” When I use Inspect Element from my Chrome browser and click on the console tab, I get the following:

Objecterror: "Timed out."ok: false__proto__: Object__defineGetter__: function defineGetter() { [native code] }defineSetter: function defineSetter() { [native code] }lookupGetter: function lookupGetter() { [native code] }lookupSetter: function lookupSetter() { [native code] }constructor: function Object() { [native code] }hasOwnProperty: function hasOwnProperty() { [native code] }isPrototypeOf: function isPrototypeOf() { [native code] }propertyIsEnumerable: function propertyIsEnumerable() { [native code] }toLocaleString: function toLocaleString() { [native code] }toString: function toString() { [native code] }valueOf: function valueOf() { [native code] }get proto: function proto() { [native code] }set proto: function proto() { [native code] }

Not sure if any of that tells you anything.

Just threw you two new pull requests, one for the webapp and the other for the firmware. If the webIDE barks about the new #include "application.h" line just remote that line

Thanks! It’s working!

Now I’ve got a question about sleep mode to try to save some battery. I added lines 50 to 53 in the code here:

I’m trying to set it to go into deep sleep at 11:00PM Central time and wake at 7:30AM. Did I get the code correct? Place it in the correct position?

Also, I think I’d like to add capacitors as recommended above. I’d like to use two of these in series: https://www.sparkfun.com/products/10068
So I would connect one capacitor’s + to the VIN, and the second capacitor’s - to the GND, then connect the remaining legs?

Thanks again for your help.

Looks great. Shot you another pull request, a tiny one, for syncing time at setup()

The cap’s should work. My only reservation with those is I’m worried they might “short out” the 12 to 5v adapter when initially connected. Those things have some serious capacitance and will take a decent amount of time to “fill up”. I’m not entirely sure what will happen when they are exposed to 5v but are only at say, 4 volts. They would charge but perhaps they would consume too much current. Not sure. Paging @BDub or @peekay123 perhaps? Could you all chime in?

I’m having trouble getting the code to compile with your additional time sync.

The error is below:

In file included from ../inc/spark_wiring.h:29:0,
from ../inc/application.h:29,
from remotecontrol.cpp:1:
../../core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning "Defaulting to Release Build" [-Wcpp]
#warning "Defaulting to Release Build"
^
remotecontrol.cpp: In function 'void setup()':
remotecontrol.cpp:49:5: error: 'lastSync' was not declared in this scope
digitalWrite(pinStart, HIGH); 
^
make: *** [remotecontrol.o] Error 1

Error: Could not compile. Please review your code.

I don’t see any current specs for those caps, but you can probably be safe with 1A. This circuit will act as a bulk charge current limiter. I would also use 3 of those 2.5V caps in series to give yourself some headroom. The LM317 will drop about 2.5V across it, which is why it’s placed in series with the 12V input.

I’m just a bit worried the SparkCore will “brown out” while the caps are charging initially given their low ESR. The charge time on those things is on the order of 10s of seconds if I remember

See latest pull request. My bad

Thanks, it’s all working again. Except my deep sleep isn’t happening. It should have slept at 5 UST (11:00PM CST last night), but didn’t. I tried to make it sleep today at 14 UST (8:00AM CST) and again it didn’t sleep. Do I have my code for checking the time and putting the Core to sleep correct?

/* This function loops forever --------------------------------------------*/
void loop()
{
    //Go to sleep at 11:00PM CST till 6:30AM
    if(Serial.print(Time.hour()) == 5)
    {
        Spark.sleep(SLEEP_MODE_DEEP,27000);
    }
    if(pressUnlock == true)

Looks like I’m going to have to do some researching on the LM317 and how to get the 12V connected to it and the 12V to 5V adaptation.

Try creating a simple sketch which:

In the loop:

  • sets the RGB LED to ORANGE (or some other color), just used to indicate that it’s running
  • delay for 1 or 2 seconds
  • deep sleep for 1 minute

And flash that. You should see it turn orange, stay orange for 1 to 2 seconds, and then go to sleep and repeat. Time the 1 minute sleep to determine how long it actually sleeps. If your bootloader is old (very possible) it will only sleep briefly and that’s what I’m testing for.