-
• #2
Looks good, it'll be fun to see your progress!
@Sacha has been posting on http://forum.espruino.com/conversations/271316/ recently, and it got me thinking... Maybe you don't need the SD card?
Despite being marked as a 384kB part, Pico actually has 512kB of flash. That means there's a whole 128kB of flash left over at the end. With 8kHz audio that's still 16 seconds worth, which might do you?
-
• #3
Hi there !
[Also, see last post on Esptruino SD card]
Yup, it's getting somewhere, but the "OUT OF MEMORY" messages from the audio part is sometimes driving me crazy ;p
-> For +Sacha's posts about the Pico flash stuff, this is truly great, and as you say it could be pretty interesting for my needs ..
.. now, what could be totally worth it 'd be being able to read a file from the SD to the free flash, ( maybe using a littl' buffer but not consuming all of Espruino's memory ) & then play it "directly" from the flash ? => aka use the flash's stuff as Waveform buffer ?
My point is: while I'm testing playing random audio files off the SD, I have two "issues"
1: can't usew.on("finish", function(buf) { .. });
when using 'readFile()' ? ( it doesn't seem triggered .. )2: "OUT OF MEMORY" error -> may be overcome by using said-"double-buffer" ?
-> the code throwing the said "OUT OF MEMORY" error is the one attached ( used for testing the audio files )-> I'll be testing the code that triggers the ground floor door's optotriac in few minutes, & then the two last steps be mixing it with the morse-like patterns matching code & finalizing the schematic part with the added RC timing circuit ( .. )
-> right after checking the optotriac's code, I'll give few tries to the buffered audio, and if I got time in the evening, I'll be digging what can be done to easily play audio from the flash ( .. )
=> Nb: what could be done, if nothing else could allow bypassing that "OUT OF MEMORY" error,is just: on code match => select appropriate random audio/load it/play it/open door/reboot ( via "save()" )
-> since rebooting the device is quite quick, it is not that cumbersome to reboot after each door lock ( nb: also, if I don't add the RC circuit, the Espruino 'll be powered off then on whener the ground floor door is opened, but in other situations, this is not considered a "feature" ;p )
1 Attachment
-
• #4
How big are the sound files you're playing? One thing that won't help is:
myPico.wave = require("fs").readFile( myPico.filename ); myPico.waveform = new Waveform(myPico.wave.length); myPico.waveform.buffer.set(myPico.wave);
try:
myPico.waveform = undefined; // get rid of old waveform var wave = require("fs").readFile( myPico.filename ); myPico.waveform = new Waveform(wave.length); myPico.waveform.buffer.set(wave);
As it was, you had 2 copies of the waveform kicking around (the string, and waveform.buffer). Also when you then went to load another waveform, you still had the first 2 in memory, so you ended up with 3 copies of the Waveform, all in RAM at the same time :)
Another thing you could do is actually to read the waveform into waveform.buffer a bit at a time, so you're not needing double the size of the waveform just to load it.
... and yes, you could potentially copy from an SD card to flash, which would be nice and easy - but if you've gone to all the trouble of wiring up an SD card then it's probably just worth using that to store all your data :)
-
• #5
aha, thanks for the quick answer: I've been looking for that
= undefined
( I've been wondering how to release the file read using "readFile()" & the associated memory , but had no.close()
function, and I didn't digg .. I must have skipped that part while reading the Waveform page :/ ..)btw, anyway to call
.onfinish = fcn
if playing audio as above ? I couldn't get it to work when I briefly tried while after finding about itFor the "read waveform into waveform.buffer a bit at a time", It's a nifty idea, I'll test that after concluding the above tests ( code should be close to the double-buff example I guess )
For the SD->flash stuff, it was mainly needed as I wasn't aware of using
= undefined
to release stuff from mem, but playing audio stuff from the flash directly is still quite nice indeed ;).. onto test(s) ..
-
• #6
The finish stuff seems to work for me? I just tried this:
var BUZZER = B4; var s = atob("f4GBgoODh5GtnmgkE1m435g/MobgzYJbd41YHkHD/7UoEZPysyscl/K5PSqLy5tLToqdfHGdrXI1V7vUeiVIqceEUG2kmWVfj6qIWFuKpZFpXXiXknNthZB9cH6LgG5vgJKSdWF7oZVoXHuRioJ8c3iJjHtweomLf3JygpCHdHOCiYJ8fYCBg4ODgn53d4CGiIZ8cHGAjo1+dn6Jh3pzeoWHfXd8hYd8d3+Gg3t1e4F9d36KiHp0fYZ+cneLlol3cnyEgXt8g4WBeXV8hoqDdnOCjoNxc4aRhnd3f4J6cXmNlIJxd4mKeXJ5iI2Denh9fX1/f4B/g4N2bnuSlYJzdoOIgXp7g4V+dnmDhoF9gIF+eHqDioJyb3+Oi3xzeIOHgXp7gIB+fH+DgHt8hIh/cnOEjoVzb32Mi3pxeYeLf3N2hIqBdXaBhoB7fYSGfXZ7hYeAeXl9goJ9e36BgYGCgoF8e4GDgHp6f4ODgHo="); var w = new Waveform(s.length); w.buffer.set(s); analogWrite(BUZZER, 0.5, {freq:20000}); w.on('finish', function() { print("Finished!"); }); w.startOutput(BUZZER,2000);
And it prints
Finished!
when done. There shouldn't be any difference between that and loading from a file though, as the Waveform is exactly the same.I'm afraid it's not possible to play directly from flash, but you could use double-buffering and read it in chunks very easily.
-
• #7
allright, the random audio now works flawlessly ;)
and as a bonus, I also got random audio playing callbacks (playInLoop()
) ;)'ll be back after other test-implm ( .. )
1 Attachment
-
• #8
ok, little issue with the optotriac circuit: it turns on ok but doesn't turn off,even with a 10k pulldown resistor on its LED in pin :|
the code has been simplified & can be used as a very crude audio looper ;) (nb: not eyt using what you suggested, aka bit-by-bit buffer fillin' ( .. ) )
Now onto testing the "Single Button Combination Multicodes Lock" on the Pico, and then mixing it with the rest of the code & connecting it to the intercom for some further "remote" testing ;p
+Gordon: for the finish stuff part, nevermind, silly error no my side & I thought I had removed it from my post ( the updated/cleaned code make uses of it for recursive callbacks )
-> now, I wanna know what's that tune you took as an example ^^
1 Attachment
-
• #9
Are you using the optotriac for AC or DC? Triacs don't turn off on DC, they only turn off when the voltage they're switching goes to 0. It makes them great for switching AC because there's very little noise though.
-
• #10
hello again :)
I'm using the optotriac with a bipolar junction transistor BT138 to short the "AP" 12V to Gnd, which triggers the ground floor door opening
-> I'm going to try again with a 10k on the BT138 pin that's controlled by the optotriac to see how it goes
-> also, I'm currently using an LED runnig from a 3V cell battery to simulate the "AP" being shorted to Gnd, so not quite the same setup than for my actual/final usageOn the code side, I edited the code hosted at SingleButtonCombinationMulticodesLock_Espruino.js, but it seems something's weird with the timeouts ( in addition to jslint's
!== 0
advices ) ?
-> the weirdest part being the same code works flawlessly when running from a webpage ?!=> if you had any hint on this, we could have it all ( aka clean working code .. to update the Espruino "SINGLE BUTTON COMBINATION LOCK" page with ;P )
( code that has issue with timeouts as attached file )
1 Attachment
-
• #11
Also, here's the circuit implm of the optotriac part, and the 2nd pic is something I just received which could be part of neat nex step(s) ;P
Also, here's the circuit ( can be found at yet-another-intercom-hack )
2 Attachments
-
• #12
I'm not sure what you mean about the
setTimeout
s? I just copied and pasted it into the Web IDE and it seems to work fine.The warnings about
!=0
are just good practice as you can get caught out otherwise. For instancefalse != 0
is actuallyfalse
... -
• #13
yes, it SEEMS to work fine, but when entering "codes", the "inactivity timeout" throw an error, and so does the "shortestmatch timeout"
Did you logs pass well without errors when you tried ? ( or maybe you just copied/pasted to check the code evaluation? )
thanks ;p
shortest code match found ! 1 2 Uncaught Error: Unknown Timeout at line 7 col 61 ...imeout(shortestMatchTimeout); ^ in function "onPress" called from line 5 col 28 if(timeDiff>0.1) onPress(); ^ in function called from system 3 Uncaught Error: Unknown Timeout at line 5 col 35 if(timeout) clearTimeout(timeout); ^ in function "onPress" called from line 5 col 28 if(timeDiff>0.1) onPress(); ^ in function called from system 4 Uncaught Error: Unknown Timeout at line 5 col 35 if(timeout) clearTimeout(timeout); ^ in function "onPress" called from line 5 col 28 if(timeDiff>0.1) onPress(); ^ in function called from system
-
• #14
Yes, I'm afraid I just copied and pasted - I didn't set up a button to check.
Unknown Timeout
usually occurs when you callclearTimeout
on a timer that's already fired or been deleted.I think your problem is:
if(timeout) clearTimeout(timeout);
It should be:
if(timeout) { clearTimeout(timeout); timeout = undefined; }
because if it gets called twice the way it was before, it'll delete the timer that has previously been deleted.
-
• #15
Back !
Haha, thanks, I get it now ^^ !
-> I didn't bother setting them to undefined as it worked on the browser ( & I naïvely though it 'd do the same "as is" on the Pico ), but after re-reading the original code, you DO indeed set the (unique ) timeout to
undefined
;)function onTimeout() { timeout = undefined; // check against our code // ( .. )
For the different behavior ( read "different handling of supposed-implicit-undefined stuff") on the browser, IYO does it means/implies that browsers evaluates the js code in a quite-similar-yet-different manner ?
Since the code worked flawlessly on the browser, I don't see many other possible reason(s) ? :|=> I'll update the code hosted on the repo & flash that to my Pico to check it out* :D
Also, "last but not least", I received the SIM800L module I ordered, tested it quickly with
.. BUT ! -> it seems that I can't use the "AT" module on the Pico ? When I tried quickly before having a nap, I ended up having the following logs:
var at = require("AT").connect(Serial2)
ERROR: Unable to mount SD card : NOT_READY
WARNING: Module "AT" not found
Uncaught Error: Field or method "connect" does not already exist, and can't create it on undefined
at line 1 col 23Same error when trying to use the following
var gprs = require('SIM900')
```Concerning the "ERROR: Unable to mount SD card : NOT_READY", I guess it's because Espruino tries to look for a connected SD card which may contain the module that's being loaded, but no idea why I wouldn't have the above modules
-> I see 2 possible solutions here, either DL the module & host it on the SD, or pass a remote url to therequire()
call, but wouldn't simply updating the Pico's firmware do the trick ?
( I don't know how recent is the implm of the AT/SIM900 stuff ;| )Also, concerning the SIM800L module, I don't know if it had enough power to work correctly when powered from the Pico +5V through a 1N4007 diode ( voltage required is 3.7<->4.2V ): it worked correctly using that setup when connected to a laptop, but with the Pico setup I have already an SD card to power, hence my question: did you have this type of issue when having fun with the SIM900 ? :)
- with a wire .. and with the intercom ringer ;p
The attached images are posted as an update to the project.
The repo containing stuff for the SIM800L is the following SIM800L
The other repos stays where theybelongare & 'll be updated
2 Attachments
- with a wire .. and with the intercom ringer ;p
-
• #16
Concerning the "ERROR: Unable to mount SD card : NOT_READY", I guess it's because Espruino tries to look for a connected SD card which may contain the module that's being loaded
Yes... but that only happens if the Web IDE hasn't uploaded the correct stuff.
Did you just paste code into the left-hand side? When you use modules you need to use the right-hand side, so the Web IDE can properly scan your code and load up the modules you're using.
If you want to use the left hand side, just put
require("AT")
in the right-hand side and upload, and then you can do whatever you want on the left. -
• #17
I updated the code hosted on the repo by a working one ( although I needed to add more
=undefined
than expected( .. ) ), and also added a link to send it directly to the Espruino web ide ;p-> on this: do you plan on adding another 'API-like' handling for weblinks to the Espruino ide ?
=> aka, stg likehttp://www.espruino.com/webide?codefile=<..>
additionally tohttp://www.espruino.com/webide?code=
, to be able to just pass the url of a file hosted on github, for ex ?For the above, you're right: I was tired & didn't recall one of the differences between left & right pane .. sorry for that :/
For the SIM800L stuff, as I get no troubles loading either the AT or SIM900 module(s), it may seem the SIM800L module isn't getting enough power ( I just did a loopback test beteen A3 & A2 to check if they were ok & they are, while I only have two brief pulses of the LED on the SIM800L module )
After digging the above & adding some basic code for SMS/CALL handling, all that's left to be done is finishing the circuit(s) & the project 'll be pretty much wrapped up :D
-> I'll continue diggin that tomorrow, hoping to have that baked in the evening ;p
See ya +
-
• #18
Nice idea! That should be pretty easy to add.
I'd be cool to have a button that said
Load this into Espruino
on your GitHub projects :) -
• #19
hello ;)
I digged a little in the Web ide source code , & added a quick update to "urlHandler.js" to have these
Load this into Espruino
buttonsSupport is added to handle "http://www.espruino.com/webide?codefile=" URLs, which seems cleaner that using the same "http://www.espruino.com/webide?code=" URL & looking for some 'http..' prefix ( I had to choose, but we could also have both a 'general' URL handler & 'dedicated' ones as well ? ( .. ) )
=> Now we can have that Cake ! :D
Send stuff to Espruino !Also, I got no luck with my tests with the SIM800L:
If I use the following code in the right pane of the web IDE, I can get a correct output .. which shows an error:Serial2.setup(115200, { rx: A3, tx : A2 }); Serial2.on('data', function(d) { USB.write(d); }); // log stuff received from SIM800L to web ide console USB.on('data', function(d) { Serial2.write(d); });
ouputs the following, when I short then release RST to Gnd:
F1: 5004 0000 F8: 380C 0000 F9: 4800 000B F9: 4800 000B F9: 4800 000B F9: 4800 000B 00: 102C 0004 01: 1005 0000 U0: 0000 0001 [0000] T0: 0000 00C3 Boot failed, reset ...
So, 'yay!' -> some output is better than no output, but I can't investigate/test AT commands if the module can't boot properly ..
What's weird, though, is that I had the same error when no providing enough power to the module, which was solved using +5V & a 1N4007 diode, but here I get the same faulty output either powering the module from Espruino's +5V through diode or another USB port + separate +5V ??!The LED either pulses twice when getting power from the Pico's +5V or 8 times when getting external power, but either way, always faulty output :(
-> I'll try diggin google to find more on this, but if you have any though/doc part I'd be interested in, feel free, you're more than welcomed ;pLast but not least, I made a commit for the said update of the web IDE -> can't wait to use it ;p
+
-
• #20
Hey, thanks! I'll merge it in.
I'm not sure what to suggest about the module - I think it's going to need a google I'm afraid.
Also, for the last line of:
Serial2.setup(115200, { rx: A3, tx : A2 }); Serial2.on('data', function(d) { USB.write(d); }); USB.on('data', function(d) { Serial2.write(d); });
to work, you need to move the Espruino interactive console off of USB with
LoopbackA.setConsole()
(or maybe Serial1?) -
• #21
Hi there !
-> haha, you're welcome, [ happy to contribute .. and can't wait to use it ! ;P ]
On the SIM800L subject, I got few stuff worked out ..
First of all, as I luckily had another Pico , I tried with it on Serial1 & B4 for the RST pin of the SIM800L module ..
.. and it seems to work, after some checks, and ALWAYS after resetting the module after connecting it to the Pico ( in other words, after whenever powering on the Pico ).
This may make sense / have stuff to do with the auto-bauder set by default on the module ? ( .. )
Also, the said-tests were done while getting power from a cheap USB<->FTDI adapter ( which was previously used to debug the module using 'screen' )Concerning the LED blinking of the module:
- it shall blink 8 times & then wait & loop when the module is booting/trying to connect
- it shall blink once every 3 seconds when the module has booted & is connected
In other words, only 2 blinks when powering it up seems to indicate not enough power [ or another error / faulty sutff .. ]
I'll try other tests while powering the SIM800L module from the Pico's +5V through a diode & see if it works flawlessly, and then back on the "original" Pico to check that out too ( the only "major" differences being the use of Serial2 instead of Serial1 & the presence of the SD card, but not on the same pins ).
Now, while I could quickly write a module to wrap useful AT cmds, there's one thing that I'm sure I can do better: parsing response from said-AT cmd:
For unknown reasons [ spoiler alert: that may be obvious ones .. ], I can't get up to the content of a message retrieved simply using an 'at.cmd()' call like the following(s)/* should the following work ? it never gets to the content of a SMS :/ .. */ at.cmd("AT+CMGR=1\r\n", 1000, function(d) { if (d===undefined) ; // we timed out! // d is now the result console.log('AT+CMGR=1 result: ' + d); }); /* I tried stg inspired from the following example */ // example at.cmd("AT+CMGR=1\r\n", 1000, function cb(d) { if (d===undefined) ; // we timed out! // d is now the result if ( still_waiting_for_more_infos ) return cb; // can 'still_waiting_for_more_infos' be any of the following ? else console.log('AT+CMGR=1 result: ' + d); }); // try 1 at.cmd("AT+CMGR=1\r\n", 1000, function cb(d) { if (d===undefined) ; // we timed out! // d is now the result if ( at.isBusy() ) return cb; else console.log('AT+CMGR=1 result: ' + d); }); // try 2 at.cmd("AT+CMGR=1\r\n", 1000, function cb(d) { if (d===undefined) ; // we timed out! // d is now the result if ( Serial1.available() !== 0 ) return cb; else console.log('AT+CMGR=1 result: ' + d); });
My current "solution", which is pretty hacky & not-clean-at-all ( even more if I can't set back the 'data' listeners that were there in the first place ( .. ) ), is the following one:
var buff = ""; Serial1.on('data', function(d) { buff+=d; }); at.write('AT+CMGR=1\r\n'); Serial1.removeAllListeners('data'); // buff seems to contain everything
Any hint on a simpler & cleaner handling of data returned through at.cmd() ?
-> It's pretty much all I need to complete the following ;)
SIM800L_moduleTesting.js
APIbtw: I achieved being thrown at the following ;P
Uncaught Error: Maximum number of scopes exceeded
UPDATE:
After trying to get power from the Pico's +5V, now it seems stuck with the red light on & not connecting any more on USB :(
Also, before the Pico did put on his red led, this is what was received over serial:"\x00\x01Áprø¢ÿ\f\x00ø!\x10\x05\x00H\x00Àøþ\x00\f\x00\b\x00\x00\x00\x00ø\x00ð\x00\x00\x00\x00ð\x01\f´\x01à\x00\x00P\x01ð\x00\x00\x00æ\x1F@\x01ü\x00\x00@\x04F¼\x10\bÈ\x11\b\x00æxÀ@\x10\x1Eþ\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00BU\x0E\x0B\x00\x00\x00\x00\x00\x00\x00\x00\x00BU\x0E\x0B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00BU\x0E\x0B\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" <--- "\x00"
So ..
.. any advice on how to get my Pico back from the void :| ?Hoping there's no attempts on England ( or any other parts of the world, actually ),
Your hints are more than welcomeThanks +
- it shall blink 8 times & then wait & loop when the module is booting/trying to connect
-
• #22
Thanks - yes, luckily we seem ok at the moment. Not sure why as we seem to have pissed terrorists off more than most. It's awful what's happened though.
The Pico red light thing could be because there's some issue with the SIM800 and you basically ended up shorting out 5V and GND? That would cause the Pico's diode that takes USB power to fry.
To check, you could try powering Espruino externally? Connect a breadboard power supply or battery between
Bat
andGND
and see if the light goes off, and then try and connect via USB?With the AT commands, I'm not sure what the problem is? You were just getting
AT+CMGR=1
repeated back to you? If so, it's because you want to turn off echo withATE0\r\n
first... or you could work around it with:at.cmd("AT+CMGR=1\r\n", 1000, function cb(d) { if (d===undefined) ; // we timed out! // d is now the result if ( d == "AT+CMGR=1" ) return cb; else console.log('AT+CMGR=1 result: ' + d); });
-
• #23
yeah, and we still consider ourselves as "evolved" apes, but less pacific/peace-smart than our hairy cousins ..
fingers crossed bullshit 'll stop, but we both know, they ain't have a cat to pet to fully embrace peacefullness ( .. )For the "damn you SIM800L" issue, I don't know how it happened, but yeah, it seems like so -> when plugged in USB to my laptop, the red light keeps being lit.
I just did what you propose, and I could indeed see the light goes off as I was connecting to either a 3.7V 150mAh battery or a bigger 3.7V 1200mAh, and after plugging in USB, I could connect to it on /dev/ttyACM0 & try
1+2
;)'Need a confirmation for a dummy-question-of-mine, though: it's ok to have Bat+V to battery +V, Gnd to battery Gnd, and be connected to USB at the same time ( for Rx /Tx ) ?
I'm pretty new to using batteries in my projects ( yes, true story ;p ), and from what I could read, aside from other things those "3.7V 150mAh 20C batteries" seems, for example, to be most used for powering RC controlled devices motors than uCs ( the "20C" thing ? )In other words, I don't want to risk the same "shorting 5V to Gnd" using a battery this time ( ' don't want it to be damaged .. or explode :/ )
Anyway, I guess I'll have to work on this Pico with a battery by now, as I really can't replace that diode ;p
Good news is, I'll order another 1 or 2 to to have them handy [ & support ] ;)With the AT commands, everything was fine except for the text messages, as even when using
ATE0\r\n
, they're still being split ( the text content resides after all the other crap ).
Now, your workaround seems quite useful, as I could use it to partially construct an obj acrosscb
calls:var SMS = {}; at.cmd("AT+CMGR=1\r\n", 1000, function cb(d) { if (d===undefined) ; // we timed out! // d is now the result if ( d == "AT+CMGR=1" ) return cb; else if ( d.startsWith( "<infos on SMS>" ){ // populate SMS SMS.date = .. SMS.senderNum = .. return cb; } else { SMS.content = .. console.log('AT+CMGR=1 result: ' + SMS); } });
Also, is the following actually doing something or just a nonsense ? ^^
// ( .. ) if ( at.isBusy() ) return cb; // ( .. )
I'll retry the SMS stuff / updating the wip module in few hours to reflect the tries results, still having a solution to make sure the SIM800L doesn't make the battery explode / burnout Pico stuff 'd be nice to have ( this being said, I actually don't know how I could have those shorted in the 1st place .. )
thanks for the troubleshooting ;p
-
• #24
it's ok to have Bat+V to battery +V, Gnd to battery Gnd, and be connected to USB at the same time ( for Rx /Tx ) ?
Yes, that's fine - the Pico has circuitry in there to auto-switch between power sources (if you have instability you could actually remove that diode, but either way nothing will get fried :) ).
For the LiPo batteries, make sure you've got one with protection (a little PCB on the battery - most of them have this now). It restricts the power that can be drawn from the battery and makes everything a lot more safe :)
You could also use a breadboard power supply?
is the following actually doing something or just a nonsense ? ^^
// ( .. ) if ( at.isBusy() ) return cb; // ( .. )
Personally I think it's nonsense.
isBusy
will always return true if called from that callback I think. -
• #25
All right !
So I guess I'll feel safe trying with different powering setups including powering both the Pico & the SIM800L module from the 1500mAh battery ;)
( anyway, I just added headers to be able to have less short-prone connections than with aligator clips .. if that's what has happened to my Pico's USB :/ )For the little protection PCB on the batteries, I'm pretty sure it's what's underneath the orange/yellow-ish side, with connected wires & JST connector ;p
( see pic for the 2 types of batteries I'll have fun with )For the breadboard power supply part, I did see some simple one on sparkfun & Cie, but yet never took the time to purchase/build one ( I kinda "borrowed" power from whatever was handy in voltage, before starting to use voltage regulators & other niceties as I was diggin' deeper in the "electronic pandora's box" ;P )
Noted!
-> I really wondered what was thatstill_waiting_for_more_infos
^^On the thread's project status / aside stuff somewhat related:
- I tried the codeurl=.. stuff, that is soooo sweet :D
- I updated SIM800L with few examples & an API-like ref
- The schematic yaih was also updated but part of the connections to the SIM800L pins are not tested ( I'm not worried for the SPK+V out pin, more for what expects the MIC +V in pin ) - this part of the circuit is supposed to actually allow two individuals to speak over the phone<->intercom, whoever initiated the call, aka via SMS/Call --> intercom or Ring-pattern --> SMS/Call ^^ )
- any hint on sending a PDU SMS or at least a HEX/UCS2 Text SMS ? I remember having coded stuff on that a whiiiile ago on Arduino or Android but can't remember on which I had it working / where my snippets hides ! ^^ ( nb: that's a pretty good excuse to digg up some forgotten treasures ;p )
For the SMS/PDU/HEX/UCS2 part, I found this tool pretty useful: smssplit
This lead me to the following conclusion in terms of writing :)// this one's easy echo -e "\x68\x65\x6c\x6c\x6f\x20\x77\x6f\x72\x6c\x64" // so is this one .. echo -e "\x00\x68\x00\x65\x00\x6c\x00\x6c\x00\x6f\x00\x20\x00\x77\x00\x6f\x00\x72\x00\x6c\x00\x64" // .. hey, I didn't know this one ^^ echo -e "\u0068\u0065\u006c\u006c\u006f\u0020\u0077\u006f\u0072\u006c\u0064"
nb: still I don't know [yet] how to write octals in bash :| ..
// not working :/ echo -e "\357\243\277" // 'd correspond to the following echo -e "\uF8FF" echo -e "\xEF\xA3\xBF"
Hence, I wondered which was the less intensive way of doing str ->hex/unicode or unicode/hex->str ( example usage hexStuff.js )
For the pics:
3.7V 1200mAh PKCELL LP503562 & 3.7V 150mAh XRT 701723 20151022 20C
( I guess the Pico wouldn't last long with the tiniest one if it ever powers up, but I intend to do tests with an ESP8266, why not flashed with Espruino ;p )Have a nice day +
2 Attachments
- I tried the codeurl=.. stuff, that is soooo sweet :D
Hi everyone !
The following thread is about hacking an intercom .. using an Espruino Pico
( aka "yet another iteration on the Intercom Hacks for the HaD readers .. ;p )
Simplest functionality planned:
Further mods:
Now, this project is huge wip, considering the code parts are yet-to-be-merged, and that the actual circuit is being tested with various components ( if can do, less bulky ones, ex: replacements for the current relay .. )
The project can be tought as three main parts:
1: morse-like codes/patterns matching:
Handling this was quite easy, since the code needed for that had been provided in the "SINGLE BUTTON COMBINATION LOCK" tutorial ( Single Button Combination Lock ), although, the "NEXT STEPS" 'd have been controlling a relay in my case, not a lock ( no real difference at this abstraction level ;p ).
Last but not least, as I wanted to be able to handle multiple codes that could share same beginning codes/patterns while still being able to vary in length, I ended up writing my "1st next step" from the original code, behaving as exposed + handling an "inactivity timeout" ( & some more things to come maybe ? .. ), which is hosted at the following url:
Single Button Combination Multicodes Lock
2: playing audio from an SD card to the original mic line:
Thanks to studying my intercom, the other Intercom hackers notes & having nice answers from +Gordon, this part is almost done, but still needs some code cleaning/optim not to take up too much memory on the Pico
3: triggering the "AP" ( ground floor door lock ) & listening to the "CA" ( ground floor call in ):
After identifying the purpose of each wire/line, it's pretty easy to deduce how to trigger the said-"AP" ( by shorting the line which has the highest voltage present to the Gnd one ), and how to listen to the ringer/bell ( needs a cap to keep DC only & few discrete components to lower/clamp the voltage to an acceptable "digital 1", aka min 2V, max 3.3V )
Nb: if some stuff's not here [ yet ?], it may be there:
https://123d.circuits.io/circuits/1176710-yet-another-intercom-hack