and removing the code you have below that also sets those sensors up?
Here's the problem ...
"If I remove the code you have below" it won't run in RAM because the function
onInit() has the device(s) setup code? Only when I do a flash "Save()" will the
function onInit() will run? The problem is ... if the code will not run
in RAM first, it sure will not run in flash by doing a save()?
For your testing, I had to leave in the I2C setup code.
On another very minor issue ...
I believe you put a patch in v66 for Serial1 noise. In v65 by printing to the LCD Serial1.available() nothing happens on the console screen. In v66, leaving
the console connected (USB), I get " a list of "Warning: String buffer overflowed maximum size (512)" when ever I print to the LCD the function "Serial1.available()?
Test code ...
/*
DS18B20 Data Logger
Rev. 1.0b
7/9/14
Espruino: v 1.3: firmware: v 66 WEB-IDE: v 45
Windows 8.1 / Chrome
Hardware: I2C 4x20 LCD, DS18B20, I2C RTC DS3231
Bugs: Memory usage 657 but after a few days increases to 667 ???
Program description:
Uses 1-wire DS18B20 for the temperature sensor.
The DS18B20 temperature is logged along with time/date to SD and LCD.
1 1-wire and 1 I2C bus is used.
Program credits:
SD data logger code snippet was used from an unknown Espruino forum member.
Note: 3.3k pull-ups for I2C LCD/RTC.
*/
var ow,sensor,lcd,rtc;
function onInit(){
ow = new OneWire(A1);
sensor = require("DS18B20").connect(ow);
sensor.setRes(12);
digitalWrite([LED1,LED2,LED3],0b100);
lcd = require("HD44780").connectI2C(I2C1);
I2C1.setup({scl:B8,sda:B9});
lcd.clear();
setTimeout("digitalWrite([LED1,LED2,LED3],0b010);", 1000);
setTimeout("digitalWrite([LED1,LED2,LED3],0b001);", 2000);
setTimeout("digitalWrite([LED1,LED2,LED3],0);", 3000);
// Delay start-up for diagnostics (above) and for LCD clear
I2C1.setup({scl:B8, sda:B9});
rtc = require("DS3231").connect(I2C1);
}
var fs = require('fs');
var testName = "TEST152Q.LOG";
var testDetails = "Data Logging DS18B20 to SD";
var logInterval = 5000;
var logEntry = 0;
var ow = new OneWire(A1);
var sensor = require("DS18B20").connect(ow);
I2C1.setup({scl:B8,sda:B9});
var rtc = require("DS3231").connect(I2C1);
/* Set Dow Time/date - comment out lines out below after first use!
Usage:
rtc.setDow("day of the week") Monday,Tuesday ...
rtc.setDate(date,month,year);1-31,1-12,0-99
rtc.setTime(hours,minutes); Military Time
Set time exactly on minute roll-over (+ 1 min)
*/
//rtc.setDow("Thursday");
//rtc.setDate(26,6,14);
//rtc.setTime(19,25);
I2C1.setup({scl:B8, sda:B9});
var lcd = require("HD44780").connectI2C(I2C1);
lcd.clear();
// Initialise log file here with header information
//console.log(testDetails); <---- do not leave in without USB (will halt)
fs.appendFileSync(testName, testDetails);
// Function to log some data every so often
setInterval(function(){
// Indicate each time function is executed
digitalPulse(LED1, 1, 100);
// Log some data.
logEntry++;
var logString = logEntry + " " + (sensor.getTemp(true)* 1.8 + 32 + " F. ") +
(rtc.readDateTime()) + " " + "\r\n";
// var logString = logEntry + " " + 1234 +
// (rtc.readDateTime()) + " " + "\r\n";
//console.log(logString); <---- do not leave in without USB (will halt)
//console.log(process.memory().usage); <--- do not leave in without USB (will halt)
fs.appendFileSync(testName, logString);
lcd.setCursor(0,0);
lcd.print("DS18B20 Logging ...");
lcd.setCursor(0,1);
// lcd needs a string
lcd.print("TempF: " + new String(sensor.getTemp(true)*1.8 + 32));
//lcd.print("TempF: " + "5678");
lcd.setCursor(0,2);
lcd.print(rtc.readDateTime());
lcd.setCursor(0,3);
lcd.print(new String(process.memory().usage));
lcd.print(" ");
//lcd.print(new String(Serial1.available()));
}, logInterval);
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Here's the problem ...
"If I remove the code you have below" it won't run in RAM because the function
onInit() has the device(s) setup code? Only when I do a flash "Save()" will the
function onInit() will run? The problem is ... if the code will not run
in RAM first, it sure will not run in flash by doing a save()?
For your testing, I had to leave in the I2C setup code.
On another very minor issue ...
I believe you put a patch in v66 for Serial1 noise. In v65 by printing to the LCD Serial1.available() nothing happens on the console screen. In v66, leaving
the console connected (USB), I get " a list of "Warning: String buffer overflowed maximum size (512)" when ever I print to the LCD the function "Serial1.available()?
Test code ...