-
@allObjects, I allways use onInit(), but yes it needs the time too.
-
-
Try with an extra timeout
function ledInit() { digitalPulse(LED1,1,200); digitalPulse(LED2,1,400); } //function onInit() { E.on('init',function() { setTimeout(function() { // extra timeout USB.setConsole(); console.log('ini'); ledInit(); setTimeout(ledInit,2000); },1500); // extra timeout (try'd 1000 but did'n work) }); // end E.on() //} // end onInit() // onInit(); remove before save
-
Your code adapted to pico, runs well on my pico.
// htu21d_00.js // pico // left 1:gnd, 2:vbat, 3:3v3, 4:b3 //I2C1.setup({scl:5,sda:4}); //pico left 7: B6, left 8: B7 //I2C1 //pico left 4: B3, right 5: B10 //I2C2 //propeller sda: P29, scl: P28 setBusyIndicator(LED1); var i2c = new I2C(); //i2c.setup({scl: D17, sda: D19});//NRF52 i2c.setup( {scl: B6, sda: B7 } ); // pico soft i2c var htu = require('HTU21D').connect( i2c ); var temperature; var humidity; function HTU21DRead() { htu.getTemperature( function(temp) { htu.getHumidity( function(hum) { temperature = temp; humidity = hum; console.log('tmp : ' + temperature); console.log('hum : ' + humidity); }); } ); } setInterval("HTU21DRead()",1000);
And output.
> _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v95 Copyright 2017 G.Williams > =undefined tmp : 21.08276855468 hum : 35.24450683593 tmp : 21.08276855468 hum : 35.22161865234 tmp : 21.08276855468 hum : 35.23687744140 tmp : 21.08276855468 hum : 35.25213623046 tmp : 21.08276855468 hum : 35.259765625 tmp : 21.09349365234 hum : 35.28265380859 tmp : 21.08276855468 hum : 35.28265380859 tmp : 21.09349365234 hum : 35.28265380859 >reset(); =undefined _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v95 Copyright 2017 G.Williams >
-
Tried today with an atmlu016 on breadboard, without pullup resistors and without capacitor. Can not see any problems here.
/* _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v95.61 Copyright 2017 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate Flash map 512KB:256/256, manuf 0xc8 chip 0x4013 > =undefined Hello World { "sdkVersion": "2.0.0(5a875ba)", "cpuFrequency": 160, "freeHeap": 10576, "maxCon": 10, "flashMap": "512KB:256/256", "flashKB": 512, "flashChip": "0xc8 0x4013" } >eeprom.read(0,10) =new Uint8Array([99, 55, 255, 255, 255, 255, 255, 255, 255, 255]) > =undefined >eeprom.write(2,[99,55]) =2 >eeprom.read(0,10) =new Uint8Array([99, 55, 99, 55, 255, 255, 255, 255, 255, 255]) > */
-
Downloaded from github yesterday, and compiled on linux.
Then I deleted flash and flashed the new version on an esp8266-01.
I still can not see any errors here, but maybe I'm using a wrong eeprom?/* _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v95.61 Copyright 2017 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate Flash map 512KB:256/256, manuf 0xc8 chip 0x4013 > =undefined Hello World > =undefined >eeprom.read(0,10) =new Uint8Array([99, 55, 196, 4, 111, 81, 16, 0, 28, 0]) > =undefined >eeprom.write(2,[55,99]) =2 > =undefined >eeprom.read(0,10) =new Uint8Array([99, 55, 55, 99, 111, 81, 16, 0, 28, 0]) > =undefined > */
This is my test setup.
-
-
With a pico and an esp8266 from kickstarter on an 24lc256 eeprom there is nothing failed.
esp8266 is on version 1v94 and pico is on 1v95
_____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v94 Copyright 2017 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate Flash map 512KB:256/256, manuf 0xc8 chip 0x4013 >
var eeprom; function dd() { //I2C2.setup( {scl: B10, sda: B3 } ); // pico //eeprom=require("AT24").connect(I2C2, 64, 256); I2C1.setup({scl:D2, sda:D0, bitrate:400000}); //esp8266 eeprom=require("AT24").connect(I2C1, 64, 256); } setTimeout(function () { console.log("Hello World"); dd(); }, 1000); /* pico =undefined Hello World >eeprom.read(0,10) =new Uint8Array([0, 180, 196, 4, 111, 81, 16, 0, 28, 0]) > ^ >eeprom.write(0,[55,99]) =2 =undefined >eeprom.read(0,10) =new Uint8Array([55, 99, 196, 4, 111, 81, 16, 0, 28, 0]) > */ /* esp8266 =undefined Hello World >eeprom.read(0,10) =new Uint8Array([55, 99, 196, 4, 111, 81, 16, 0, 28, 0]) > =undefined >eeprom.write(0,[99,55]) =2 >eeprom.read(0,10) =new Uint8Array([99, 55, 196, 4, 111, 81, 16, 0, 28, 0]) > */
-
Please a picture of the module.
Is it like those, there is on those pages.
https://www.espruino.com/EspruinoESP8266
https://www.espruino.com/ESP8266
If it is, then D1 is tx out. -
-
I have problems with Math.wrap.
When I run it in a program, it does not wrap, but if I enter it in the console it wraps it ok.// test.js var tmp = []; var i = 0; var k = 0; function onInit() { for(var j = 0; j < 30; j++) { tmp[i] = i; console.log('k = ' + k +' ' + 'i = ' + i); Math.wrap(k++, 10); i++; if(i > 9) {i = 0;} } console.log(tmp); console.log(tmp.length); } setTimeout(onInit, 100); /* k = 0 i = 0 k = 1 i = 1 k = 2 i = 2 k = 3 i = 3 k = 4 i = 4 k = 5 i = 5 k = 6 i = 6 k = 7 i = 7 k = 8 i = 8 k = 9 i = 9 k = 10 i = 0 k = 11 i = 1 k = 12 i = 2 k = 13 i = 3 k = 14 i = 4 k = 15 i = 5 k = 16 i = 6 k = 17 i = 7 k = 18 i = 8 k = 19 i = 9 k = 20 i = 0 k = 21 i = 1 k = 22 i = 2 k = 23 i = 3 k = 24 i = 4 k = 25 i = 5 k = 26 i = 6 k = 27 i = 7 k = 28 i = 8 k = 29 i = 9 [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ] 10 >k =30 >Math.wrap(k++, 10) =0 >Math.wrap(k++, 10) =1 >Math.wrap(k++, 10) =2 >Math.wrap(k++, 10) =3 >Math.wrap(k++, 10) =4 >Math.wrap(k++, 10) =5 >Math.wrap(k++, 10) =6 >Math.wrap(k++, 10) =7 >Math.wrap(k++, 10) =8 >Math.wrap(k++, 10) =9 >Math.wrap(k++, 10) =0 >Math.wrap(k++, 10) =1 >Math.wrap(k++, 10) =2 > */
On a Pico
-
You can read more of it on: https://learn.adafruit.com
The BME680 takes those sensors to the next step in that it contains a small MOX sensor. The heated metal oxide changes resistance based on the volatile organic compounds (VOC) in the air, so it can be used to detect gasses & alcohols such as Ethanol, Alcohol and Carbon Monoxide and perform air quality measurements. Note it will give you one resistance value, with overall VOC content, it cannot differentiate gasses or alcohols. -
-
I can upload this feature, but it does not give me any default values.
Will it work in Espruino?function dd (tmp, dur = 100, opt = 50) { // if (tmp === undefined) tmp = 200; // if (dur === undefined) dur = 100; // if (opt === undefined) opt = 0; console.log (tmp, dur, opt); } /* >dd() undefined undefined undefined =undefined >dd(10,20,30) 10 20 30 =undefined */
-
Hi, I have found the last mistakes, so now the gas sensor works.
There was a calculation of calc_heater_resistance and calc_heater_duration missing.
I'm still working on adding some features.
I tried to turn it into a module, but I do not have enough knowledge yet.
I hope you can use it. I moved the tables under "C".
If you are looking for PB, you can see where I have made changes. -
Yes, that's the one I'm looking at, I've soldered the plug on Raspi and connected the sensor.
The gas resistance is now around 180,000 Ohm, after several hours of operation, and falls to
about 100,000 Ohm, when I breathe on it.
I can see in the C program that 64 bit variables are used, can Pico calculate 64 bit? -
Hi! I have changed getInt16 () and getUint16 (xx, true), according to Doc
function DataView.getUint16 (byteOffset, littleEndian) byteOffset - The offset in bytes to read from littleEndian - (optional) Whether to read in little endian - if false or undefined data is read as big endian
So now, temperature, pressure and humidity show the same as my Ruuvitag.
Gas resistance is very high so I do not know if it is correct! 12,535,991.64395217411.
If I try with upython on a Wipy, the number is negative.
The next thing I want to try is on a RaspberryPi.BME680.prototype.get_calib_data = function() { var coefs = new Uint8Array(C.COEFF_ADDR1_LEN+C.COEFF_ADDR2_LEN); coefs.set(this.r(C.COEFF_ADDR1,C.COEFF_ADDR1_LEN)); coefs.set(this.r(C.COEFF_ADDR2,C.COEFF_ADDR2_LEN),C.COEFF_ADDR1_LEN); var vc = new DataView(coefs.buffer); // everything is little endian this.cal={}; /* Temperature related coefficients */ this.cal.par_t = [,vc.getUint16(C.T1_LSB_REG, true) // PB ,vc.getInt16(C.T2_LSB_REG, true) // PB ,vc.getInt8(C.T3_REG)]; /* Pressure related coefficients */ this.cal.par_p = [,vc.getUint16(C.P1_LSB_REG, true) // PB ,vc.getInt16(C.P2_LSB_REG, true) // PB ,vc.getInt8(C.P3_REG) ,vc.getInt16(C.P4_LSB_REG, true) // PB ,vc.getInt16(C.P5_LSB_REG, true) // PB ,vc.getInt8(C.P6_REG) ,vc.getInt8(C.P7_REG) ,vc.getInt16(C.P8_LSB_REG, true) // PB ,vc.getInt16(C.P9_LSB_REG, true) // PB ,vc.getUint8(C.P10_REG)]; /* Humidity related coefficients */ this.cal.par_h = [,(vc.getUint8(C.H1_MSB_REG) << C.HUM_REG_SHIFT_VAL) | (vc.getUint8(C.H1_LSB_REG) & C.BIT_H1_DATA_MSK) ,(vc.getUint8(C.H2_MSB_REG) << C.HUM_REG_SHIFT_VAL) | (vc.getUint8(C.H2_LSB_REG) >> C.HUM_REG_SHIFT_VAL) ,vc.getInt8(C.H3_REG) ,vc.getInt8(C.H4_REG) ,vc.getInt8(C.H5_REG) ,vc.getUint8(C.H6_REG) ,vc.getInt8(C.H7_REG)]; /* Gas heater related coefficients */ this.cal.par_gh = [,vc.getInt8(C.GH1_REG) ,vc.getInt16(C.GH2_LSB_REG, true) // PB ,vc.getInt8(C.GH3_REG)]; /* Other coefficients */ this.cal.res_heat_range = (this.r(C.ADDR_RES_HEAT_RANGE_ADDR,1)[0]&C.RHRANGE_MSK)/16; this.cal.res_heat_val = this.r(C.ADDR_RES_HEAT_VAL_ADDR,1)[0]; this.cal.range_sw_err = (this.r(C.ADDR_RANGE_SW_ERR_ADDR,1)[0]&C.RSERROR_MSK)/16; };
-
-
-
-
run this in own folder:
git clone --recursive https://github.com/espruino/EspruinoWebIDE.gitthen you get a copy, double or 3 duble this folder or more.
in chrome://extensions/
do "Load unpacked extension" from your copyesthen in:
chrome://apps/
you have -
-
I don't know a lot of this, but took it from here:
https://github.com/ruuvi/ruuvi-sensor-protocols#sensor-protocol-for-sensor-tag -
Is it somthing like this.
I made this on my Puck to get ruuvi tags and display the results.
The ruuvi tags are emitting raw values in "Manufacturer specific data".// pucktest05 setBusyIndicator(LED1); var darray = {}; var tg = 0x2F; // 0x2F ^ 0x73 = 0x5C var count = 0; function getDewpoint(temp, humi) { var C = { a1 : 8.1332, b1 : 1762.39, c1 : 235.66 }; PP = Math.pow(10,C.a1 - C.b1 / (this.temp + C.c1)); this.dewp = -((C.b1 / (Math.log(this.humi * PP / 100) / Math.log(10) - C.a1)) + C.c1); return this.dewp.toFixed(2); } function bprint(dada, navn) { humi = dada.data[8] / 2; temp = dada.data[9] + dada.data[10] / 100; if(temp >128) {temp = 128 - temp;} bati = (dada.data[19] * 256 + dada.data[20]); dewi = getDewpoint(temp, humi); console.log(navn + dada.rssi + ' ' + temp.toFixed(2) + ' ' + humi.toFixed(1) + ' ' + dewi + ' ' + bati); } function cprint(didi) { tg ^= 0x73; console.log('count: ' + count++); console.log(String.fromCharCode(tg) + ' ' + NRF.getBattery().toFixed(3)); console.log(' Sted Rssi Temp Humi Dewi Bati'); bprint(didi[0], ' Ude: '); bprint(didi[1], 'Drivhus: '); bprint(didi[2], ' Bad: '); bprint(didi[3], 'Udestue: '); console.log(' '); } function find() { NRF.findDevices(function(devices) { console.log(devices.length); for(i=0;i<devices.length;i++) { if(devices[i].id == 'ce:5c:55:08:22:5a random') { darray[0] = devices[i]; } if(devices[i].id == 'da:dc:f2:19:d4:e3 random') { darray[1] = devices[i]; } if(devices[i].id == 'fa:2e:7b:6d:97:e0 random') { darray[2] = devices[i]; } if(devices[i].id == 'fc:62:2d:b7:96:30 random') { darray[3] = devices[i]; } } cprint(darray); }, 3000); } find(); setInterval(function () { find(); }, 60000);
Uploaded to Pico.
And the answer is:
But should have been Tuesday, April 3rd 2018 16:56.
I am on GMT +1
Should it not have taken the time from the PC?
Web IDE version 0.68.6