Mohamed Ali Bedair
Published

SOS : Device for People with disability to Call for Support

SOS device installed within the wheelchair to allow people with mobility impairments to call for help and send their location.

IntermediateFull instructions providedOver 1 day139
SOS : Device for People with disability to Call for Support

Things used in this project

Hardware components

nRF9160 Development Kit
Nordic Semiconductor nRF9160 Development Kit
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
×1
Button
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Plastic Enclosure, Project Box
Plastic Enclosure, Project Box
×1

Software apps and online services

Zephyr RTOS
Zephyr Project Zephyr RTOS
VS Code
Microsoft VS Code
nRF Connect SDK
Nordic Semiconductor nRF Connect SDK

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Solder Flux, Soldering
Solder Flux, Soldering

Story

Read more

Schematics

System Block Diagram

The System main component is the Nordic nRF9160 which has the Modem for Cellular connectivity and GNSS sensing.

Code

LED Status change based in System State

C/C++
The System will update LED status based on the System state. The LED1 will blink if the Modem is currently in initialization phase and will turn the LED1 ON once the Initialization is done.

The LED2 will blink if the user didn't press the button to request for help (SOS Signal), and the LED2 will be turned ON when the user press the button requesting for support.
static void LED_Handler(void)
{       
	IoHwAbs_LED_Init();

	while (1)
	{
		/* Toogle LED During Modem Initialization and make it ON when modem is initialized */
		if (MODEM_STARTED == Modem_State)
		{
			IoHwAbs_LED_Set_State(LED_0, LED_ON);
		}
		else
		{
			IoHwAbs_LED_Toggle(LED_0);
		}

		/* Toggle LED2 if SOS not requested and make it ON when SOS is requested */
		if (SOS_REQUESTED == SOS_State)
		{
			IoHwAbs_LED_Set_State(LED_2, LED_ON);
		}
		else
		{
			IoHwAbs_LED_Toggle(LED_2); 
		}

		k_msleep(LED_INITIAL_PERIODICITY); 
	}
}

System will wait for button to be pressed

C/C++
System will wait for button to be pressed which indicate SOS request, the system will wakeup the task responsible for reading the GPS data and send the SMS every 1 minute
static void Button_Handler(void)
{       
	static TaskState_Type Modem_Task_State = TASK_STATE_SUSPEND;
	IoHwAbs_Switch_Init();
	while (1)
	{
		if (IoHwAbs_Switch_Get_State(SWITCH_0))
		{
			/* Debounce the Button */
			k_msleep(BUTTON_DEBOUNCE_DELAY);
			if (IoHwAbs_Switch_Get_State(SWITCH_0))
			{
				printk("Button Pressed ... \n\r");
				if (Modem_Task_State != TASK_STATE_RESUME)
				{
					/* Activate thee Modem_Handler task */
					k_wakeup(Modem_Handler_id);
					printk("Modem_Handler Task Activated ... \n\r");
					Modem_Task_State = TASK_STATE_RESUME;
				}  
			} 
		}
		k_msleep(BUTTON_HANDLER_PERIODICITY); 
	}  
}

Read GPS data and send SMS

C/C++
The SW has a task to handle GPS and SMS, this task will initialize the Modem Firmware and go to sleep until the user press the button to request SOS.

Once the Modem task gets wakeup from sleep, it will read the GPS data and send it in a SMS to the configured number, it will send new GPS data every minute.

The Periodicity of reading the GPS data and send the SMS is configured easily be a C macro.
static void Modem_Handler(void)
{       
	int ret = 0;
	GNSS_Position_Type position;
	uint32_t attampt = 0;

	char textBuff[100];

	printk("START Modem ... \n\r");
	App_Modem_Init();

	printk("START GNSS ... \n\r");
	App_GNSS_Init();

	App_SMS_Init();

	Modem_State = MODEM_STARTED;

	printk("Modem_Handler Task Suspended ... \n\r");
	/* Wait until the Button is Pressed */
	k_sleep(K_FOREVER);

	SOS_State = SOS_REQUESTED;
	while (1)
	{       
		if (App_GNSS_Data_Valid())
		{

			App_GNSS_Get_Position_Data(&position);
			attampt++;
			sprintf(textBuff, "SOS Attampt: %d, longitude: %.6f, latitude: %.6f\n\r ", attampt, position.longitude, position.latitude);

			ret = App_SMS_Send(CONFIG_SMS_SEND_PHONE_NUMBER, textBuff);
			if (ret) 
			{
				printk("Sending SMS failed with error: %d\n", ret);
			}
		}
		
		k_msleep(MODEM_HANDLER_PERIODICITY); 
	} 
}

Full SW Project on GitHub

Credits

Mohamed Ali Bedair

Mohamed Ali Bedair

7 projects • 4 followers
Engineer/Maker

Comments