-
@MaBe told me to set the cpufreq to 80, this is better now I have readings, but I have negativ values in the temperature what is wrong.
-
This is what I get from this old version:
>reset(); =undefined _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v85.tve_master_cee7141 Copyright 2016 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate Flash map 4MB:512/512, manuf 0xe0 chip 0x4016 >echo(0); =undefined { "temp": 25.2, "rh": 46.1 } Temp is 25.2 and RH is 46.1 { "temp": 25.2, "rh": 48.4 } Temp is 25.2 and RH is 48.4 { "temp": 25.2, "rh": 48 } Temp is 25.2 and RH is 48 { "temp": 25.2, "rh": 49.9 } Temp is 25.2 and RH is 49.9 { "temp": 25.3, "rh": 49.9 } Temp is 25.3 and RH is 49.9 { "temp": 25.3, "rh": 50 } Temp is 25.3 and RH is 50 { "temp": 25.3, "rh": 49.8 } Temp is 25.3 and RH is 49.8 { "temp": 25.3, "rh": 49 } Temp is 25.3 and RH is 49 { "temp": 25.3, "rh": 48.5 } Temp is 25.3 and RH is 48.5 >clearInterval() =undefined
Dont know when it works with the new. If I plug and unplug about every second, some times, it write out some negativ values, but the other part is just no data.
-
@Gordon this does not work for me. I'm using AM2302, ESP8266
>reset() =undefined _____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v85 Copyright 2016 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate Flash map 4MB:512/512, manuf 0xe0 chip 0x4016 >
{ "raw": "0100000001100110110000000100110000110011011", "rh": 41.1, "temp": -30.4 } Temp is -30.4 and RH is 41.1 { "err": true, "checksumError": false, "raw": "", "temp": -1, "rh": -1 }
It is getting err: true, if I unplug/replug the data pin from the AM2302 then sometimes it reads like this negative value.
This is the code what i'm using now:
var pin=D2; var dht = require("https://raw.githubusercontent.com/espruino/EspruinoDocs/master/devices/DHT22.js").connect(pin); setInterval(function() { dht.read( function(a){ console.log(a); console.log("Temp is "+a.temp.toString()+ " and RH is "+a.rh.toString()); });}, 1000);
Using this is wrong to:
var dht = require("DHT22").connect(pin);
-
-
-
https://github.com/HyGy/Nextion
I started a basic version. Feel free to bugreport, extend, etc...
HyGy
-
-
-
-
-
I put this workaround into the code, and its the same...
sendTsStart { "free": 179, "usage": 844, "total": 1023, "history": 38 } ERROR: Out of Memory! WARNING: Unable to create string as not enough memory WARNING: Unable to create string as not enough memory WARNING: Unable to create string as not enough memory WARNING: Unable to create string as not enough memory Execution Interrupted
-
I'm not sure, how is this workaround working. The setTimeout runs timeout, but the http.get need to be wayted, while it calls the callback. But if we are there, then something is happend, whay it is called the callback, and if the callback called after 10 minutes, it will wait 10 minutes.
And I cannot se, where this errTimeout kill the original http call/socket, if timed out. -
I commented out all the onewire and ds18b20 codes and libs from the code when the test run, as @Kolban asked. :)
-
Okay,
The mean time I connected a second usbttl to UART1:
@Kolban is it help for you?
Here is what I get on the debug serial port:Restart info: reason: 6=reset pin exccause: 0 epc1: 0 epc2: 0 epc3: 0 excvaddr: 0 depc: 0 Flash map 512KB:256/256, manuf 0xE0 chip 0x4016 Heap: 6096 Variables: 1023 @12ea = 12276bytes Time sys=320912 rtc=62118 mode : null > initDone > jshInit RTC read: 1685498645 1873183604 0xfd538868 (0x9e8d8e81) RTC: cannot restore time UStimer init < jshInit > jswrap_ESP8266_init > jswrap_ESP8266WiFi_ ets Jan 8 2013,rst cause:2, boot mode:(3,0) load 0x40100000, len 30936, room 16 tail 8 chksum 0x75 load 0x3ffe8000, len 2108, room 0 tail 12 chksum 0x34 ho 0 tail 12 room 4 load 0x3ffe8840, len 29476, room 12 tail 8 chksum 0x15 csum 0x15 Restart info: reason: 2=exception exccause: 0 epc1: 40100711 epc2: 0 epc3: 0 excvaddr: 0 depc: 0 Flash map 512KB:256/256, manuf 0xE0 chip 0x4016 Heap: 6096 Variables: 1023 @12ea = 12276bytes Time sys=330807 rtc=944651649 mode : null > initDone > jshInit RTC read: 5374 933665468 0xa95ea382 (0xdeadbeef) RTC: restore sys=340961 rtc=944653293 RTC: restored time: 5442 (delta=10987825 cal=6174us) UStimer init < jshInit > jswrap_ESP8266_init > jswrap_ESP8266WiFi_
And here is what I got from the espruino console:
sendTsStart { "free": 425, "usage": 598, "total": 1023, "history": 20 } > Disconnected > Connected Interrupted Execution Interrupted Execution Interrupted > ASSERT(jsvHasCharacterData(str)) FAILED AT src/jsvariterator.c:144 #1[r1,l2] Object { #2[r1,l2] Name String [1 blocks] "" #3[r1,l2] Object { #6[r1,l2] Name String [1 blocks] "" #493[r1,l2] String [2 blocks] "\x04\x00\x00\x00\x00ÿÿÿ" #9[r1,l2] Name String [2 blocks] "" #11[r2,l1] Array(177) [ #513[r1,l2] Name Integer 1 #521[r1,l1] Object { #519[r1,l2] Name String [1 blocks] "" undefined #517[r1,l2] Name String [2 blocks] "" #518[r1,l1] Integer 500000 #515[r1,l2] Name String [2 blocks] "" #531[r1,l1] Function { #526[r1,l2] Name String [1 blocks] "" #532[r1,l1] String [6 blocks] "{toggle=!toggle;digitalWrite(GPIO2,toggle)}" #525[r1,l2] Name String [1 blocks] "" #201[r1,l1] Function { #509[r1,l2] Name String [2 blocks] "" undefined } #523[r1,l2] Name String [1 blocks] ""= int 4 } } #474[r1,l2] Name Integer 176 #377[r1,l1] Object { #372[r1,l2] Name String [1 blocks] "" undefined #462[r1,l2] Name String [2 blocks] "" #432[r2,l1] ... } ] #12[r1,l2] Name String [2 blocks] "" #14[r2,l1] Array(0) [ ] #15[r1,l2] Name String [2 blocks] "" #19[r1,l1] Array(13) [ ] #21[r1,l2] Name String [2 blocks] "" #35[r1,l1] Object { #23[r1,l2] Name String [2 blocks] "" #36[r2,l1] ... #186[r1,l2] Name String [1 blocks] "" #185[r2,l1] ... } #641[r1,l2] Name String [2 blocks] "" #643[r1,l1] Array(175) [ #719[r1,l2] Name Integer 73 #728[r1,l1] Object { #727[r1,l2] Name String [2 blocks] "" #660[r9,l1] ... #721[r1,l2] Name String [1 blocks] ""= int 1 #722[r1,l2] Name String [2 blocks] "" #817[r1,l1] Function { #813[r1,l2] Name Param "" undefined #778[r1,l2] Name String [1 blocks] "" #814[r1,l1] String [37 blocks] "{print(\"get callback!\");a.on(\"data\",function(a){console.log(\"connection getdata:\");console.log(process.memory());console.log(E.getSizeOf(global,1));print(a)});a.on(\"close\",function(){print(\"The response connection closed\");console.log(\"connection close\");console.log(process.memory())})}" #777[r1,l2] Name String [1 blocks] "" #953[r1,l1] Function { #955[r1,l2] Name Param "" #488[r176,l1] ... #949[r1,l2] Name String [2 blocks] "" undefined } #775[r1,l2] Name String [1 blocks] ""= int 6 } #718[r1,l2] Name String [1 blocks] "" #731[r1,l1] Object { #730[r1,l2] Name String [2 blocks] "" #649[r176,l1] ... } #713[r1,l2] Name String [1 blocks] "" #842[r1,l1] Object { #822[r1,l2] Name String [1 blocks] "" #535[r9,l1] ... #821[r1,l2] Name String [1 blocks] ""= int 80 #825[r1,l2] Name String [2 blocks] "" #828[r1,l1] Object { #827[r1,l2] Name String [1 blocks] "" #826[r1,l1] String [3 blocks] "tingspeak.com" } #938[r1,l2] Name String [1 blocks] "" #863[r1,l1] String [6 blocks] "/update?key=UN3U6J51X72NCG18&field1=28" #733[r1,l2] Name String [2 blocks] "" #776[r1,l1] String [1 blocks] "GET" } #640[r1,l2] Name String [1 blocks] "" undefined #637[r1,l2] Name String [1 blocks] ""= int 74 } #748[r1,l2] Name Integer 120 #762[r1,l1] Object { #759[r1,l2] Name String [2 blocks] "" #660[r9,l1] ... #750[r1,l2] Name String [1 blocks] ""= int 1 #751[r1,l2] Name String [2 blocks] "" #927[r1,l1] Function { #923[r1,l2] Name Param "" undefined #829[r1,l2] Name String [1 blocks] "" #924[r1,l1] String [37 blocks] "{print(\"get callback!\");a.on(\"data\",function(a){console.log(\"connection getdata:\");console.log(process.memory());console.log(E.getSizeOf(global,1));print(a)});a.on(\"close\",function(){print(\"The response connection closed\");console.log(\"connection close\");console.log(process.memory())})}" #774[r1,l2] Name String [1 blocks] "" #628[r1,l1] Function { #520[r1,l2] Name Param "" #488[r176,l1] ... #398[r1,l2] Name String [2 blocks] "" undefined } #772[r1,l2] Name String [1 blocks] ""= int 6 } #747[r1,l2] Name String [1 blocks] "" #765[r1,l1] Object { #764[r1,l2] Name String [2 blocks] "" #649[r176,l1] ... } #746[r1,l2] Name String [1 blocks] "" #967[r1,l1] Object { #943[r1,l2] Name String [1 blocks] "" #535[r9,l1] ... #942[r1,l2] Name String [1 blocks] ""= int 80 #947[r1,l2] Name String [2 blocks] "" #952[r1,l1] Object { #951[r1,l2] Name String [1 blocks] "" #950[r1,l1] String [3 blocks] "tingspeak.com" } #920[r1,l2] Name String [1 blocks] "" #769[r1,l1] String [6 blocks] "/update?key=UN3U6J51X72NCG18&field1=28" #771[r1,l2] Name String [2 blocks] "" #773[r1,l1] String [1 blocks] "GET" } #663[r1,l2] Name String [1 blocks] "" undefined #629[r1,l2] Name String [1 blocks] ""= int 121 } #703[r1,l2] Name Integer 148 #710[r1,l1] Object { #708[r1,l2] Name String [2 blocks] "" #660[r9,l1] ... #705[r1,l2] Name String [1 blocks] ""= int 1 #706[r1,l2] Name String [2 blocks] "" #977[r1,l1] Function { #970[r1,l2] Name Param "" undefined #897[r1,l2] Name String [1 blocks] "" #972[r1,l1] String [37 blocks] "{print(\"get callback!\");a.on(\"data\",function(a){console.log(\"connection getdata:\");console.log(process.memory());console.log(E.getSizeOf(global,1));print(a)});a.on(\"close\",function(){print(\"The response connection closed\");console.log(\"connection close\");console.log(process.memory())})}" #896[r1,l2] Name String [1 blocks] "" #568[r1,l1] Function { #329[r1,l2] Name Param "" #488[r176,l1] ... #308[r1,l2] Name String [2 blocks] "" undefined } #893[r1,l2] Name String [1 blocks] ""= int 6 } #702[r1,l2] Name String [1 blocks] "" #734[r1,l1] Object { #725[r1,l2] Name String [2 blocks] "" #649[r176,l1] ... } #693[r1,l2] Name String [1 blocks] "" #1012[r1,l1] Object { #995[r1,l2] Name String [1 blocks] "" #535[r9,l1] ... #993[r1,l2] Name String [1 blocks] ""= int 80 #998[r1,l2] Name String [2 blocks] "" #999[r1,l1] Object { #1004[r1,l2] Name String [1 blocks] "" #1002[r1,l1] String [3 blocks] "tingspeak.com" } #903[r1,l2] Name String [1 blocks] "" #744[r1,l1] String [6 blocks] "/update?key=UN3U6J51X72NCG18&field1=28" #855[r1,l2] Name String [2 blocks] "" #894[r1,l1] String [1 blocks] "GET" } #524[r1,l2] Name String [1 blocks] "" undefined #510[r1,l2] Name String [1 blocks] ""= int 149 } #633[r1,l2] Name Integer 166 #717[r1,l1] Object { #712[r1,l2] Name String [2 blocks] "" #660[r9,l1] ... #669[r1,l2] Name String [1 blocks] ""= int 1 #698[r1,l2] Name String [2 blocks] "" #1003[r1,l1] Function { #989[r1,l2] Name Param "" undefined #752[r1,l2] Name String [1 blocks] "" #992[r1,l1] String [37 blocks] "{print(\"get callback!\");a.on(\"data\",function(a){console.log(\"connection getdata:\");console.log(process.memory());console.log(E.getSizeOf(global,1));print(a)});a.on(\"close\",function(){print(\"The response connection closed\");console.log(\"connection close\");console.log(process.memory())})}" #743[r1,l2] Name String [1 blocks] "" #573[r1,l1] Function { #865[r1,l2] Name Param "" #488[r176,l1] ... #247[r1,l2] Name String [2 blocks] "" undefined } #741[r1,l2] Name String [1 blocks] ""= int 6 } #625[r1,l2] Name String [1 blocks] "" #737[r1,l1] Object { #735[r1,l2] Name String [2 blocks] "" #649[r176,l1] ... } #623[r1,l2] Name String [1 blocks] "" #1022[r1,l1] Object { #1013[r1,l2] Name String [1 blocks] "" #535[r9,l1] ... #1011[r1,l2] Name String [1 blocks] ""= int 80 #1016[r1,l2] Name String [2 blocks] "" #1017[r1,l1] Object { #1019[r1,l2] Name String [1 blocks] "" #1018[r1,l1] String [3 blocks] "tingspeak.com" } #355[r1,l2] Name String [1 blocks] "" #758[r1,l1] String [6 blocks] "/update?key=UN3U6J51X72NCG18&field1=28" #740[r1,l2] Name String [2 blocks] "" #742[r1,l1] String [1 blocks] "GET" } #397[r1,l2] Name String [1 blocks] "" undefined #375[r1,l2] Name String [1 blocks] ""= int 167 } #229[r1,l2] Name Integer 167 #237[r1,l1] Object { #235[r1,l2] Name String [2 blocks] "" #660[r9,l1] ... #231[r1,l2] Name String [1 blocks] ""= int 1 #233[r1,l2] Name String [2 blocks] "" #616[r1,l1] Function { #288[r1,l2] Name Param "" undefined #248[r1,l2] Name String [1 blocks] "" #394[r1,l1] String [37 blocks] "{print(\"get callback!\");a.on(\"data\",function(a){console.log(\"connection getdata:\");console.log(process.memory());console.log(E.getSizeOf(global,1));print(a)});a.on(\"close\",function(){print(\"The response connection closed\");console.log(\"connection close\");console.log(process.memory())})}" #246[r1,l2] Name String [1 blocks] "" #864[r1,l1] Function { #374[r1,l2] Name Param "" #488[r176,l1] ... #239[r1,l2] Name String [2 blocks] "" undefined } #244[r1,l2] Name String [1 blocks] ""= int 6 } #226[r1,l2] Name String [1 blocks] "" #241[r1,l1] Object { #240[r1,l2] Name String [2 blocks] "" #649[r176,l1] ... } #225[r1,l2] Name String [1 blocks] "" #399[r1,l1] Object { #595[r1,l2] Name String [1 blocks] "" #535[r9,l1] ... #596[r1,l2] Name String [1 blocks] ""= int 80 #579[r1,l2] Name String [2 blocks] "" #575[r1,l1] Object { #469[r1,l2] Name String [1 blocks] "" #574[r1,l1] String [3 blocks] "tingspeak.com" } #298[r1,l2] Name String [1 blocks] "" #401[r1,l1] String [6 blocks] "/update?key=UN3U6J51X72NCG18&field1=28" #243[r1,l2] Name String [2 blocks] "" #245[r1,l1] String [1 blocks] "GET" } #440[r1,l2] Name String [1 blocks] "" undefined #463[r1,l2] Name String [1 blocks] ""= int 168 } #470[r1,l2] Name Integer 172 #522[r1,l1] Object { #511[r1,l2] Name String [2 blocks] "" #660[r9,l1] ... #485[r1,l2] Name String [1 blocks] ""= int 1 #486[r1,l2] Name String [2 blocks] "" #736[r1,l1] Function { #682[r1,l2] Name Param "" undefined #567[r1,l2] Name String [1 blocks] "" #695[r1,l1] String [37 blocks] "{print(\"get callback!\");a.on(\"data\",function(a){console.log(\"connection getdata:\");console.log(process.memory());console.log(E.getSizeOf(global,1));print(a)});a.on(\"close\",function(){print(\"The response connection closed\");console.log(\"connection close\");console.log(process.memory())})}" #566[r1,l2] Name String [1 blocks] "" #610[r1,l1] Function { #347[r1,l2] Name Param "" #488[r176,l1] ... #305[r1,l2] Name String [2 blocks] "" undefined } #558[r1,l2] Name String [1 blocks] ""= int 6 } #468[r1,l2] Name String [1 blocks] "" #554[r1,l1] Object { #553[r1,l2] Name String [2 blocks] "" #649[r176,l1] ... } #467[r1,l2] Name String [1 blocks] "" #1001[r1,l1] Object { #861[r1,l2] Name String [1 blocks] "" #535[r9,l1] ... #856[r1,l2] Name String [1 blocks] ""= int 80 #969[r1,l2] Name String [2 blocks] "" #980[r1,l1] Object { #984[r1,l2] Name String [1 blocks] "" #982[r1,l1] String [3 blocks] "tingspeak.com" } #380[r1,l2] Name String [1 blocks] "" #379[r1,l1] String [6 blocks] "/update?key=UN3U6J51X72NCG18&field1=28" #557[r1,l2] Name String [2 blocks] "" #565[r1,l1] String [1 blocks] "GET" } #361[r1,l2] Name String [1 blocks] "" undefined #357[r1,l2] Name String [1 blocks] ""= int 173 } #453[r1,l2] Name Integer 173 #392[r1,l1] Object { #512[r1,l2] Name String [2 blocks] "" #660[r9,l1] ... #351[r1,l2] Name String [1 blocks] ""= int 1 #405[r1,l2] Name String [2 blocks] "" #300[r1,l1] Function { #336[r1,l2] Name Param "" undefined #29[r1,l2] Name String [1 blocks] "" #337[r1,l1] String [37 blocks] "{print(\"get callback!\");a.on(\"data\",function(a){console.log(\"connection getdata:\");console.log(process.memory());console.log(E.getSizeOf(global,1));print(a)});a.on(\"close\",function(){print(\"The response connection closed\");console.log(\"connection close\");console.log(process.memory())})}" #28[r1,l2] Name String [1 blocks] "" #472[r1,l1] Function { #307[r1,l2] Name Param "" #488[r176,l1] ... #339[r1,l2] Name String [2 blocks] "" undefined } #24[r1,l2] Name String [1 blocks] ""= int 6 } #402[r1,l2] Name String [1 blocks] "" #16[r1,l1] Object { #344[r1,l2] Name String [2 blocks] "" #649[r176,l1] ... } #299[r1,l2] Name String [1 blocks] "" #364[r1,l1] Object { #403[r1,l2] Name String [1 blocks] "" #535[r9,l1] ... #455[r1,l2] Name String [1 blocks] ""= int 80 #389[r1,l2] Name String [2 blocks] "" #388[r1,l1] Object { #385[r1,l2] Name String [1 blocks] "" #386[r1,l1] String [3 blocks] "tingspeak.com" } #466[r1,l2] Name String [1 blocks] "" #362[r1,l1] String [6 blocks] "/update?key=UN3U6J51X72NCG18&field1=28" #20[r1,l2] Name String [2 blocks] "" #27[r1,l1] String [1 blocks] "GET" } #701[r1,l2] Name String [1 blocks] "" undefined #699[r1,l2] Name String [1 blocks] ""= int 174 } #564[r1,l2] Name Integer 174 #691[r1,l1] Object { #692[r1,l2] Name String [2 blocks] "" #660[r9,l1] ... #689[r1,l2] Name String [1 blocks] ""= int 1 #1010[r1,l2] Name String [2 blocks] "" #359[r1,l1] Function { #358[r1,l2] Name Param "" undefined #674[r1,l2] Name String [1 blocks] "" #716[r1,l1] String [37 blocks] "{print(\"get callback!\");a.on(\"data\",function(a){console.log(\"connection getdata:\");console.log(process.memory());console.log(E.getSizeOf(global,1));print(a)});a.on(\"close\",function(){print(\"The response connection closed\");console.log(\"connection close\");console.log(process.memory())})}" #675[r1,l2] Name String [1 blocks] "" #384[r1,l1] Function { #396[r1,l2] Name Param "" #488[r176,l1] ... #346[r1,l2] Name String [2 blocks] "" undefined } #680[r1,l2] Name String [1 blocks] ""= int 6 } #561[r1,l2] Name String [1 blocks] "" #684[r1,l1] Object { #685[r1,l2] Name String [2 blocks] "" #649[r176,l1] ... } #542[r1,l2] Name String [1 blocks] "" #688[r1,l1] Object { #338[r1,l2] Name String [1 blocks] "" #535[r9,l1] ... #367[r1,l2] Name String [1 blocks] ""= int 80 #539[r1,l2] Name String [2 blocks] "" #1023[r1,l1] Object { #582[r1,l2] Name String [1 blocks] "" #583[r1,l1] String [3 blocks] "tingspeak.com" } #350[r1,l2] Name String [1 blocks] "" #349[r1,l1] String [6 blocks] "/update?key=UN3U6J51X72NCG18&field1=28" #681[r1,l2] Name String [2 blocks] "" #679[r1,l1] String [1 blocks] "GET" } #376[r1,l2] Name String [1 blocks] "" undefined #287[r1,l2] Name String [1 blocks] ""= int 175 #484[r1,l2] Name String [1 blocks] "" #387[r1,l1] String [37 blocks] "HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nConnection: close\r\nStatus: 200 OK\r\nX-Frame-Options: ALLOWALL\r\nAccess-Control-Allow-Origin: *\r\nAccess-Control-Allow-Methods: GET, POST, PUT, OPTIONS, DELETE, PATCH\r\nAccess-Control-Allow-Headers: origin, content-type, X-R\nETag: \"e=0, pri" } ] } #26[r1,l2] Name String [2 blocks] "" #36[r2,l1] NativeFunction 0x40222ac4 (0) { } #220[r1,l2] Name String [1 blocks] "" #219[r1,l1] String [2 blocks] "hygywlanpbj" #217[r1,l2] Name String [1 blocks] "" #216[r1,l1] String [2 blocks] "nEgrO111" #214[r1,l2] Name String [2 blocks] "" #212[r1,l1] String [3 blocks] "UN3U6J51X72NCG18" #209[r1,l2] Name String [1 blocks] ""= int 30 #208[r1,l2] Name String [2 blocks] "" #206[r1,l1] String [3 blocks] "thingspeak.com" #203[r1,l2] Name String [2 blocks] "" #535[r9,l1] String [3 blocks] "144.212.80.10" #200[r1,l2] Name String [2 blocks] "" #187[r1,l1] Pin 2 #197[r1,l2] Name String [1 blocks] "" #198[r2,l1] NativeFunction 0x402335e0 (9) { #195[r1,l2] Name String [2 blocks] "" #193[r1,l1] Object { #192[r1,l2] Name String [2 blocks] "" #198[r2,l2] ... } } #196[r1,l2] Name String [2 blocks] "" #363[r1,l1] Bool false #189[r1,l2] Name String [1 blocks] "" #185[r2,l1] NativeFunction 0x40222b34 (0) { } #188[r1,l2] Name String [2 blocks] "" #488[r176,l1] Double 28 #183[r1,l2] Name String [2 blocks] "" #181[r1,l1] Function { #168[r1,l2] Name String [1 blocks] "" #180[r1,l1] String [12 blocks] "{print(\"startBlink\");setInterval(function(){toggle=!toggle;digitalWrite(GPIO2,toggle)},500)}" #166[r1,l2] Name String [1 blocks] ""= int 4 } #167[r1,l2] Name String [3 blocks] "" #163[r1,l1] Function { #118[r1,l2] Name String [1 blocks] "" #162[r1,l1] String [44 blocks] "{console.log(\"connecting to wifi\");digitalWrite(GPIO2,1);ESP8266WiFi.init();ESP8266WiFi.connect(ssid,pass,function(){digitalWrite(GPIO2,0);console.log(\"connected to wifi\");\nvar a=ESP8266WiFi.getIPInfo();print(\"Current IP address is: \"+ESP8266WiFi.getAddressAsString(a.ip)+\":\"+ESP8266WiFi.getAddressAsString(a.netmask));resolveIotAddress(repeat)})}" #116[r1,l2] Name String [1 blocks] ""= int 4 } #117[r1,l2] Name String [3 blocks] "" #113[r1,l1] Function { #112[r1,l2] Name Param "" undefined #92[r1,l2] Name String [1 blocks] "" #111[r1,l1] String [19 blocks] "{ESP8266.getHostByName(iotHostName,function(b){iotIpAddr=ESP8266.getAddressAsString(b);console.log(\"resolved:\"+iotIpAddr);startBlink();a()})}" #90[r1,l2] Name String [1 blocks] ""= int 5 } #91[r1,l2] Name String [2 blocks] "" #88[r1,l1] Function { #87[r1,l2] Name Param "" undefined #415[r1,l2] Name String [1 blocks] "" #86[r1,l1] String [59 blocks] "{console.log(\"sendTsStart\");console.log(process.memory());http.get({host:iotIpAddr,port:80,headers:{Host:\"tingspeak.com\"},path:\"/update?key=\"+\nApiKey+\"&field1=\"+a},function(a){print(\"get callback!\");a.on(\"data\",function(a){console.log(\"connection getdata:\");console.log(process.memory());console.log(E.getSizeOf(global,1));print(a)});a.on(\"close\",function(){print(\"The response connection closed\");console.log(\"connection close\");console.log(process.memory())})})}" #417[r1,l2] Name String [1 blocks] ""= int 5 } #416[r1,l2] Name String [3 blocks] "" #420[r1,l1] Function { #421[r1,l2] Name Param "" undefined #428[r1,l2] Name String [1 blocks] "" #422[r1,l1] String [6 blocks] "{console.log(\"current temp:\"+a);sendTs(a)}" #430[r1,l2] Name String [1 blocks] ""= int 6 } #429[r1,l2] Name String [2 blocks] "" #432[r2,l1] Function { #439[r1,l2] Name String [1 blocks] "" #433[r1,l1] String [6 blocks] "{sendTs(field1);setTimeout(repeat,1E3*peri)}" #441[r1,l2] Name String [1 blocks] ""= int 6 } #456[r1,l2] Name String [1 blocks] "" #457[r1,l1] NativeFunction 0x40222c34 (1) { #480[r1,l2] Name String [2 blocks] "" #452[r1,l1] Function { #479[r1,l2] Name String [1 blocks] "" #451[r1,l1] String [14 blocks] "{field1=1+Math.floor(40*Math.random());console.log(\"created new random number:\"+field1);connectToWifi()}" } } #489[r1,l2] Name String [1 blocks] "" #490[r1,l1] NativeFunction 0x40222b84 (1) { } #491[r1,l2] Name String [2 blocks] "" #501[r1,l1] NativeFunction 0x40222c14 (1) { } #506[r1,l2] Name String [2 blocks] "" #507[r1,l1] NativeFunction 0x40222aa0 (1) { } #502[r1,l2] Name String [2 blocks] "" undefined #559[r1,l2] Name String [2 blocks] "" #551[r1,l1] NativeFunction 0x40222bb4 (1) { } #644[r1,l2] Name String [2 blocks] "" #646[r2,l1] NativeFunction 0x40222ae4 (1) { #647[r1,l2] Name String [2 blocks] "" #649[r176,l1] Object { #650[r1,l2] Name String [2 blocks] "" #646[r2,l2] ... } } #655[r1,l2] Name String [2 blocks] "" #657[r2,l1] NativeFunction 0x40222af4 (1) { #658[r1,l2] Name String [2 blocks] "" #660[r9,l1] Object { #661[r1,l2] Name String [2 blocks] "" #657[r2,l2] ... } } #694[r1,l2] Name String [1 blocks] "" #321[r1,l1] NativeFunction 0x40222c04 (1) { } } ets Jan 8 2013,rst cause:2, boot mode:(3,0) load 0x40100000, len 30936, room 16 tail 8 chksum 0x75 load 0x3ffe8000, len 2108, room 0 tail 12 chksum 0x34 ho 0 tail 12 room 4 load 0x3ffe8840, len 29476, room 12 tail 8 chksum 0x15 csum 0x15 don't use rtc mem data Disconnected
-
-
-
Wooo I write this in the console:
what is that: ----> "ÿ"
>E.getSizeOf(global, 1) =[ { "name": "ÿ", "size": 354 }, { "name": "Modules", "size": 3 }, { "name": "ssid", "size": 3 }, { "name": "pass", "size": 3 }, { "name": "ApiKey", "size": 5 }, ... { "name": "Restart", "size": 2 }, { "name": "process", "size": 3 }, { "name": "httpCRs", "size": 8 }, { "name": "httpCRq", "size": 8 }, { "name": "JSON", "size": 2 } ] >
-
@Gordon it is running some time, whitout problem, then it dies. When this happens, i reset the board, the problem will be the same exactyl, then I try to plug and unplug the board from the usb port but it is wrong. So I send the saved code to esp8266 again with the espruino ide, then save() it, after that it is working.
I'll try tu put the given code lines to have more debug messages.
But I think there is stg wrong with the http get module, maybe the esp8266 implementation is buggy somewhere.
-
Here is the modified ds18b20 code. It uses a callback when the temperature is ready.
/* Copyright (c) 2013 Gordon Williams, Pur3 Ltd. See the file LICENSE for copying permission. */ /* Modified by HyGy */ /* Module for the DS18B20 temperature sensor */ var C = { CONVERT_T: 0x44, COPY: 0x48, READ: 0xBE, WRITE: 0x4E }; function DS18B20(oneWire, device) { this.bus = oneWire; if (device === undefined) { this.sCode = this.bus.search()[0]; } else { if (parseInt(device).toString() == device && device >= 0 && device <= 126) { this.sCode = this.bus.search()[device]; } else { this.sCode = device; } } this.deviceTypeCode=parseInt(this.sCode[0]+this.sCode[1]); } /** For internal use - read the scratchpad region */ DS18B20.prototype._readSpad = function(convert_t) { var spad = []; this.bus.reset(); this.bus.select(this.sCode); convert_t=false; if (convert_t) { this.bus.write(C.CONVERT_T, true); this.bus.reset(); this.bus.select(this.sCode); } this.bus.write(C.READ); for (var i = 0; i < 9; i++) { spad.push(this.bus.read()); } return spad; }; /** For internal use - write the scratchpad region */ DS18B20.prototype._writeSpad = function(th, tl, conf) { this.bus.reset(); this.bus.select(this.sCode); this.bus.write(C.WRITE); this.bus.write(th); this.bus.write(tl); this.bus.write(conf); this.bus.reset(); this.bus.select(this.sCode); this.bus.write(C.COPY); this.bus.reset(); }; /** Set the resolution in bits. From 8 to 12 bits */ DS18B20.prototype.setRes = function(res) { var spad = this._readSpad(); res = [0x1F, 0x3F, 0x5F, 0x7F][E.clip(res, 9, 12) - 9]; this._writeSpad(spad[2], spad[3], res); }; /** Return the resolution in bits. From 8 to 12 bits */ DS18B20.prototype.getRes = function() { return [0x1F, 0x3F, 0x5F, 0x7F].indexOf(this._readSpad()[4]) + 9; }; /** Return true if this device is present */ DS18B20.prototype.isPresent = function() { return this.bus.search().indexOf(this.sCode) !== -1; }; /** Get a temperature reading, in degrees C */ DS18B20.prototype.getTempOld = function(verify) { var spad = null; var temp = null; if ((verify && !this.isPresent()) || !this.sCode) { return temp; } spad = this._readSpad(true); temp = spad[0] + (spad[1] << 8); if (temp > 32767) { temp -= 65536; } temp = temp / 16.0; return temp; }; DS18B20.prototype.getTemp = function(callback) { var me=this; var temp=null; var spad=null; ow.reset(); ow.select(this.sCode); ow.write(C.CONVERT_T, true); setTimeout( function() { var s = sensor._readSpad(false); var str=""; s.forEach( function(v) { str+=" 0x"+v.toString(16); } ); var temp = s[0] + (s[1]<<8); if (temp > 32767) temp -= 65536; switch (me.deviceTypeCode) { case 10: temp = temp/2.0; break; default: temp = temp/16; break; } callback(temp); }, 1000); } /** Return a list of all DS18B20 sensors with the alarms set */ DS18B20.prototype.searchAlarm = function() { return this.bus.search(0xEC); }; /** Set alarm low and high values in degrees C - see DS18B20.prototype.searchAlarm. If the temperature goes below `lo` or above `hi` the alarm will be set. */ DS18B20.prototype.setAlarm = function(lo, hi) { lo--; // DS18B20 alarms if (temp<=lo || temp>hi), but we want (temp<lo || temp>hi) if (lo < 0) lo += 256; if (hi < 0) hi += 256; var spad = this._readSpad(); this._writeSpad(hi, lo, spad[4]); }; /** Initialise a DS18B20 device. Use either as: connect(new OneWire(pin)) - use the first found DS18B20 device connect(new OneWire(pin), N) - use the Nth DS18B20 device connect(new OneWire(pin), ID) - use the DS18B20 device with the given ID */ exports.connect = function(oneWire, device) { return new DS18B20(oneWire, device); };
-
Hi,
I have some memory problems with a js code.
I connect to wifi, resolve an ip addr, connect to onewire, get the ds18s20 sensor data, and every minutes it sends the data to thingspeak.
For a while (what is sometimes 5-10 horus, sometimes less), I got this (it disconnect from espruino ide, and I need to reconnect):
The response connection closed connection close { "free": 107, "usage": 916, "total": 1023, "history": 1 } > Disconnected > Connected >)ü =undefined > =undefined current temp:25.5 sendTsStart { "free": 213, "usage": 810, "total": 1023, "history": 17 } ERROR: Out of Memory! WARNING: Unable to create string as not enough memory WARNING: Out of memory while appending to array Execution Interrupted current temp:25.5 sendTsStart { "free": 212, "usage": 811, "total": 1023, "history": 1 } WARNING: Unable to create string as not enough memory WARNING: Out of memory while appending to array Execution Interrupted
Here is the code:
require("ESP8266").logDebug(false); var ssid = "ssid"; var pass = "pass"; var ApiKey = 'apikey'; var peri = 60; //period of reading sensor in sec. var iotHostName="thingspeak.com"; var iotIpAddr=""; var GPIO0 = new Pin(12); // GPIO0 | ~D3 port var ow = new OneWire(GPIO0); var sensor = require("DS18S20").connect(ow); var GPIO2 = new Pin(2); // internal led var toggle=1; var startBlink = function() { print("startBlink"); setInterval(function() { toggle=!toggle; digitalWrite(GPIO2, toggle); }, 500); }; var connectToWifi = function() { console.log('connecting to wifi'); var GPIO2 = new Pin(2); digitalWrite(GPIO2, 1); ESP8266WiFi.init(); ESP8266WiFi.connect(ssid, pass, function() { digitalWrite(GPIO2, 0); console.log('connected to wifi'); var ipInfo = ESP8266WiFi.getIPInfo(); print("Current IP address is: " + ESP8266WiFi.getAddressAsString(ipInfo.ip) + ':' + ESP8266WiFi.getAddressAsString(ipInfo.netmask)); resolveIotAddress(repeat); }); }; var resolveIotAddress= function(callback) { var ESP8266 = require("ESP8266"); ESP8266.getHostByName(iotHostName, function(address) { iotIpAddr = ESP8266.getAddressAsString(address); console.log('resolved:' + iotIpAddr); startBlink(); callback(); }); }; var sendTs = function(temp) { console.log('sendTsStart'); console.log(process.memory()); var http = require("http"); http.get({ host: iotIpAddr, port: 80, headers: { 'Host': 'tingspeak.com', }, path: '/update?key=' + ApiKey + '&field1=' + temp }, function(response) { print("get callback!"); response.on('data', function(data) { console.log('connection getdata:'); console.log(process.memory()); print(data); }); response.on('close', function() { print("The response connection closed"); console.log('connection close'); console.log(process.memory()); }); } ); }; var sendTemperature = function(temp) { console.log('current temp:' + temp); // var field2 = 1 + Math.floor(Math.random() * 40); sendTs(temp); }; repeat = function() { //var field1 = 1 + Math.floor(Math.random() * 40); // var field2 = 1 + Math.floor(Math.random() * 40); // sendTs(field1, field2); sensor.getTemp(sendTemperature); setTimeout(repeat, peri * 1000); }; E.on('init', function() { connectToWifi(); });
The smallest value what I get, is the response in the sendTs function in respons.on data part:
{ "free": 17, "usage": 1006, "total": 1023, "history": 1 }
1331I used a changed ds18b20 library to support ds18s20. I send it in the next post.
thanks,
HyGy -
At the weekend I changed a little bit the ds18b20 code: Now it works for me with ds18s20 too, and it waits for 1 sec to a conversation and then calls a given callback.
It's based on @tve modification.
var C = { CONVERT_T: 0x44, COPY: 0x48, READ: 0xBE, WRITE: 0x4E }; function DS18B20(oneWire, device) { this.bus = oneWire; if (device === undefined) { this.sCode = this.bus.search()[0]; } else { if (parseInt(device).toString() == device && device >= 0 && device <= 126) { this.sCode = this.bus.search()[device]; } else { this.sCode = device; } } this.deviceTypeCode=parseInt(this.sCode[0]+this.sCode[1]); } /** For internal use - read the scratchpad region */ DS18B20.prototype._readSpad = function(convert_t) { var spad = []; this.bus.reset(); this.bus.select(this.sCode); convert_t=false; if (convert_t) { this.bus.write(C.CONVERT_T, true); this.bus.reset(); this.bus.select(this.sCode); } this.bus.write(C.READ); for (var i = 0; i < 9; i++) { spad.push(this.bus.read()); } return spad; }; /** For internal use - write the scratchpad region */ DS18B20.prototype._writeSpad = function(th, tl, conf) { this.bus.reset(); this.bus.select(this.sCode); this.bus.write(C.WRITE); this.bus.write(th); this.bus.write(tl); this.bus.write(conf); this.bus.reset(); this.bus.select(this.sCode); this.bus.write(C.COPY); this.bus.reset(); }; /** Set the resolution in bits. From 8 to 12 bits */ DS18B20.prototype.setRes = function(res) { var spad = this._readSpad(); res = [0x1F, 0x3F, 0x5F, 0x7F][E.clip(res, 9, 12) - 9]; this._writeSpad(spad[2], spad[3], res); }; /** Return the resolution in bits. From 8 to 12 bits */ DS18B20.prototype.getRes = function() { return [0x1F, 0x3F, 0x5F, 0x7F].indexOf(this._readSpad()[4]) + 9; }; /** Return true if this device is present */ DS18B20.prototype.isPresent = function() { return this.bus.search().indexOf(this.sCode) !== -1; }; /** Get a temperature reading, in degrees C */ DS18B20.prototype.getTempOld = function(verify) { var spad = null; var temp = null; if ((verify && !this.isPresent()) || !this.sCode) { return temp; } spad = this._readSpad(true); temp = spad[0] + (spad[1] << 8); if (temp > 32767) { temp -= 65536; } temp = temp / 16.0; return temp; }; DS18B20.prototype.getTemp = function(callback) { var me=this; var temp=null; var spad=null; ow.reset(); ow.select(this.sCode); ow.write(C.CONVERT_T, true); setTimeout( function() { var s = sensor._readSpad(false); var str=""; s.forEach( function(v) { str+=" 0x"+v.toString(16); } ); var temp = s[0] + (s[1]<<8); if (temp > 32767) temp -= 65536; switch (me.deviceTypeCode) { case 10: temp = temp/2.0; break; default: temp = temp/16; break; } callback(temp); }, 1000); } /** Return a list of all DS18B20 sensors with the alarms set */ DS18B20.prototype.searchAlarm = function() { return this.bus.search(0xEC); }; /** Set alarm low and high values in degrees C - see DS18B20.prototype.searchAlarm. If the temperature goes below `lo` or above `hi` the alarm will be set. */ DS18B20.prototype.setAlarm = function(lo, hi) { lo--; // DS18B20 alarms if (temp<=lo || temp>hi), but we want (temp<lo || temp>hi) if (lo < 0) lo += 256; if (hi < 0) hi += 256; var spad = this._readSpad(); this._writeSpad(hi, lo, spad[4]); }; /** Initialise a DS18B20 device. Use either as: connect(new OneWire(pin)) - use the first found DS18B20 device connect(new OneWire(pin), N) - use the Nth DS18B20 device connect(new OneWire(pin), ID) - use the DS18B20 device with the given ID */ exports.connect = function(oneWire, device) { return new DS18B20(oneWire, device); };
-
-
@Kolban If U give me a documentation where can U found this gitter stream, I use it then to help you. Its like google hangouts?
-
@Kolban thanks. Can U check the ds18s20 problem too?
Is it corrected now? I still get negative values.