
I managed to write a piece of code using table stuff, it took over 4k
went back to if/elseif etc , this took over 2k
now back to the not enough memory wall, oh well

Explore... Chat... Share...
kolban wrote:
We find a link at the top called "Documentation" and it seems to have a large "Tutorials and Examples" set of pages.
Could this be what you are looking for?
A program written in JavaScript for Espruino should work just the same on all boards that Espruino works upon.
var ssid = "SSID";
var pass = "Password";
var ApiKey = 'APIKey';
var altitude = 188; // current altitude in m
var mode = 2; //resolution of sensor conversion (0-3)
var afdt = 2; //present numbers after dot
var press = 0; //pressure
var temp = 0; //temperature
var peri = 15; //period of reading sensor in sec.
var cl = 0; // SCL to GPIO0
var da = 2; // SDA to GPIO2
//var bmp = require("BMP085").connect(I2C1, mode);
var http = require("http");
var wifi=require("wifi");
var ESP8266 = require("ESP8266");
print('Connecting to wifi');
wifi.connect(ssid, pass,null, function(err) {
print("Wifi error ", err);
var ipInfo = wifi.getIP();
print("Current IP address is: " +
ESP8266.getAddressAsString(ipInfo.ip) + ':' +
ESP8266.getAddressAsString(ipInfo.netmask));
});
function aftDot(number, ad) //Formatting numbers.
{
return Math.round(number*Math.pow(10,ad))/Math.pow(10,ad);
}
function readBMP() //read BMP85 or BMP180 sensor
{ var bmp = require("BMP085").connect(I2C1, mode);
bmp.getPressure(function(d) {
press = aftDot(bmp.getSeaLevel(d.pressure, altitude) / 100, afdt);
temp = aftDot(d.temperature, afdt);
console.log("\nPressure at sea level: " + press + " hPa");
console.log("Temperature: " + temp + " C");
});
return;
}
function sendTs(press, temp) {
http.get({
host: "184.106.153.149",
port: 80,
path: '/update?key=' + ApiKey + '&field3=' + press + '&field4=' + temp
},
function(response) {
response.on('data', function(data) {
print("Callback :",data);
});
response.on('close', function() {
print("Connection closed");
});
}
);
}
I2C1.setup({
scl: cl,
sda: da
});
function repeat() {
readBMP(), sendTs(press, temp), setTimeout(repeat, peri * 1000);
}
repeat();
>
Pressure at sea level: 1031.26 hPa
Temperature: 21.66 C
Callback : 1262
Connection closed
>
Pressure at sea level: 1031.36 hPa
Temperature: 21.67 C
Callback : 1263
Connection closed
WARNING: Prototype is not an Object, so setting it to {}
ASSERT(!jsvIsStringExt(v)) FAILED AT src/jsvar.c:534
#1[r3,l2] Object {
#2[r1,l2] Name String [1 blocks] "ÿ" #3[r1,l2] Object {
#6[r1,l2] Name String [1 blocks] "net" #4[r1,l3] String [2 blocks] "\x04\x00\x00\x00\x00ÿÿÿ"
#9[r1,l2] Name String [2 blocks] "timers" #11[r2,l2] Array(514) [
#193[r1,l3] Name Integer 512 #935[r1,l2] Object {
#79[r1,l2] Name String [1 blocks] "time"= int 127
#78[r1,l2] Name String [2 blocks] "callback" #332[r2,l3] ...
}
#390[r1,l2] Name Integer 513 #396[r1,l1] Object {
#393[r1,l2] Name String [1 blocks] "time" #394[r1,l1] Integer 45503
#392[r1,l2] Name String [2 blocks] "callback" #421[r1,l1] Function {
#413[r1,l2] Name String [1 blocks] "ÿcod" #420[r1,l1] String [3 blocks] "{b(a.read16(246))}"
#399[r1,l2] Name String [1 blocks] "ÿsco" #415[r1,l1] Array(2) [
#401[r1,l2] Name Integer 0 #564[r17,l1] ...
#400[r1,l2] Name Integer 1 #522[r1,l1] Function {
#426[r1,l2] Name Param "b" #521[r1,l1] Function {
#520[r1,l2] Name Param "c" undefined
#439[r1,l2] Name String [1 blocks] "ÿcod" #519[r1,l1] String [46 blocks] "{a.readRawPressure(function(f){var g=\nMath.round((c-a.ac6)*a.ac5/32768),g=g+Math.round(2048*a.mc/(g+a.md)),e=g-4E3;f=Math.round((f-((4*a.ac1+(a.b2*(e*e>>12)>>11)+(a.ac2*e>>11)<<a.oss)+2>>2))/(a.ac4*(((a.ac3*e>>13)+(a.b1*(e*e>>12)>>16)+2>>2)+32768)>>15)*(5E4>>a.oss))<<1;b({pressure:f+(((f>>8)*(f>>8)*3038>>16)+(-7357*f>>16)+3791>>4),temperature:(g+8)/160})})}"
#427[r1,l2] Name String [1 blocks] "ÿsco" #432[r1,l1] Array(2) [
#429[r1,l2] Name Integer 0 #564[r17,l1] ...
etc....
It takes about 20-25 seconds for home assistant c[…]
I tried to upgrade tof my sonoff basic R2 with the[…]
a problem Perhaps you want to define "Probl[…]
Rebooting your router will not give you a faster I[…]
There are no other notifications from esptool.py i[…]
Using the Arduino IDE, you'll learn how to set up […]
In this project, you will post to Twitter using an[…]
In this project, we will build a water level contr[…]
I guess I'm late, but I had the same problem and f[…]
Last night I received my first D1 Minis for a lear[…]
Although I am aware that this is an old post, I fe[…]