Two Argons stuck in safe mode trying to use LIS3DH 3_I2C library

I am new to the particleio components and just starting to experiment with them.

-I am trying to use the 3_I2C.ino example (part of the library included in the Particle Web IDE) to hook a LIS3DH to an Argon.
-The modification I made to the 3_I2C.ino example was to change the variable ‘wire1’ to ‘wire’ (since the example didn’t seem to be working).
-After flashing the Argon, it went into a mode where the status LED is both red and blue in a breathing (I beleive this is safe mode)
-After various attempts to get it out of safe mode by pressing and hold the mode button and rest in various combinations failled, I begin to wonder it the device was damaged and tried it on a second Argon.
-Now I have two Argons stuck in safe mode.

Any suggestion, help, adivce appreciated (please keep in mind I am new to using the Particle IO devices and thus likely missing something obvious).

Thanks.

UPDATE: Interestingly, when I was in safe mode (due to the code), I could not flash, connect or anything else. However, when I purposefully went into safe mode (by holding the mode and Reset together, then releasing the Reset), for the part that was already showing it was in safe mode, then I was able to use the Web IDE to flash the blink example code over my bad code and all is now good (no more safe mode).
Unfortunately, using the same approach on the second Argon, gets it to come out of safe mode for a few seconds, then right back into safe mode. I suspect a more serious issue with this particular Argon since the voltage regulator on this part does not charge the LiPo battery.

Could you post your modified code here and which device OS you are using?
It could be that there is a software update going on. Have both Argons been setup and connected to the Particle Cloud (breathing cyan) at any stage.

1 Like

That would suggest that you flashed some application firmware that required a automatic device OS update (Safe Mode Healing).

That was not the best move as this interrupted the Safe Mode Healing and potentially left the device in some limbo state where it’s harder to get the device out of.

Not necessarily :wink:

Try putting your device(s) into DFU Mode an run CLI 1.40.1 (check via particle --version)

particel flash --usb tinker -v
partucle update -v
particle flash --usb tinker -v

ScruffR, this solved my problem.
Detailing it below for anyone else that might get into this bind.

For ArgonA (the one that won’t charge LiPos)

-Downloaded and installed the CLI (https://docs.particle.io/tutorials/developer-tools/cli/)
I am on Windows 10, so from the search box in the lower left corner of the screen, I type ‘command prompt’ to open a command prompt window

-from the command line ran ‘particle setup’, and logged in
-from command line ‘particle --version’ results in 1.41.0

-plugged the ArgonA into the USB port
-on ArgonA, I held the mode and reset together, released the rest, waited until light turned blinking yellow, released mode button
-from command line ‘particle flash --usb tinker -v
about 20 lines of text finishing with ‘Flash success!’
ArgonA is status light is now breathing cyan (yeah!)

-again on ArgonA, I held the mode and reset together, released the rest, waited until light turned blinking yellow, released mode button
-from command line ‘particle update -v
about 20 lines of text finishing with ‘your device should now restart automatically.’
ArgonA light is initially flashing green, then transitions to breathing cyan

-on ArgonA, I held the mode and reset together, released the rest, waited until light turned blinking yellow, released mode button
-from command line ‘particle flash --usb tinker -v

SUCCESS: I was able to setup the device again, and it is now showing on the particle web IDE. From the web IDE, flashed the Blink demo and the proper LED blinked!!

ArgonA is still unable to charge LiPos, but I am pretty sure that was because the battery from Amazon had the black and red wires backward from the particle documentation. I made the mistake of plugging it into only this Argon before checking the battery wiring. I then swapped the wiring to the JST connector so it matches the particle documentation, and now the Amazon LiPo works and charges fine on the other particle devices. However, it appears the reversed wiring fried the recharging circuitry on this Argon.

Big thanks ScruffR for helping me recover this Argon that I thought was lost forever.
Falconm

1 Like

armor,
Big thanks for responding.

First, before slogging through the explanation I have below, both devices are working again:
One via the method I mentioned in my UPDATE above
One via the method scruffR provided via CLI flash updating
I got the LIS3DH using I2C working by using the code download from the Adafruit website (https://learn.adafruit.com/adafruit-lis3dh-triple-axis-accelerometer-breakout/arduino).
I have abandoned trying to use the LIS3DH I2C examples in the particle library.


Now the answers to your questions:

the device IO version is 1.1.0
both Argons had been setup and connected to the Particle cloud, and had the Blink example successfully flashed from the particle web IDE (during this last week). Breathing cyan at the appropriate times prior to getting locked into safe mode.
The code that sent the two Argons into their locked safe mode was a change to the 3_I2C.ino example (part of the library included in the Particle Web IDE when you search for LIS3DH).
-I changed the variable ‘wire1’ to just ‘wire’ in the three instances it shows up in the code below:

here is the original code from the particle LIS3DH library:

#include "Particle.h"

#include "LIS3DH.h"

// Electron sample to print accelerometer samples to serial using the I2C interface
//
// Does not work on the AssetTracker (use Example 1, which uses SPI, which is how the accelerometer
// is connected on the AssetTracker.
//
// This example as is does not work on other platforms like Photon and P1 because they
// don't have Wire1. They do work with the main I2C interface, Wire, using pins D0 and D1.


SYSTEM_THREAD(ENABLED);

// This sample only uses serial, not data, so cellular is turned off to save data
SYSTEM_MODE(MANUAL);

// Print 10 samples per second to serial
const unsigned long PRINT_SAMPLE_PERIOD = 100;

// Connect the Adafruit LIS3DH breakout
// https://www.adafruit.com/products/2809
// VIN: 3V3
// GND: GND
// SCL: C5 (Electron Wire1)
// SDA: C4 (Electron Wire1)
// INT: WKP
LIS3DHI2C accel(Wire1, 0, WKP);

unsigned long lastPrintSample = 0;

void setup() {
	Serial.begin(9600);

	delay(5000);

	// Make sure you match the same Wire interface in the constructor to LIS3DHI2C to this!
	Wire1.setSpeed(CLOCK_SPEED_100KHZ);
	Wire1.begin();

	// Initialize sensor
	LIS3DHConfig config;
	config.setAccelMode(LIS3DH::RATE_100_HZ);

	bool setupSuccess = accel.setup(config);
	Serial.printlnf("setupSuccess=%d", setupSuccess);
}

void loop() {

	if (millis() - lastPrintSample >= PRINT_SAMPLE_PERIOD) {
		lastPrintSample = millis();

		LIS3DHSample sample;
		if (accel.getSample(sample)) {
			Serial.printlnf("%d,%d,%d", sample.x, sample.y, sample.z);
		}
		else {
			Serial.println("no sample");
		}
	}
}

Thanks again armor.

You are using the library LIS3DH with Wire1 for the Electron not the Argon. For the Argon the Wire1 are different. The reference sheet shows this:

Additionally, on the Argon and Xenon, there a second I2C port that can be used with the Wire1 object:

  • SCL => D3
  • SDA => D2

Note : Because there are multiple I2C locations available, be sure to use the same Wire or Wire1 object with all associated functions.

You need to look into the library and check which pins it is using. You could try using Wire instead which has the same pins used on the Argon and Electron.

1 Like

Armor,

   Thanks again (Armor and ScruffR rock) and yep, that was a big piece of the problem. Looks like I had two things happening. 
  • the first time I tried the example, I didn’t change ‘wire1’ to ‘wire’

  • the second time, I did make the change, however, at that point, I didn’t realize that the web IDE was no longer talking to the Argon. It had gone into this locked safe mode (the origins of this thread). When I tried to flash from the web IDE, if I paid attention to the status bar, I would see a statement about the flash being successful at the left of the status bar, but also to the right of the status bar that the update was unsuccessful ‘Last Event: flash/status = failed’. Thus my code alteration from ‘wire1’ to ‘wire’ wasn’t actually being flashed and I didn’t realize that at first in my eagerness to get my Argon doing fun things.

  • -I am new to particle parts, but after some head scratching, I dug into the line “SYSTEM_MODE(MANUAL);”. this seems to disable the WiFi and thus seems to explain why I couldn’t flash the Argon.

  1. If I leave “SYSTEM_MODE(MANUAL);” in the code, the Argon goes into the locked safe mode that started this thread (which doesn’t yet make sense).
  2. If I leave “SYSTEM_MODE(MANUAL);” in the code, I have to use the buttons to put the Argon into safe mode to flash the part using the web IDE (which makes sense since the Argon isn’t connected to the WiFi).

-BOTTOMLINE: I have the I2C LIS3DH example working on my Argon after two changes:

  1. changed the three instances of ‘wire1’ to ‘wire’
  2. removed the line: SYSTEM_MODE(MANUAL);

Now I need to find a good tutorial/explanation/resource to get educated on SYTEM_MODE(MANUAL), especially concerning how to get out of it elegantly without having to manually invoke safe mode.

Thanks again!!!
Falconm

1 Like

SYSTEM_MODE(MANUAL) (without SYSTEM_THREAD(ENABLED)) needs special care any requires your code to regularly (as fast as possible but at least every 5sec - ignore the 20sec mentioned in docs, especially with regards to OTA updates) Particle.process()

But that is (mostly) documented here
https://docs.particle.io/reference/device-os/firmware/photon/#manual-mode