i have been playing around with the RuuviTag using the Espruino firmware. After saving a script into flash memory, the tag started to report odd Data, ( Ruuvitag.getEnvData()
={ “temp”: -138.56340314587, “pressure”: 1197.21111857997, “humidity”: 0 }
)
Initially, i was able to reset the tag by re-upoading the firmware, but the same data was sent again after a few more script tests. Assuming an error in the Espruino firmware, i proceeded to flash the Weatherstation firmware back on to the tag, but now all i get is #BDwWAMc4n as encoded data, which decodes to Temp 0, humidity NaN, Pressure 0A50000 when i decode it myself, while the Ruuvi page delivers results of 22/72 degrees, 30% humidity and 1010 hPa pressure.
Interestingly enough, the JS code i uploaded to the tag survives reflashing the firmware. This leaves me with a few questions :
Did i manage to break the tag by saving garbage to the flash memory ? If not,
How do i clear the JS code from the device ?
How do i reset the Tag so that the Weatherstation will report correct data again ?
The Espruino saves javascript to flash, and the Weather Station firmware does not erase the Espruino data files by default. However, the weather station does not use any Espruino code.
My best guess is that the environmental sensor BME280 is somehow misconfigured. As the BME280 retains the configuration as long as power is on, you could try removing the battery, waiting a few seconds and reconnecting the battery.
thank you for the quick response. Unfortunately, powering down does not change anything. I left the tag without battery over the weekend but still had the same situation this morning.
Thank you for the details. Could you please paste here or PM me the Espruino code you used? I’ll try to replicate the problem and see if I can find a fix for it.
My best guess is that this is caused by initializing "Var Ruuvitag = require("RuuviTag) in the start, which does not get called in onInit(). However this is just a guess. I hope this helps.
thank you very much for the help. I have been caught in the “german special letter” trap, it seems. I never checked the comments, just the code for odd issues but didn’t find a thing.
I have tried a number of things. Unfortunately all without success. Here is what i have tried:
If i upload code and run it without saving, it works (correct data)
If i upload code and save it, it does not work right away, (incorrect data) and state remains that way until i upload new code. Interestingly enough, if i flash the original weather station code back onto the tag, the data is still wrong.
i tried to move the require(“Ruuvitag”) into the onInit function - no change.
i moved the initialisation into a function which is called with a 20 second delay to stave off any init timing issues - no change.
I stripped the code to a bare minimum (see below) - still, wrong read after save.
If i upload an empty program (literally no single line of code) using the Espruino IDE and then save it, the error disappears and i can at least use the weatherstation firmware on the tag.
This has me both puzzled (as to why the tag keeps reporting wrong data even after reflashing the original weather station firmware), and in a bind - i want to use the tag as stand alone data logger which i can on demand query via Bluetooth. As it stands now, i am convinced that JS (Espruino) is not a good way to go but i am also not certain how to develop a working firmware which provides the desired functionality.
Do you have any suggestion which way to go / which compiler / set of libraries to use to get there ?
A.
Stripped down code :
function ReadRuuvidata(tag)
{
var temp = tag.getEnvData().temp;
console.log("read ", temp);
}
function onInit()
{
var Ruuvitag = require("Ruuvitag");
Ruuvitag.setEnvOn(true);
Interval = setInterval(ReadRuuvidata, 1000, Ruuvitag);
console.log("Interval set: ", Interval);
return 1;
}
Logging data and querying it over bluetooth is a common need and we’re working towards it, however it will take some time (months) before we have an example application ready.
Some options for you:
Arduino is working on Arduino Primo Core, which runs on nRF52, and Arduino drivers for BME280 exists. We’ll support Arduino on RuuviTag if possible.
If you’re comfortable with C, you could fork https://github.com/ojousima/ruuvitag_fw/tree/feature-webble/ruuvi_examples/web-bluetooth and do following things: Implement environment_callback() in application.c which would store the measured values and call the callback in BME280 driver timer task when new sample is ready. To send the data out of device you’ll need to fill the ble_ess_s (defined in ble_ess.h) handles with stored values and call the “send”-functions in ble_ess.h with the filled struct as a paramter. You’d also need to implement something to subscribe to the notfications sent by tag.
If you can have a raspberrry pi / other logger nearby at all times, you could use one of the logger libraries presented on the forum.
Again thank you very much for your help. I will take a closer look at the web-bluetooth example and see where i get with that.
Having a logger nearby is no option due to size and Geometry limitations. I assume that i will need the nRF52 SDK to compile the firmware. Do i also need to get wired access to the tag, or can all this be done over Bluetooth ?
Development board is not required for developing RuuviTag firmware, although it helps.
You can compile the code with ARM-GCC by running “make” in $project_folder/ruuvitag_b3/s132/armgcc
You can also create your own DFU packages for flashing with mobile phone, more detailed instructions are on github readme.