The key fob on my 2002 Ford Fairlane broke and was no longer able to be used for wireless remote central locking. After dismantling the fob, it appeared that just the packaging and one of the switches was broken. I connected the switches (using a transistor for each switch) to be driven by a Particle Electron.
This is very cool. How are you calling the Particle functions?
A few constructive comments:
You don’t need to use three different Particle functions. You can easily use a central one (let’s call it “command”) that takes various arguments (“unlock”, “lock”, and “boot”)
Ideally you want Particle functions to execute as quickly as possible. To achieve this we suggest you use “flags”.
See below for an example code (untested but should give you the general gist)
Oh noes! That’s frustrating. If you are up for it I can guide you through unbricking your device. First you need to purchase something like this (search “ST-Link” on eBay or Amazon): [eBay][Amazon]
That is frustrating. The same thing happened to my solar panel powered Photon. The next thing you need to purchase is a battery protector that will disconnect the load when the battery voltage goes below a preset level. Search “battery protector” on Ebay.
My panel is charging a 12 V. gel cell. When we have a long stretch of cloudy weather, the battery protector will cleanly disconnect the Photon when the battery goes below 11.2 V and automatically reconnect it when it goes back above 12.2 V. No more dead microprocessors.
The Electron already has a fuel gauge. The issue is that there is no easy way to “hard cutoff” the battery when the voltage drops below safe levels. The lipo battery looks to already have some protection circuitry (it’s usually hidden under the yellow tape) but I guess it’s not optimized for the Electron. Ideally you’d have something that would cut the battery off at voltage X and then turn it back on at voltage X + ε where ε is just some positive value to add a bit of hysteresis.
That's exactly what the battery protector does. It has pots to select the low cutoff voltage and the reconnect voltage. I have mine set to disconnect the Photon from the 12 V gel cell when it gets down to 11.2 V. Later on when the sun returns and resumes charging the battery, it will reconnect when it gets back to 12.2 V, which is about the 50% point for gel cells.
This kills two birds with one stone. The battery is protected from deep discharging, which will kill a gel cell in short order, and the Photon is protected from its tendency to commit hari kiri when its input voltage slowly sags below 3v3.
@rickkas7 that's a great set of instructions! But I'm having a small problem implementing them. I seem to keep getting this error when I go to program the bootloader:
program /Users/Jeremy/Downloads/bootloader-electron.bin verify 0x08000000
target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
auto erase enabled
stm32x device protected
failed erasing sectors 0 to 0
embedded:startup.tcl:454: Error: ** Programming Failed **
in procedure 'program'
in procedure 'program_error' called at file "embedded:startup.tcl", line 510
at file "embedded:startup.tcl", line 454
I'm not really sure what this means as I've never gotten quite this low-level before. I've already implemented the previous command:
flash protect 0 0 0 off
So I'm not sure why it keeps saying that the stm32 device is protected. Unless I'm reading that completely wrong! Any chance you could please give me a hand? Thanks!
Device Security Bit Set
#0 : stm32f2x at 0x08000000, size 0x00100000, buswidth 0, chipwidth 0
# 0: 0x00000000 (0x4000 16kB) not protected
# 1: 0x00004000 (0x4000 16kB) not protected
# 2: 0x00008000 (0x4000 16kB) not protected
# 3: 0x0000c000 (0x4000 16kB) not protected
# 4: 0x00010000 (0x10000 64kB) not protected
# 5: 0x00020000 (0x20000 128kB) protected
# 6: 0x00040000 (0x20000 128kB) protected
# 7: 0x00060000 (0x20000 128kB) protected
# 8: 0x00080000 (0x20000 128kB) protected
# 9: 0x000a0000 (0x20000 128kB) not protected
# 10: 0x000c0000 (0x20000 128kB) not protected
# 11: 0x000e0000 (0x20000 128kB) not protected
STM32F2xx - Rev: unknown (0x2007)
I'm not exactly sure what to make of this. I can see that using 'flash protect 0 0 0 off' disables the protection to 0x00000000, but I'm not sure what the rest of it is, or what it is used for.
Additionally, after running the bootloader command, I get the same error as mentioned in previously.