-
just an info how far i am. no help required.
i think the puck crashes. i have to attach a serial console.
Puck:
var IrData = []; function setService(){ NRF.setServices({ 0xBCDE : { 0xFF01 : { /*clear buffer*/ writable : true, onWrite : function(evt) { //digitalWrite([LED3,LED2,LED1], evt.data[0]); if (evt.data[0]==255){ IrData = []; LED3.set(); setTimeout(()=>{LED3.reset();},1000); } } }, 0xFF02 : { /*fill buffer*/ writable : true, onWrite : function(evt) { var array1 = new Uint8Array(evt.data); array1.map(val=>{ IrData.push(val/10); }); } }, 0xFF03 : { /*exec buffer*/ writable : true, onWrite : function(evt) { if (evt.data[0]==255){ LED2.set(); setTimeout(()=>{LED2.reset();},1000); } //Puck.IR(IrData); } }, 0xFF04 : { /*reserved*/ writable : true, onWrite : function(evt) { console.log( new Uint8Array(evt.data)); } } } }); } setService(); function advertise() { var voltage = Math.round( NRF.getBattery() * 1000)/1000 ; voltage = voltage.toString(); var data = { 0x180F : [Puck.getBatteryPercentage()], 0x1801 : [ voltage.split('') ], 0x1809 : [Math.round(E.getTemperature()+1 /*device specific offset*/)] }; var options = { name: "Puck2", interval: 1000 }; NRF.setAdvertising(data,options); } advertise();
Node Red send IR Payload in chunks
msg.payload = [ 8.9111328125, 4.5166015625, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 1.77001953125, 0.45776367187, 1.77001953125, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 0.64086914062, 0.48828125, 0.64086914062, 0.48828125, 1.73950195312, 0.48828125, 0.64086914062, 0.48828125, 1.73950195312, 0.48828125, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 0.6103515625, 0.54931640625, 1.708984375, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 1.77001953125, 0.45776367187, 41.015625, 8.94165039062, 4.48608398437, 0.51879882812, 0.57983398437, 0.48828125, 1.77001953125, 0.51879882812, 0.57983398437, 0.54931640625, 1.708984375, 0.51879882812, 1.73950195312, 0.45776367187, 1.77001953125, 0.51879882812, 0.57983398437, 0.54931640625, 1.67846679687, 0.48828125, 0.64086914062, 0.54931640625, 0.57983398437, 0.51879882812, 0.57983398437, 0.54931640625, 0.57983398437, 0.54931640625, 0.57983398437, 0.51879882812, 1.708984375, 0.54931640625, 0.57983398437, 0.48828125, 1.73950195312 ]; var data = msg.payload; //return if no array if (!Array.isArray(data)){ msg.payload = []; return msg; } //float to byte var byteArray = data.map(i=> Math.min(Math.max( Math.round(i*10), 1), 255) ); var len = byteArray.length; var steps = Math.floor(len / 20); var outArrays = []; var i = 0; while (i < len) { outArrays.push(byteArray.slice(i, i += 20)); } outArrays.map(data=>{ msg.payload = data; node.send(msg); })
EspruinoHub
commit 97871d43d66edaefd47fb4f577008aedd82b1035
Author: Gordon Williams gw@pur3.co.uk
Date: Tue Feb 20 10:17:05 2018 +0000<MQTT> Connected <HTTPProxy> Bleno State poweredOn <HTTPProxy> Bleno.startAdvertising Success <HTTPProxy> Bleno.setServices Success <Discover> Starting scan... <Discover> Scanning started. <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF01 => "255" <Discover> Scanning stopped. <Connect> e9:05:8c:a7:64:ab: Connecting... <Connect> Connected. <Connect> e9:05:8c:a7:64:ab: Getting Service... <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF01 => "255" <Connect> e9:05:8c:a7:64:ab: found service: bcde <Connect> e9:05:8c:a7:64:ab: found characteristic: ff01 <Connect> e9:05:8c:a7:64:ab: Written. <Connect> e9:05:8c:a7:64:ab: Written. <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[89,45,5,6,5,18,5,6,5,18,5,18,5,18,5,6,5,18,5,6]" <Connect> e9:05:8c:a7:64:ab: Getting Service... <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[5,6,5,6,5,6,5,6,5,17,5,6,5,17,5,6,5,6,5,18]" <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[5,18,5,6,5,6,5,18,5,6,5,17,5,18,5,6,5,6,5,18]" <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[5,18,5,6,5,18,5,89,45,5,6,5,18,5,6,5,17,5,17,5]" <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[18,5,6,5,17,5,6,5,6,5,6,5,6,5,6,5,17,5,6,5]" <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[17,5,6,5,6,5,18,5,18,5,6,5,6,5,18,5,6,5,18,5]" <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[17,5,6,5,6,5,18,5,18,5,6,5,18,5,255,89,45,5,6,5]" <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[18,5,6,5,18,5,18,5,18,5,6,5,18,5,6,5,6,5,6,5]" <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[6,5,6,5,18,5,6,5,18,5,6,5,6,5,17,5,18,5,6,5]" <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[6,5,18,5,6,5,18,5,18,5,6,5,6,5,18,5,18,5,6,5]" <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF02 => "[18,5,3,6,1,42]" <Connect> e9:05:8c:a7:64:ab: found characteristic: ff02 <MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/FF03 => "255" <Connect> e9:05:8c:a7:64:ab: Disconnecting due to lack of use (after 10 secs) <Connect> e9:05:8c:a7:64:ab: Disconnecting. <Connect> e9:05:8c:a7:64:ab: Disconnected Wed Feb 21 2018 22:20:01 GMT+0100 (CET) 45:68:9e:41:77:b4 - ? (RSSI -58) fe9f => {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]} 69:23:86:23:8f:47 - ? (RSSI -62) fe9f => {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]} 6e:d0:2f:84:f7:06 - ? (RSSI -87) fe9f => {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]} 6f:c6:f2:d8:2a:93 - ? (RSSI -71) fe9f => {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]} googlB - ? (RSSI -83) fe9f => {"type":"Buffer","data":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]} Puck1 - Puck1 (RSSI -88) 1801 => {"type":"Buffer","data":[51,46,53,57,57]} 1809 => {"temp":19} 180f => {"battery":100} Puck2 - Puck2 (RSSI -87) 1801 => {"type":"Buffer","data":[50,46,55,52,49]} 1809 => {"temp":23} 180f => {"battery":89}
-
Hi,
i try to send some IR Codes via nodered + mqtt + puck to turn on my soundbar on chromecast activity.
msg.payload = [ 8.9111328125, 4.5166015625, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 1.77001953125, 0.45776367187, 1.77001953125, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 0.64086914062, 0.48828125, 0.64086914062, 0.48828125, 1.73950195312, 0.48828125, 0.64086914062, 0.48828125, 1.73950195312, 0.48828125, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125, 1.77001953125, 0.48828125, 0.6103515625, 0.54931640625, 1.708984375, 0.48828125, 1.77001953125, 0.45776367187, 0.64086914062, 0.48828125, 0.6103515625, 0.48828125 ];
Topic:
/ble/write/e9:05:8c:a7:64:ab/BCDE/ABCE
The Problem is that the EspruinoHub crashes after it receives the message:
<MQTT> /ble/write/e9:05:8c:a7:64:ab/BCDE/ABCE => "[8.9111328125,4.5166015625,0.48828125,0.6103515625,0.48828125,1.77001953125,0.48828125,0.6103515625,0.48828125,1.77001953125,0.48828125,1.77001953125,0.45776367187,1.77001953125,0.48828125,0.6103515625,0.48828125,1.77001953125,0.45776367187,0.64086914062,0.48828125,0.64086914062,0.48828125,0.6103515625,0.48828125,0.64086914062,0.48828125,0.64086914062,0.48828125,1.73950195312,0.48828125,0.64086914062,0.48828125,1.73950195312,0.48828125,0.64086914062,0.48828125,0.6103515625,0.48828125,1.77001953125,0.48828125,1.77001953125,0.45776367187,0.64086914062,0.48828125,0.6103515625,0.48828125,1.77001953125,0.48828125,0.6103515625,0.54931640625,1.708984375,0.48828125,1.77001953125,0.45776367187,0.64086914062,0.48828125,0.6103515625,0.48828125]" <Discover> Scanning stopped. <Connect> e9:05:8c:a7:64:ab: Connecting... <Connect> Connected. <Connect> e9:05:8c:a7:64:ab: Getting Service... <Connect> e9:05:8c:a7:64:ab: found service: bcde <Connect> e9:05:8c:a7:64:ab: found characteristic: abce /home/pi/EspruinoHub/lib/util.js:36 buf.writeUInt8(o.charCodeAt(i), i); ^ TypeError: o.charCodeAt is not a function at Object.exports.obj2buf (/home/pi/EspruinoHub/lib/util.js:36:22) at /home/pi/EspruinoHub/lib/connect.js:193:41 at /home/pi/EspruinoHub/lib/connect.js:63:9 at Service.<anonymous> (/home/pi/EspruinoHub/node_modules/noble/lib/service.js:53:7) at Object.onceWrapper (events.js:315:30) at emitOne (events.js:116:13) at Service.emit (events.js:211:7) at Noble.onCharacteristicsDiscover (/home/pi/EspruinoHub/node_modules/noble/lib/noble.js:261:13) at emitThree (events.js:136:13) at NobleBindings.emit (events.js:217:7)
If i send the hole command as a string to /ble/write/e9:05:8c:a7:64:ab/nus/nus_tx it works.
So i'm questioning what are the limitations for self defined Services?
Can i send the IR Codes that way?How "looks" the evt.data Object of the onWrite function?
How can one read that console.log as long as the puck is connected to the IDE?onWrite : function(evt) { // optional console.log("Got ", evt.data); }
Thank you very much.
-
With both of them. I already increased the
setTimeout(job, 1000);
to 2000 without success.
I will try this command later:
https://github.com/sandeepmistry/node-bluetooth-hci-socket#linux-1 -
-
The dongel has Bluetooth 4.0 and not 4.1.
https://github.com/sandeepmistry/noble#bleno-compatibility
With a Raspi 3.0 its working. -
I cant send a write command to the puck:
<Config> Config loaded <MQTT> Connecting... <HTTP> Server is listening on 1888 <MQTT> Connected <HTTPProxy> Bleno State poweredOn <HTTPProxy> Bleno.startAdvertising Success <HTTPProxy> Bleno.setServices Success <Discover> Starting scan... <Discover> Scanning started. <MQTT> /ble/write/e9:05:8c:a7:64:ab/nus/nus_tx => "digitalPulse(LED3, 1, 200);\n" <Discover> Scanning stopped. <Connect> e9:05:8c:a7:64:ab: Connecting... <Connect> e9:05:8c:a7:64:ab: Error Connecting: Error: Command Disallowed (0xc) <Discover> Scanning started.
I only found this information:
https://github.com/sandeepmistry/noble/issues/658I had a look into the EspruinoHub code and i saw that the scanning is interruptet if a write message needs to be sent.
/* Write to the given device */ exports.write = function(device, service, characteristic, data) { if (isBusy) { queue.push(function() { exports.write(device,service,characteristic,data); }); return; } isBusy = true; getConnectedDevice(device, function(err, connection) { if (err) return setNotBusy(); connection.getCharacteristic(util.uuid2noble(service), util.uuid2noble(characteristic), function(err,char) { if (err) return setNotBusy();; writeToCharacteristic(char, util.obj2buf(data), function() { log(connection.name+": Written."); setNotBusy(); }); }); }); };
and
function serviceQueue() { if (!queue.length) { if (connections.length==0) // no open connections discovery.restartScan(); return; } if (connections.length < MAX_CONNECTIONS) { var job = queue.shift(); discovery.stopScan(); setTimeout(job, 1000); } } function setNotBusy() { isBusy = false; serviceQueue(); }
Can it still be related to the dongle i use?
-
If i install the the espruino module local and not global it works:
:~/Downloads/espruino$ node node_modules/espruino/bin/espruino-cli.js Espruino Command-line Tool 0.0.36 ----------------------------------- Using first port, {"path":"/dev/ttyACM0","usb":[1155,22336],"description":"Espruino board"} Connecting to '/dev/ttyACM0' |_|_|_|___| |_| http://espruino.com 1v95 Copyright 2017 G.Williams >Connected
-
-
not working:
https://youtu.be/LK4eFga2P7E
working:
I think i will buy a new DCF receiver. i can get it to work but its not stable. not on the arduino nor on the espruino.
Code:
function wlan() { digitalWrite(B9,1); // enable on Pico Shim V2 Serial2.setup(115200, { rx: A3, tx : A2 }); var wifi = require("ESP8266WiFi_0v25").connect(Serial2, function(err) { if (err) throw err; wifi.reset(function(err) { if (err) throw err; console.log("Connecting to WiFi"); wifi.getAPs(function(err, aps) { console.log("Scanning Aps"); //console.log(aps); }); wifi.connect("XXX","XXX", function(err) { if (err){ return console.log("NO Wifi"); } var myip; wifi.getIP(function(err, ip) { myip = ip; console.log("Connected to:",myip); //printscreen(myip,13); }); var http = require("http"); http.createServer(function (req, res) { var a = url.parse(req.url, true); text1 = (a.query && a.query.t1 || ""); text2 = (a.query && a.query.t2 || ""); if (a.query && (a.query.t1 || a.query.t2)){ printscreen(text1,10); setTimeout(function(){printscreen(myip,13);},2500); } res.writeHead(200, {'Content-Type': 'text/html'}); res.write('<html><head><meta name="viewport" content="width=320"/></head><body>'); res.write('LCD Display:<input id="t1" value="'+text1+'" type="text"><br>'); res.write('LCD Display:<input id="t2" value="'+text2+'"type="text"><br>'); res.write('<input type="button" onclick="get()" value="senden"><br>'); res.write('<script> function get(){var e;window.XMLHttpRequest&&(e=new XMLHttpRequest),e.onreadystatechange=function(){4==e.readyState&&200==e.status&&console.log("done")};var t=document.getElementById("t1").value,n=document.getElementById("t2").value;e.open("GET","lcd/?t1="+t+"&t2="+n,!0),e.send()} </script>'); res.end('</body></html>'); }).listen(80); }); }); }); } function onInit(){ console.log("start"); wlan(); oled(); } var img2 = { width : 32, height : 32, bpp : 1, transparent : 0, buffer : E.toArrayBuffer(atob("AAAAAAAAeAAAf/4AH/+bAH/ABQBoAAeAaAADwHQAAf5aAfCfS/8/sUXP//1G//AdQ/wAHUAAAB1AAAAdQAAAHWAAABNgAAAeYAAAEOAAABDgAAAQ8AAAGPgAABz4AAAcfAAAnD4AP/A+B//AHz//wA///4AAP+AAABgAAAAAAAA=")) }; function image(){ //g.clear(); g.drawImage(img2, 96, 0); //g.flip(); } var g; function printscreen(line1,line2,size){ if (init !== 0){ clearTimeout(init); init=0; } g.clear(); // write some text g.setFontVector(size); g.drawString(line1,2,2); g.drawString(line2,2,20); // write to the screen g.flip(); } var init=0; var step=1; function clear(){ var p; var p1=". "; var p2=" . "; var p3=" ."; if (step==1){ p=p1; } if (step==2){ p=p2; } if (step==3){ p=p3; } step++; if (step == 4) step=1; g.clear(); g.setFontVector(14); g.drawString("waiting "+p,2,4); image(); g.flip(); init=setTimeout(clear,300); } function oled(){ digitalWrite(B4, LOW); digitalWrite(B4, HIGH); I2C2.setup({scl:B10, sda:B3}); g = require("SSD1306").connect(I2C2, clear,{ height : 32 }); } function DCF77(){ // Decode 4 bits into a number function decode4(s) { return (0|s[0])*1 + (0|s[1])*2 + (0|s[2])*4 + (0|s[3])*8; } // xor all items in s and return the result (for parity checks) function xor(s) { var r = 0; for (var i=0;i<s.length;i++) r^=s[i]; return r; } // decode the DCF77 time transmission function decode(d, callback) { if (xor(d.substr(21,7))!=d[28]) return callback("Bad minutes"); var minute = decode4(d.substr(21,4)) + decode4(d.substr(25,3))*10; if (xor(d.substr(29,6))!=d[35]) return callback("Bad hours"); var hour = decode4(d.substr(29,4)) + decode4(d.substr(33,2))*10; if (xor(d.substr(36,22))!=d[58]) return callback("Bad date"); var day = decode4(d.substr(36,4)) + decode4(d.substr(40,2))*10; var doy = decode4(d.substr(42,3)); var month = decode4(d.substr(45,4)) + decode4(d.substr(49,1))*10; var year = decode4(d.substr(50,4)) + decode4(d.substr(54,4))*10; //console.log(hour+":"+minute+", "+day+"/"+month+"/"+year); var date = new Date(2000+year, month-1, day, hour, minute, 0, 0); return callback(null, date, { CEST:!!d[17], CET:!!d[18] } ); } this.connect = function(dataPin, callback) { var dcf = { last : getTime(), bits : "" }; setWatch(function (e) { // Work out what bit we got var d = e.time-e.lastTime; console.log("pulsewidth:",(d*1000).toString().substring(0, 3)); var bit = (d<0.12)?0:1; // if we had a 2 sec gap then it's the beginning of a minute if (e.time - dcf.last > 1.5) { decode(dcf.bits, callback); dcf.bits = ""; } dcf.last = e.time; // now add this bit of data dcf.bits += bit; if (dcf.bits.length>59) dcf.bits = dcf.bits.substr(-59); }, dataPin, { edge:"falling", repeat:true, debounce:60 }); return dcf; }; } var Clock = require("clock").Clock; var clk=new Clock(0); var dcf = new DCF77(); dcf.connect(B6, function(err, date, info) { if (err){ console.log("Invalid time received: " + err); }else{ console.log(date.toString(), info); clk.setClock(date.getTime()); } }); var woche = ["So","Mo","Di","Mi","Do","Fr","Sa"]; setInterval(function(){ var date = clk.getDate(); var weekday = date.getDay(); //0-31 var wochentag = woche[weekday]; var jahr = date.getFullYear(); var monat = date.getMonth()+1; monat=(monat<10)?"0"+monat:monat; var tag = date.getDate(); tag=(tag<10)?"0"+tag:tag; var stunden = date.getHours(); stunden=(stunden<10)?"0"+stunden:stunden; var minute = date.getMinutes();minute=(minute<10)?"0"+minute:minute; var sek = date.getSeconds(); sek=(sek<10)?"0"+sek:sek; var s1 = wochentag+". "+tag+"."+monat+"."+jahr; var s2 = stunden+":"+minute+":"+sek; printscreen(s1,s2,10); },1000); save();
@Gordon thank you for help.
-
-
-
-
i updated the firmware and switched to pin B6.
now i get a valid time :)
_____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v81 Copyright 2015 G.Williams >echo(0); =undefined Erasing Flash..... Writing....... Compressed 81600 bytes to 4745 Checking... Done! pulsewidth: 0.16911602020 Invalid time received: Bad minutes pulsewidth: 0.09433269500 pulsewidth: 0.09107685089 pulsewidth: 0.08496856689 pulsewidth: 0.08354568481 pulsewidth: 0.08212578296 pulsewidth: 0.09331417083 pulsewidth: 0.17105960845 pulsewidth: 0.17469120025 pulsewidth: 0.07842826843 pulsewidth: 0.17037200927 pulsewidth: 0.07430648803 pulsewidth: 0.17654514312 pulsewidth: 0.07944297790 pulsewidth: 0.08435630798 pulsewidth: 0.17442226409 pulsewidth: 0.08007431030 pulsewidth: 0.08116531372 pulsewidth: 0.08446788787 pulsewidth: 0.17115879058 pulsewidth: 0.17611885070 pulsewidth: 0.07796955108 pulsewidth: 0.17144978046 pulsewidth: 0.08308219909 pulsewidth: 0.17642116546 pulsewidth: 0.08210074901 pulsewidth: 0.08147811889 pulsewidth: 0.08908569812 pulsewidth: 0.17521846294 pulsewidth: 0.08436203002 Invalid time received: Bad minutes pulsewidth: 0.08617496490 pulsewidth: 0.17422580718 pulsewidth: 0.17254734039 pulsewidth: 0.08129310607 pulsewidth: 0.08000469207 pulsewidth: 0.07793712615 pulsewidth: 0.08469009399 pulsewidth: 0.17134666442 pulsewidth: 0.07955360412 pulsewidth: 0.08358573913 pulsewidth: 0.17171764373 pulsewidth: 0.16930770874 pulsewidth: 0.16940021514 pulsewidth: 0.17125415802 pulsewidth: 0.07798385620 pulsewidth: 0.07773876190 pulsewidth: 0.08058834075 pulsewidth: 0.16745769977 pulsewidth: 0.08179664611 pulsewidth: 0.17019271850 pulsewidth: 0.08226764202 pulsewidth: 0.16649723052 pulsewidth: 0.07572460174 pulsewidth: 0.07742798328 pulsewidth: 0.17198657989 pulsewidth: 0.07287502288 pulsewidth: 0.08357334136 pulsewidth: 0.08595657348 pulsewidth: 0.07994079589 pulsewidth: 0.07726287841 pulsewidth: 0.08137893676 pulsewidth: 0.08567523956 pulsewidth: 0.08365154266 pulsewidth: 0.08036613464 pulsewidth: 0.07942295074 pulsewidth: 0.08462131023 pulsewidth: 0.17574119567 pulsewidth: 0.17203903198 pulsewidth: 0.06586933135 pulsewidth: 0.17288875579 pulsewidth: 0.08118247985 pulsewidth: 0.17242527008 pulsewidth: 0.07482910156 pulsewidth: 0.08241367340 pulsewidth: 0.17064762115 pulsewidth: 0.07899856567 pulsewidth: 0.08000206947 pulsewidth: 0.08048152923 pulsewidth: 0.17255878448 pulsewidth: 0.17012310028 pulsewidth: 0.07951927185 pulsewidth: 0.17014408111 pulsewidth: 0.08236026763 pulsewidth: 0.16853904724 pulsewidth: 0.08116734027 pulsewidth: 0.08185195922 pulsewidth: 0.08379852771 pulsewidth: 0.17349720001 pulsewidth: 0.08322811126 Mon Nov 16 2015 00:12:00 GMT+0000 { "CEST": true, "CET": true }
-
i guess the problem could be the setWatch function.
i'm using the wifi adapter and an i2c oled display on the same espruino.so i tried a emtpy one with only the DCF77 sample.
but i still don't get a valid time:_____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v80 Copyright 2015 G.Williams >echo(0); =undefined Erasing Flash..... Writing.......... Compressed 81600 bytes to 7529 Checking... Done! 10 20 30 40 50 60 Invalid time received: Bad date 70 80 90 100 110 120 Invalid time received: Bad minutes 130 140 150 160 170 180 190 200 210 220 230 Invalid time received: Bad minutes 240 250 260 270 280 290 Invalid time received: Bad date 300 310 320 330 340 Invalid time received: Bad minutes 350 360 370 380 390 400 Fri Apr 25 2036 21:13:00 GMT+0000 { "CEST": true, "CET": true }
-
Hi Gordon,
i use the receiver from Conrad. It is a little bit different from the one on Pollin.
i tried your sample code:
require("DCF77").connect(B5, function(err, date, info) { if (err) console.log("Invalid time received: " + err); else console.log(date.toString(), info); });
But i haven't got any valid results. So i tried the dcf77 library from (http://thijs.elenbaas.net/2012/04/arduino-dcf77-radio-clock-receiver-library/)
with an arduino one.At the beginning i didn't get valid result there either, but then i tested his debug code.
i saw that his pulsewitdh differed from mine.he had 130 and 230ms.
on my side the pulses where 80 and 180ms:Cycle: 904 Pulse :185 Cycle: 999 Pulse :88 Cycle: 1002 Pulse :84 Cycle: 992 Pulse :191 Cycle: 1008 Pulse :87 Cycle: 1007 Pulse :178
After i changed the DCFSplitTime from 180 to 120 in his dcf77.h...
_#define DCFSplitTime 120
... i got a vaild time.
Waiting for DCF77 time ... It will take at least 2 minutes until a first update can be processed. 0:00:01 1 1 1970 0:00:02 1 1 1970 0:00:03 1 1 1970 0:00:04 1 1 1970 0:00:05 1 1 1970 0:00:06 1 1 1970 ... 0:02:09 1 1 1970 0:02:10 1 1 1970 0:02:11 1 1 1970 0:02:12 1 1 1970 0:02:13 1 1 1970 Time is updated 22:26:01 15 11 2015 22:26:02 15 11 2015 22:26:03 15 11 2015 22:26:04 15 11 2015 22:26:05 15 11 2015 ... 22:26:58 15 11 2015 22:26:59 15 11 2015 22:27:00 15 11 2015 Time is updated 22:27:01 15 11 2015 22:27:02 15 11 2015 22:27:03 15 11 2015 ...
How can i achieve this with the espruino?
PS: i also used a 10k resistor to pull up the Data Pin.
-
Hello friends,
thank you for you suggestions.
console.log("start"); //595 Pinput: /* 1 = 2 2 = 3 3 = 4 4 = 5 5 = 6 6 = 7 7 = 8 = Decimal Point/ DP 8 = GND 9 = carryover, to Next 595's SER/Pin 14 10 = SCL/CLR Rest, not used, flushing 32bit each time. 11 = Clock/SRCLK/SRCK, SPI1 SCK, Pin B3 12 = RCK/RCLK/LATCH/, SPI SS,Pin B6 via 10KOhm to Ground = Data Out 13 = Output Enable, GND 14 = Data/SER/SIN, SPI1 MOSI, Pin B5 15 = 1 16 = VCC 3,3V 330Ohm */ //SS Pin = B6 var sport = 0b00000001; var one = 48; // "00110000"; var two = 91; // "01011001"; var three = 121; // "01111001"; var four = 116; // "01110100"; var five = 109; // "01101101"; var six = 111; // "01101111"; var seven = 56; // "00111000"; var eight = 127; // "01111111"; var nine = 125; // "01111101"; var zero = 63; // "00111111"; var z = [zero,one,two,three,four,five,six,seven,eight,nine]; digitalWrite([B6,B7],0); // SS Pin to 0 digitalWrite([B7],1); SPI1.setup({ mosi:B5, sck:B3, baud:100000, order:'msb' }); //SPI Setup var out = 0; // current Segment var i = 0; // Value to Display var i1=0, i2=0, i3=0, i4=0; setInterval(function(){ i++; if (i>999)i=0; if (i>999){ i1 = Math.floor(i/1000); } else { i1 = 0; } if (i>99){ i2 = Math.floor(i/100) % 10; } else { i2 = 0; } if (i>9){ i3 = Math.floor(i/10) % 10; } else { i3 = 0; } i4 = i % 10; //SPI1.write(buf_off,B6); //flush only needed when not writing to all four segements SPI1.write([ z[i4], z[i3],z[i2],z[i1] ],B6); //SPI1.write([ sport, sport, sport ], B6); //to debug a segement },100);
I have chained three additional 74HC595 s. The problem with that solution is, that i have no clue how to bring all this wires to a PCB breadboard.
I think i will have to do it the multiplexing way to avoid all this new cables.
-
Hi,
can someone review my code? i think that there must be a more efficient way to get this done.
console.log("start"); //595 Belegung: /* 1 = 2 2 = 3 3 = 4 4 = 5 5 = 6 6 = 7 7 = 8 = Decimal Point, not used 8 = GND 9 = Serial Out, not used 10 = CLR Rest, Pin B7 11 = SCK, SPI1 SCK, Pin B3 12 = SS/RCK,Pin B6, 10KOhm to GND 13 = Output Enable, GND 14 = Datum/SER/SIN, SPI1 MOSI, Pin B5 15 = 1 16 = VCC 3,3V + 330Ohm */ //SS Pin = B6 //reset=B7 //B10 1000 - 9999 //B13 100 - 999 //B14 10 - 99 //B15 0 - 9 var one = 48; // "00110000"; var two = 91; // "01011001"; var three = 121; // "01111001"; var four = 116; // "01110100"; var five = 109; // "01101101"; var six = 111; // "01101111"; var seven = 56; // "00111000"; var eight = 127; // "01111111"; var nine = 125; // "01111101"; var zero = 63; // "00111111"; var z = [zero,one,two,three,four,five,six,seven,eight,nine]; var outpins = [B10,B13,B14,B15]; // the four 7 Segment LED Blocks digitalWrite(outpins,15); // LEDs off 15=1111 digitalWrite([B7,B6],0); // SS Pin und Reset to 0 digitalWrite([B7],1); // Reset to 1 pinMode(B10, output); pinMode(B13, output); pinMode(B14, output); pinMode(B15, output); SPI1.setup({ mosi:B5, sck:B3, baud:4000000 }); //SPI Setup var out = 0; // current Segment var i = 0; // Counter var i1=0, i2=0, i3=0, i4=0; //increase counter and split setInterval(function(){ i++; if (i>9999)i=0; if (i>999){ i1 = Math.floor(i/1000); } else { i1 = 0; } if (i>99){ i2 = Math.floor(i/100) % 10; } else { i2 = 0; } if (i>9){ i3 = Math.floor(i/10) % 10; } else { i3 = 0; } i4 = i % 10; },10); function loop4() { SPI1.send(z[i1],B6); digitalPulse(outpins[0],0,4); setTimeout(loop3,4); } function loop3() { SPI1.send(z[i2],B6); digitalPulse(outpins[1],0,4); setTimeout(loop2,4); } function loop2() { SPI1.send(z[i3],B6); digitalPulse(outpins[2],0,4); setTimeout(loop1,4); } function loop1() { SPI1.send(z[i4],B6); digitalPulse(outpins[3],0,4); setTimeout(loop4,4); } loop4();
Should it be possible to turn the Puck into an Fido2/U2F device?
I found this
https://wiki.makerdiary.com/nrf52-u2f/building/
and this
https://github.com/uru-card/uru-card