I have an Electric Imp impExplorer Kit and it was running fine until I tried to let it run till failure on batteries to see how long it would last. I’m pulling temperature & humidity from the onboard sensors. Since I plugged it in I now get the following errors:
|2018-05-04 16:08:47 -04:00|[Status]|Device connected| |—|---|—|
|2018-05-04 16:08:48 -04:00|[Device]|ERROR: I2C write error: -1|
|2018-05-04 16:08:48 -04:00|[Device]|ERROR: in _setReg …mp#hts221.device.lib.nut#2.0.1:239|
|2018-05-04 16:08:48 -04:00|[Device]|ERROR: from _getCalibrationVariables …mp#hts221.device.lib.nut#2.0.1:251|
|2018-05-04 16:08:48 -04:00|[Device]|ERROR: from constructor …mp#hts221.device.lib.nut#2.0.1:86|
|2018-05-04 16:08:48 -04:00|[Device]|ERROR: from main device_code:20|
|2018-05-04 16:08:53 -04:00|[Status]|Device disconnected|
Line 20 refers to the I2c initilization:
tempHumid <- HTS221(hardware.i2c89);
Code was running fine and I suspect the power failure caused it. Any toughts on fixing the issue? I’ll try to grab another imp on Monday to validate that the code is not problem.
Here’s the code until the device fails and reboots: #require “HTS221.device.lib.nut:2.0.1” #require “LPS22HB.device.lib.nut:2.0.0” #require “LIS3DH.device.lib.nut:2.0.1” #require “WS2812.class.nut:3.0.0”
//LED variables
spi <- null;
led <- null;
state <- false;
Hello,
I had the same problem a few days ago.
I suppose, that with the last update of the libraries, some initialization parameters the sinxtaxis has changed.
I did see your thread, would you mind posting how do you initialize your HTS221? The setmode configuration that was problematic is done after your temphumid declaration.
Thanks, I tried your code and I get the same results. If looks like if I initiate only the pressure sensor it sometimes works but anytime I initiate the temperature sensor I get the error. I read somewhere else that the I2c bus could blocked.
Any bus lock (generally caused by a transaction aborting midway through a byte) would be cleared by a power cycle. The bus is a shared resource, so if it was locked you’d be unable to talk to any peripherals.
Your code at the top of the thread is not, however, going to show any useful errors. Calling readerror() when there have been no transactions on the bus will return bogus data - nothing has happened so there’s no data to return.
Try this, and tell me what it logs:
// Try to talk to HTS221
hardware.i2c89.configure(CLOCK_SPEED_400_KHZ);
server.log(hardware.i2c89.write(0xbe, "");
Note that if you want long battery life (years) you will need to use deep sleep.
New unit works, I suspect the other one had a manufacturing defect. On top of the I2c issues the readings were weird (68% RH in my house!). This one reads 38% which makes more sense.