-
If your phone is rooted, and you have installed Tasker, (and understood its' complexities) then I would think what you want to achieve might be possible. Bluetooth Tasker Wiki search - might lead to some recipes, or maybe onto other clues.
-
Thanks for your considered thoughts Gordon.
Yeah, finally worked out for myself that the HC-05s get through a lot of current, and the general lack of quality documentation (and discussion on StackOverflow) concerning the whole myriad of settings around their SNIFF settings left me flummoxed. Plus, classic BT is not really getting me the transmission distance I'd like.
Anyhow, for anyone in the same boat I figured my options at that point included:
de-soldering the HC-05 from that awfully useful Serial1 "pad" on the Espruino and maybe wiring the power through a MOSFET too (I'm still in "Wow MOSFETs are cool" mode).
Ordering some HM-10s, but essentially that would still need the same ability to turn on/off
Using the beacon idea
n00b101 moment : A major light bulb (well, LED I suppose) moment for me came when I finally understood DeepSleep. Just because the setSleepIndicator LED occasionally flickers does not mean the sum of all the kit welded to your Espruino is only using 0.04mah when asleep! Wire your multimeter in line with your battery early on, and assume nothing.
As it happens I had some old Xbee units from a few years ago when I first started tinkering, so have spent the last few days in Xbee Javascript Hex data-packet hell, but now ready to put all this back together and test if I can power that up/down at will.
Learning about Xbees might be a dead end, I realise, but it reminds me very much of s/w dev when I was learning Design Patterns. Reading about concepts is one thing, putting them into practice is entirely different - and is the only way (at least for myself) I can hammer the facts/issues into my brain so they stay learned.
Xbees make the whole solution rather expensive, but if I have something that works it will be good, I can then start swapping components and ideas.
Ultimately, BTLE and beacons is the way to for now. Anyone else thinking of going to Nordics BTLE dev day in Copenhagen?
-
Update on this. After many distractions, hw fails and quite a bit of effort my long life GPS logger is largely working as I wanted. Thanks for the help.
I ended up using a MOSFET to switch power to the GPS, new knowledge and a new ability for me (and some more ugly soldering, sigh). I'm keeping it simple and logging to SD. I stuck with the HC-05 and this is working decently. The learning curve concerning the switching from USB to Serial1 console was steeper than I thought, but have now finally grokked that. I'm using Blueterm to query the unit at set times. (Blueterm+ does not have an output save option).
I am doing some more tests now and I will post back how long I expect it to last on which sized battery, pseudo code :
wake up every hour, on the hour
if h hour is a match, turn on gps, log data,
if h hour is a match, turn on Serial1 and listen for instructions for m minutes
go back to deep sleepHowever, as I work though this project it has become clear to me (as I am horizon watching all the time) that instead of me having to physically be next to the device to download the captured data over BT at a very exact set time which may not be convenient, I could use a beacon to detect my phone is in range, and they wake up the device and switch Serial1 on for m minutes.
Now I've ordered some Pucks like a good-un but I think they'd be overkill for this . I wondered if anyone could give me a pointer on whether there are any basic cheap beacons I could use for this, and if they've had any luck getting a beacon to send enough power to signal to Espruino to wake out of Deep Sleep? Is this even doable?
This would make things far more convenient.
-
I see your point. Yes, the Daylight Saving (DST) would be a pain -- I even wonder if that would be worth the bother. As my device returns to base or gets in BT range I was going to reset the time as the argument in that func applies negative figures.
I suppose as more devices are made wifi or LoRa capable then this need would diminish anyhow.
Brilliant piece of kit all the same.
-
My IDE is set to transfer my computer time to my Espruino (Settings/Communications/Set Current Time), as long as I have a battery installed at the same time, I can unhook USB and continue with Serial1 on Bluetooth (HC-05).
The problem is the time transferred is GMT without TZs or Summer Time adjustments.
This leaves a 2 hour gap in my case. i.e. My computer tells me it is 15:00 hrs, but 13:00 hrs gets transferred to my Espruino. Now, maybe there is something in the guts of my computer I can change, but I doubt it.
So I made this for now, posting it here in case anyone else is searching for a work-around.
function addMins(mins) { newTime = getTime() + (mins * 60); setTime(newTime); // if(dbg) {date = new Date(); console.log(date.toString());} }
As I cannot believe that I am the only one who wants (almost) correct time sync with their devices I will ask : Any chance the IDE Set Current Time setting can have a GMT +/- hour diff option? OR maybe I have missed something?
-
I don't normally chime in on this forum because I am such an ee n00b too, but I remember being a s/w n00b and I too share your enthusiasm and excitement.
If you don't have one, get a multimeter. Find out how to do a "continuity test". I'm from a s/w background and I think of this part of the tool as the equivalent of the basics of Unit Testing.
Does pin x really connect to pin y of my sensor? Prove it. Buzzzz... yep.
I admit I am quite interested how other s/w disciplines/patterns relate to ee, all I have so far is that and:
Blinking LED = "Hello World"
So no, not a terribly long list, not even sure how true this comparison rings, but its helping me until I find a better paradigm.
I think buying a soldering iron is the equivalent of learning to touch-type for a programmer. It might be an expensive outlay (cash as apposed to time) but you will use it elsewhere, a skill for life. My wife is amazed at the things I can now "repair".
-
Espruino 1.4 flash v1.86 / 262144 I have the Serial over BT working fine, my question is when my board is deployed, how can I fine tune the system clock?
I think I understand I can send the exact time when I send my code over to the board by clicking the correct IDE setting, and could add hours on to adjust for daylight saving or TZs etc.
My concern is if the battery is changed/disconnected how would I go about sending the correct time and date to the system over BT?
I read about Clock but I have doubts that this var eg clk is just that, a var I keep persisting, or does it indeed update the system clock?
var Clock = require("clock").Clock; var clk=new Clock(2016,4,15,23,45,0,0); // Initialise with specific date
-
When I am just testing out an idea for a circuit, I want to be able to create a temporary connection without soldering/de-soldering my Espruino boards - is a pogo pin the correct method to use? If so, is there any you can recommend, if not, what do you use?
Inspired by what I read today over at Hackaday "ViaConnect" diy pins.
-
Thanks, I never tried a state machine in JS (knowingly) I will break the code out into doing that if I can. I've used FSMs before, and can lead to much cleaner code. The more I think about this the more exceptions I will have to cater for.
you switch the GPS off and do the rest of the work.
This is my immediate stumbling block, do I do that by somehow disconnecting Serial4, by turning a control pin to 0, or ... tell 'gps' it is null? What is the correct method to power it down?
A GPS gets much faster on the road when you can tell it something
I had not thought of that at all, nice.
I quickly read through the NMEA spec previously, so I realise I could just extract the things I actually need for this project, but I'm happy enough the existing GPS.js spews out figures. I mean I am still (maybe stuck?) in that ridiculous/happy/delirious stage of "**** me, it works!".
I've combed my way up and down the docs, but cannot for the life of me see the correct way to turn a component off.
-
OK, I have returned to this project finally.
The GPS unit (ublox Neo-6m-0-001) works fine, takes about a minute before it gets a "fix".
Got BT working, so I can read the SD card remotely.
The problem I am having now is understanding how to turn off the GPS unit, I mean it needs to be powered off for 4 hours until its next wake up call. I am guessing that cold starting the GPS will consume far less power than keeping it powered on (warm?).
This is inside a setInterval() loop - I was thinking of setting a flag to break myself out of the setInterval() loop, but now am doubting that is the correct way to think about this.
bGotFix = 0; var gps = require("GPS").connect(Serial4, function(data){ if(data.fix == 1) { // todo this will be logged to sd card console.log(data.time, data,lat, data.lon); bGotFix = 1; } else { // debug console.log('no fix yet'); } });
Traditionally I'd check data.fix is true, stop the interval code, but how to turn off the GPS? Or do I need to?
-
Thanks both for the encouraging replies. I was thinking of only waking up the BT once a day, after one of those 6 hour logging periods probably - for about 5 minutes - if I make contact then do the necessary and then let everything go to sleep again.
I believe that some of the SD cards don't draw much power at all. It'd
be a matter of testing, but I imagine that if you found a small
capacity card (64MB, if they still make them?) power consumption would
be pretty good.Right, so using a smaller SD card would result in less complexity but possibly slightly more power usage, but heck, at four writes per day this could well be negligible. I will try this first, I think I jumped at the idea of eeprom because it is something I know little about.
I was wondering why you made that comment about smaller SD cards and found this discussion (Arduino forum ftw). New knowledge, thanks.
I know Espruino is great for this kind of extended battery project, so I am looking forward to extending my skills and knowledge.
-
I'm not sure if this forum is for showing off completed projects, or the discussion of problems associated with current projects, so if I am polluting this forum please let me know and I will move this, or split it into discrete isssues.
I have a project to create a low battery consuming GPS logger that I would like to be able to periodically query over the air using bluetooth, I have most of the kit already and have ordered the GPS unit shown in the tutorials. I want the unit to be as small as possible but I am initially planning to use an Espruino 1.4.
However I have a couple of nagging queries about my approach.
I calculated that to log for 100 days I would need to log 15.5k of data, timestamp and gps coords every 6 hours. e.g.
2016-05-01 12:00:00,1.234567,-1.234567
2016-05-01 18:00:00,1.234567,-1.234567
2016-05-01 24:00:00,1.234567,-1.234567
2016-05-02 04:00:00,1.234567,-1.234567I initially thought of logging to SD card, but after some reading I think for the sake of conserving battery, and reliability I think using eeprom could be better.
Q1. Is that a reasonable approach?
To access the data when nearby with BT I wanted to use the modules I have, HC-05
Q2. As that link shows, its a simple matter of soldering that to the prototype area of the Espruino, but how/where would I then attach an eeprom? This discussions I have seen mention soldering the eeprom to the prototype area too, you see?Q3. Assuming that is all physically do-able, could I then command, via BT the reading of the eeprom, and if successful, the deletion of the eeprom to empty it? (I am guessing these would be js functions/classes I'd call over BT)
Oh, and being able to understand remaining battery life would be a bonus too...
I haven't used BT or eeprom ever before, but I look forward to tackling these issues one by one myself, honestly I just wanted a heads-up on my general approach, and maybe a couple of potholes that I'd face.
Thanks.
-
Thanks for the ideas and discussion. I am certainly no electronics engineer but it gives me an idea.
Maybe I could just find the smallest LIPO possible (like this 20mah, retired) and see how long before it gives up.
Neither appreciating, nor understanding how the different battery types discharge, I could at least compare LIPO to LIPO, and as a bonus I could stick it in the freezer to see how it copes in low temperatures. I'd be opening and closing the fridge door every hour to check it.
I say this mindful that if I am going to get serious about this iot stuff, an Oscilloscope will be the right way to go.
-
Hi,
I have a simple project in which my Espruino wakes up every 2 seconds and takes a reading from a magnetometer, if the conditions are right, it wakes up an nfr2401 radio and sends a signal.
All OK and is very good, but I am trying to estimate how long a LIPO battery will last.
I put my multimeter into the correct mode, and put it in-line (?) (measure current ftw) between the LIPO and the Espruino, and fair enough I can see the numbers change as the current surges when the reading is taken and the radio is required to TX, i.e. from almost nothing to a jump then back down again in a blur.
What is the name of the equipment I would need to monitor and log this usage properly, say over a 5 minute period? (some expensive piece of kit no doubt)
What is the poor man's version of that?
I imagine this must be a common practice, how do you set up your workbench to monitor current use as you work?
Thanks!
-
No I did not know that, I will look further into it.
Third stage prototype will involve 2 units one to sensor and transmit (Pico), the other to receive and log.
I really wanted to cut my teeth on straight Espruino standard boards first. Looking at both BT and RF units right next. Your site has some really good info on fixing these in, I like the videos.
-
Yup, that scalpel cut did it. Nice to know how to reuse or re-purpose reset button too.
Me searching for RST instead of 'reset' might have yielded the find.
Thanks for the nice fast reply and saving me from the very nasty alternative I was dreaming up involving hot-glue and an old led cover.
My comments re RTC were because I can see them removing the battery too, sticking a charger in the project should negate that. Reset maintains clock, good to know.
Cheers
-
I've searched everywhere and cannot find a solution to this.
I have someone in the real world testing an Espruino with a sensor and logging. Its only a second stage prototype and at this stage I don't want to add an RTC, so the time is hard coded as the prog is save()d when init is run.
I have programmed BTN1 to allow them to unmountSD, but am scared that they will press reset, and send the time back to the hard-coded one I just mentioned.
I thought I'd found the answer on this thread with
var reset=0;
but it does not work.How can I disable, or redirect a button press on the Reset button?
I read this on the Adafruit description :
Solder jumped so you can turn the reset button into a second general
purpose buttonBut am unsure how to do that. It seems a bit drastic, but I will do/undo it if necessary.
Thanks for any ideas - loving my Espruinos by the way, great project.
Espruino 1.4 with 1v81.
-
The reason I piped up was one of the most useful Tasker recipes I found was "disable wifi if out of range of either home wifi or office wifi". Given the plethora of MITM (Man in the middle) attacks and access point spoofing, this stuck in my mind. I am guessing its the same with Tasker and Bluetooth. "When x happens send SMS" features quite a lot on Tasker, so I'd be surprised if you couldn't make a call.