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
  • Hello Freddy,

    Freddy said:
    I am done with my project and left it as it was. Hope my professor doesn't mind this flaw. 

    Thanks for letting me know, and I am glad to hear that you submitted your project. Please let me know if there is any update on this issue and also create new tickets if you face any trouble in the future.

     Kind Regards,

    Abhijith

    .

Reply
  • Hello Freddy,

    Freddy said:
    I am done with my project and left it as it was. Hope my professor doesn't mind this flaw. 

    Thanks for letting me know, and I am glad to hear that you submitted your project. Please let me know if there is any update on this issue and also create new tickets if you face any trouble in the future.

     Kind Regards,

    Abhijith

    .

Children
No Data
Related