Thingy:91 resets only when USB is connected

Hello everyone,

there seems to be an issue with my programm I am unable to solve. When I flash/reset the thingy via VSCode with Segger J-Link mini EDU and USB it boots just fine and the application runs even if I disconnect it after. But if I try to reset it just with the J-link without the USB or simply by a power-on reset it doesn't do anything. 

The battery is fine and when f.e. the blinky demo is flashed it works without issues. What am I missing?

Thanks for your help.

The app is supposed to first connect to the network, then measure the airquality and send a message via MQTT. After that go to sleep for 5 mins and repeat.

This is my main():

void main(void)
{
	k_msleep(500); //tested if delaying helps
	gpio_pin_configure_dt(&red_led, GPIO_OUTPUT_ACTIVE);
	/*Initialisierung und Aufbau der Internetverbindung*/
	int err;
	printk("Connecting to LTE network. This may take a few minutes...\n");
	k_msleep(500); //tested if delaying helps
	err = lte_lc_init_and_connect_async(lte_handler);
	if (err) {
			printk("lte_lc_init_and_connect_async, error: %d\n", err);
			return;
	}
	err = lte_lc_psm_req(true); //enabling PSM
	if (err) {
			printk("lte_lc_psm_req, error: %d\n", err);
			return;
	}
	k_sem_take(&lte_connected, K_FOREVER);
	gpio_pin_configure_dt(&red_led, GPIO_OUTPUT_INACTIVE);

	/*Abarbeitung des weiterführenden Programms*/
	printMessageConnection();
	connectedLED();
	sensINIT();	

	err = client_init(&client);
	if (err) {
		printk("Failed to initialize MQTT client: %d\n", err);
		return;
	}

do_connect:
	err = mqtt_connect(&client);
	if (err) {
		printk("Error in mqtt_connect: %d\n", err);
		goto do_connect;
	}
	err = fds_init(&client,&fds);
	if (err) {
		printk("Error in fds_init: %d\n", err);
		return;
	}


	while(1){

		err = poll(&fds, 1, mqtt_keepalive_time_left(&client));
		if (err < 0) {
			printk("Error in poll(): %d\n", errno);
			break;
		}

		err = mqtt_live(&client);
		if ((err != 0) && (err != -EAGAIN)) {
			printk("Error in mqtt_live: %d\n", err);
			break;
		}

		if ((fds.revents & POLLIN) == POLLIN) {
			err = mqtt_input(&client);
			if (err != 0) {
				printk("Error in mqtt_input: %d\n", err);
				break;
			}
		}

		if ((fds.revents & POLLERR) == POLLERR) {
			printk("POLLERR\n");
			break;
		}

		if ((fds.revents & POLLNVAL) == POLLNVAL) {
			printk("POLLNVAL\n");
			break;
		}

		airQualLED();
		sensValues();
		sendMsg();
		k_sleep(K_MINUTES(MAIN_SLEEP));
	}

	printk("Disconnecting MQTT client\n");

	err = mqtt_disconnect(&client);
	if (err) {
		printk("Could not disconnect MQTT client: %d\n", err);
	}
	goto do_connect;
}

Parents Reply Children
  • Hi,

    no. I still have the same issue. In the image you can see the console output. First I resetted it via VS Code and it booted and started to connect to a network. Then I turned it off and on again and it didn't boot. 

    As I am writing this I tried turning it off and on again and it booted. Then directly after it didn't boot. When it isn't connected via USB and debug probe it doesn't do anything when turned off and on.

    Could you add a new build configuration like shown below and try it with that build?

Related