-
Hello,
wanted to know if there is a way to upload the code not using IDE ?
or somehow to intigrate it into my website using API ?I'm using the MDBT42 only as a beacon - and I want to be able to change it's name when ever I want to
is this somthing reasonable to do ?
is there any way to do it?*** I have created a virtual com to the device and using the webIDE I can uplaod to him the wanted code , so no netwrok issue
Thanks , -
-
-
I don't know what to say:
I have try to upload the code you posted(I'm write it so you will see no errors)
var mcp; function onInit() { clearInterval(); I2C1.setup({scl:D25,sda:D26, bitrate: 60000}); mcp = require("MCP9808").connect(I2C1, 0b000); console.log("I2C Setup Finsih"); ReadTemp(); } function ReadTemp() { setInterval (function() { digitalWrite(LED1,0); var temperature = mcp.getTemperature(); var TimeStemp = new Date().toString(); console.log(TimeStemp + " : " + "Temperature: " + temperature + " C"); setTimeout(function(){ digitalWrite(LED1,1); },5000); } , 10000); } onInit();
this is what I get :
> ____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v07 (c) 2019 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate > Running onInit()... Uncaught Error: Module MCP9808 not found at line 3 col 26 mcp = require("MCP9808").connect(I2C1, 0b000); ^ in function called from system
both on RAM\Flash uplaod
what is wrong now?
update*
I get the same error when I try to uplaod my own code that works before -
-
so what to do now?
I have change it to "Flash" but it say "Sent"
but still it stuck (can't do nothing on the console )
I have disconnect , and now I can't reconnectI have reboot the device ,recoonet it
nothing is running now (no output on the console)
but I can "talk" with the device:>new Date().toString() ="Thu Jan 1 1970 00:01:34 GMT+0000"
have try to run upload to FLASH
and this is what I get :____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v07 (c) 2019 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate >Uncaught Error: File already written with different data at line 1 col 1077 ....REG_TEMPERATURE);r",0,3939); ^ Uncaught Error: Unable to find or create file at line 2 col 1082 ...FIG,d&65522|a&13)};a.",1024); ^ Uncaught Error: Unable to find or create file at line 3 col 1070 ...otype.write8=function",2048); ^ Uncaught Error: Unable to find or create file at line 4 col 943 ...\n\nReadTemp();\n\n\n",3072); ^ >
so what to do now?
** I have uplaod it now to RAM - and it's working (if it's help you to understand and help me)
Thanks ,
-
the address is OK
I have check in some i2c scannerI think something is wrong with the flash memory
because I have upload the code using the esperino IDE in chrome this time , selected RAM
and it's working , it print me the datathis is the code:
I2C1.setup({scl:D25,sda:D26, bitrate: 60000}); var mcp = require("MCP9808").connect(I2C1, 0b000); console.log("I2C Setup Finsih"); function ReadTemp() { setInterval (function() { digitalWrite(LED1,0); var temperature = mcp.getTemperature(); var TimeStemp = new Date().toString(); console.log(TimeStemp + " : " + "Temperature: " + temperature + " C"); setTimeout(function(){ digitalWrite(LED1,1); },5000);} , 10000);} ReadTemp();
I have used upload to RAM
and it's workingMon Oct 12 2020 10:53:35 GMT+0300 : Temperature: 21.625 C Mon Oct 12
2020 10:53:45 GMT+0300 : Temperature: 21.5625 C Mon Oct 12 2020
10:53:55 GMT+0300 : Temperature: 21.5 C Mon Oct 12 2020 10:54:05
GMT+0300 : Temperature: 21.5625 C Mon Oct 12 2020 10:54:15 GMT+0300
: Temperature: 21.5625 C Mon Oct 12 2020 10:54:25 GMT+0300 :
Temperature: 21.5625 Cnow I have enter save() , in order to make it work after reboor\power off - everything
got stuck:
can't write nothing in the console
get no replay
the led is offthis is what I have in the console after "save()"
>save() =undefined Compacting Flash... Calculating Size... Writing.. Compressed 40000 bytes to 6792
what to do now ? something went wrong ?
Thanks ,
-
after I wated all day connectiong the device using USB-serial
I have try to use the bluetooth option in the chrome ide - https://www.espruino.com/ide/#I can see the device
I can connect to it
but I get this errorCONNECTED TO WEB BLUETOOTH, MDBT42Q 2E7E (NO RESPONSE FROM BOARD)
how could it be?
what can I do now?I have try with another board
I get this errorCONNECTION FAILED.
I have only conneced 3.3V and gnd to the devices
what is wrong?
Thanks ,
-
another problem
I have try to upload this code
I2C1.setup({scl:D25,sda:D26, bitrate: 60000}); var mcp = require("MCP9808").connect(I2C1, 0b000); // 0b000 means A2 = A2 = A1 = GND var temperature = mcp.getTemperature(); console.log("Temperature: " + temperature + " C"); function ReadTemp() { setInterval (function() { var temperature = mcp.getTemperature(); console.log("Temperature: " + temperature + " C"); digitalWrite(LED1,1); } ,1000);} digitalWrite(LED1,0); ReadTemp();
I get no error while uploading ,
just see the bar running , then "SENT"
see the____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v07 (c) 2019 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate
then nothing - the device is not replay
nothing on the console , can't write nothing on itI don't get any error - but it doesn't uplaod the code
after reboot from power - It run the old code (the one on the first post)
how could it be ?Thanks ,
-
Hello ,
I have bought the MCP9808 and connect itcopy the code from here:
I2C1.setup({scl:B6,sda:B7, bitrate: 60000}); var mcp = require("MCP9808").connect(I2C1, 0b000); // 0b000 means A2 = A2 = A1 = GND var temperature = mcp.getTemperature(); console.log("Temperature: " + temperature + " C");
but I get this error:
in function called from system Uncaught Error: Cannot read property 'getTemperature' of undefined at line 10 col 22 var temperature = mcp.getTemperature(); ^ in function called from system Uncaught Error: Cannot read property 'getTemperature' of undefined at line 10 col 22 var temperature = mcp.getTemperature()
what is missing?
do I need to download something?
Thanks, -
I know that the MAx30102 is also a temperture sensor
from the datasheet
https://datasheets.maximintegrated.com/en/ds/MAX30102.pdfINTERNAL DIE TEMPERATURE SENSOR Temperature ADC Acquisition Time TT TA
= +25°C 29 ms Temperature Sensor Accuracy TA TA = +25°C ±1 °C Temperature Sensor Minimum Range TMIN -40 °C Temperature Sensor
Maximum Range TMAX 85 °CI will figure the data out - but now I want to be sure the what you wrote can "read" the temp data
-
-
-
this is what I did:
// set up I2C var i2c = new I2C(); i2c.setup({ scl : D25, sda: D26 }); var P = { HRM_SCL : D25, HRM_SDA : D26 }; var hrm = (function() { // MAX30102 var R = { INTR_STATUS_1 : 0x00, INTR_STATUS_2 : 0x01, INTR_ENABLE_1 : 0x02, INTR_ENABLE_2 : 0x03, FIFO_WR_PTR : 0x04, OVF_COUNTER : 0x05, FIFO_RD_PTR : 0x06, FIFO_DATA : 0x07, FIFO_CONFIG : 0x08, MODE_CONFIG : 0x09, SPO2_CONFIG : 0x0A, LED1_PA : 0x0C, LED2_PA : 0x0D, PILOT_PA : 0x10, MULTI_LED_CTRL1 : 0x11, MULTI_LED_CTRL2 : 0x12, TEMP_INTR : 0x1F, TEMP_FRAC : 0x20, TEMP_CONFIG : 0x21, PROX_INT_THRESH : 0x30, REV_ID : 0xFE, PART_ID : 0xFF }; var i = new I2C(); i.setup({scl:P.HRM_SCL,sda:P.HRM_SDA}); function r(a,n) { i.writeTo(87,a); return i.readFrom(87,n); } function w(a,d) { i.writeTo(87,[a,d]); } function init() { if (r(R.PART_ID,1)!=0x15) throw new Error("WHO_AM_I failed"); w(R.MODE_CONFIG,0x40); // reset all w(R.INTR_ENABLE_1,0xc0); // INTR setting w(R.INTR_ENABLE_2,0x00); w(R.FIFO_WR_PTR,0x00); //FIFO_WR_PTR[4:0] w(R.OVF_COUNTER,0x00); //OVF_COUNTER[4:0] w(R.FIFO_RD_PTR,0x00); //FIFO_RD_PTR[4:0] w(R.FIFO_CONFIG,0b10001111); //sample avg = 4, fifo rollover=false, fifo almost full = 17 w(R.MODE_CONFIG,0x02); //0x02 for Red only, 0x03 for SpO2 mode 0x07 multimode LED w(R.SPO2_CONFIG,0b00101111); // SPO2_ADC range = 4096nA, SPO2 sample rate (400 Hz), LED pulseWidth (411uS) w(R.LED1_PA,0x3f); //Choose value for ~ 7mA for LED1 w(R.LED2_PA,0x3f); // Choose value for ~ 7mA for LED2 w(R.PILOT_PA,0x3f); // Choose value for ~ 8mA for Pilot LED (?)( } function kill() { w(R.MODE_CONFIG,0x40); } function read() { var d = r(R.FIFO_DATA,6); return { red : (d[0]<<16)|(d[1]<<8)|d[2], ir : (d[3]<<16)|(d[4]<<8)|d[5] }; } function readFifoRaw() { var fifo = r(R.FIFO_WR_PTR,3); // wr,overflow,rd var s = fifo[0]-fifo[2]; if (s<=0) s+=32; if (fifo[1]) s=32; //overflowed var result = []; return r(R.FIFO_DATA,3*s); } function decodeRawData(d, red) { var l = d.length; for (var i=0,n=0;i<l;i+=3,n++) { red[n] = (d[i+0]<<16)|(d[i+1]<<8)|d[i+2]; } } var h = { r:r,w:w, init:init, kill:kill, read:read, // read one readFifoRaw:readFifoRaw, // read entire fifo as raw data (32 elements max, 6 bytes each) decodeRawData:decodeRawData // decode data read with readFifoRaw }; // IRQ seems not to work at the moment //pinMode(P.HRM_INT,"input_pullup"); //setWatch(function() { // h.emit('data',read()); //}, P.HRM_INT, {repeat:true,edge:-1}); // could use with hrm.on('data',x=>print("hrm",x)); return h; })(); function getHRM() { print("Starting HRM..."); hrm.init(); var cnt = 100; var rawdata = new Uint8Array(cnt*3); var dcnt = 0; print("Waiting for HRM... wait 1 second"); var i = setInterval(function() { hrm.readFifoRaw(); }); setTimeout(function() { print("Reading HRM... wait 10 seconds"); clearInterval(i); hrm.readFifoRaw(); var t = getTime(); var i = setInterval(function() { d = hrm.readFifoRaw(); rawdata.set(d, dcnt*3); dcnt += d.length/3; if (dcnt>=cnt) { drawHRM(rawdata); dcnt=0; } }, 1000); }, 1000); } function drawHRM(rawdata) { var cnt = rawdata.length/3; var dred = new Uint32Array(cnt); hrm.decodeRawData(rawdata, dred); var g = Graphics.createArrayBuffer(cnt,60,1); var red = E.sum(dred)/cnt; g.clear(); g.drawString("Red",2,2); g.moveTo(-100,0); for (var i=0;i<cnt;i++) g.lineTo(i,30+(dred[i]-red)/10); g.dump(); } getHRM();
in the device (MAx30102):
connected 3.3V,GND
SCL-D25
SDA-D26after I uplaod the code I get this error:
>Starting HRM... Uncaught Error: WHO_AM_I failed at line 45 col 60 ...new Error("WHO_AM_I failed"); ^ in function "init" called from line 103 col 12 hrm.init(); ^ in function "getHRM" called from line 143 col 8 getHRM();
why?
what did I do wrong ?I disconnected the max3012 and connect it to the arduino - it's working (so now hardware issue ) . did it just to be sure
-
-
-
-
-
-
-
-
hello ,
I have started a new project , and went back to basic because something isn't working for me
simple scan for devices and print them
this is the code:NRF.setAdvertising({}, {name: "Test3"}); var s=setInterval(function(){ LED1.write(false); NRF.findDevices(function(devices) { if (devices.length>0) { print("I found you :\n\r "); for(var i=0;i<devices.length;i++) { var time = (new Date()).toString(); var rssi = devices[i].rssi; var MAC = devices[i].id; var name = devices[i].name; var manufacturer = devices[i].manufacturer; print ( + " " + time + " " + MAC + " " + rssi + " " + name + " " + manufacturer ); } } LED1.write(true); print ("**************************"); }, 1000);},5000);
I can see devices found (none of them is my phone...)
I found you : NaNMon Aug 10 2020 17:08:56 GMT+0300 00:0e:0b:0c:70:03 -77 undefined 19784 NaNMon Aug 10 2020 17:08:56 GMT+0300 7c:9a:12:f8:57:c3 -85 undefined 76 NaNMon Aug 10 2020 17:08:56 GMT+0300 28:af:35:20:89:9b -89 undefined 6 NaNMon Aug 10 2020 17:08:56 GMT+0300 68:bd:35:87:b2:2c -87 undefined 6 NaNMon Aug 10 2020 17:08:56 GMT+0300 60:d9:f3:7d:3e:a6 -87 undefined 76 **************************
everything is on the desk maybe 10 cm from the device
the samsung phone bluetooth is open
how could it be ?
did I miss something in the code?Thanks ,
-
-
great
thank you
I think you can post the code you post here as an easy to understand example
or even first code jsut flahs it
much more easy to understand ....so see I understand it correct:
NRF.setAdvertising([ require("ble_eddystone").get("http://www.david.com"), { //this part is all the data I want to show using Hex , // can take examples from here https://www.bluetooth.com/specifications/gatt/characteristics/ - //right? 0x180F : [NRF.getBattery()], 0x1809 : [Math.round(E.getTemperature())] } ], //this is the default setting I can cahnge - right ? this is the only setting I can change from here { name : "David", showName: true, discoverable : true, connectable : false, scannable : true, interval:100 });
so now:
I can see the device in bluetooth normal scan (see the name only and can't connect to it because of connectable : false)
I can see the data from "NRF-connect". which is what I wantThank you so so much for this!
- I'm tryin to play with this , and send more data
just for the test I want to test this Hex(Got this from https://www.bluetooth.com/specifications/gatt/characteristics/)
Age org.bluetooth.characteristic.age 0x2A80 GSS
and add this to the code:{//here I put the HEX data -https://www.bluetooth.com/specifications/gatt/characteristics/ 0x180F : [NRF.getBattery()], 0x1809 : [Math.round(E.getTemperature())], 0x2A80 : "15" }
in the NRF I can see battery\temp but not age -jsut Service Data without name - why?
just 20x2A80 0x31 0x35 (which is 15)
is it standart?also can I set the time of the ble_eddystone for showing 2 websites?
I did thisrequire("ble_eddystone").get("http://www.david1.com"), require("ble_eddystone").get("http://www.Danny1.com"),
if I want to make 1 min for website1 and 2 min for website 2?
and meanwhile it will send data every 1 sec ?
or I need to write a more complicated code for this ?also the battery shown 3%
is it because I'm connecting using USB to the V+ (5V) and not to the battery input?
can I know what the voltage I'm using ? beacuse I saw it can be power onwill work off of 2.5 to 16 volts
can I measure the input?
Thanks,
- I'm tryin to play with this , and send more data
the device is not near the computer
I want to be able to uplaod\ chhange the code from another palce \ remote location