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;
}

  • Hello,

    Letting you know that I have been assigned to this case and I have started looking into this.

    I need some more time for checking this and will get back to you soon.

     

    Kind Regards,

    Abhijith

  • Hello,

    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. 

    By "doesn't do anything" , did you mean the Thingy is not responding? Your application works well when the USB port is connected, So I don't think it's an issue with your code. This might be an issue with the power supply, but not sure, since it is working fine for the Blinky sample.

    Can you try one of the samples from the SDK and let me know whether the same is happening?

    Kind Regards,

    Abhijith

  • Hey,

    the Thingy gets resetted but the code doesn't seem to run (no LEDs or MQTT messages).

    The battery is at 4,1 V so it should be fine. 

    I just flashed the MQTT sample and that one works fine as well (green LED lights up shortly after the Thingy is powered on). 

    Let me know if you need any more info.

    Best regards,

    Freddy

  • Hello,

    Freddy said:
    I just flashed the MQTT sample and that one works fine as well (green LED lights up shortly after the Thingy is powered on). 

    This narrows down that there is no issue with the Thingy91. Blinking green led shows that the sample is working fine and I think it's publishing the data.

    Which SDK version are you using here?

    I went through your code and  void main()  looks good to me. But I am not sure about your whole Application though. What I understood reading your query is that, with the USB port connected, your Application is working fine, right? If that's the case then we can say that there is no issue with the Application too. Please correct me if what I interpreted is wrong.

    Kind Regards,

    Abhijith

  • Hey,

    Which SDK version are you using here?

    I believe it's the latest version of the SDK.

    What I understood reading your query is that, with the USB port connected, your Application is working fine, right?

    Yes. Even when I disconnect it after booting. The only thing that doesn't work is Power-On reset or resetting without USB.

    Could there be an error in the configuration?

Related