460 views|2 replies

45

Posts

2

Resources
The OP
 

[DigiKey Smart Manufacturing Happy Creativity Contest] STM32MP157D Remote Pet Bird Feeder One MQTT GPIO Control [Copy link]

 

STM32MP157D-DK runs on Linux. To achieve remote bird feeding, the previous article has introduced the transplantation of MQTT, which realizes the remote sending of data to STM32MP157D through MQTT. On this basis, GPIO needs to be controlled.

To control GPIO in Linux, you need to know the pin number of each GPIO. Starting from Linux 4.8, the sysf interface is no longer recommended to control GPIO. Instead, the libgpio library is used to control GPIO using character devices in user mode. At the same time, some tools are also provided to help users debug GPIO, such as gpiodetect to list all gpiochips on the system, gpiofind to find the corresponding gpiochip and the offset within the line by name, gpioget to read the value of the specified gpio line, gpioinfo to list all gpiochip lines and their names, users and direction activity status and other information, gpiomon to wait for events on the specified gpio line or specified monitored events, and gpioset to set the value of the specified gpio line.

The GPIOA14 of the STM32MP157D-DK1 development board is connected to a yellow LED indicator light. The high and low outputs of GPIO14 can be controlled through the gpioset command. For example, gpioset gpiochip0 14=0 or gpioset gpiochip0 14=0 controls the GPIO output to be high level to light up the yellow LED light.

Through this, a GPIOA14 control interface function can be encapsulated.

void gpioA14_ctrl(unsigned char u8level)

{

unsigned char cmdbuf[255];

memset(cmdbuf,0,sizeof(cmdbuf));

snprintf(cmdbuf,sizeof(255),"gpioset gpiochip0 14=%d",u8level);

printf("cmdbuf %s\r\n",cmdbuf);

system(cmdbuf);

}

Define a thread to process MQTT data to achieve control

void * mqtt_process(void *parg)

{

unsigned u8cmd=0;

//parse json data

switch(u8cmd){

case LED_ON:

gpioA14_ctrl(0);

break;

case LED_OFF:

gpioA14_ctrl(1);

break;

default:

;

}

}

This post is from DigiKey Technology Zone

Latest reply

It would be more perfect if you post a control circuit for this part or a video of the effect.   Details Published on 2023-12-18 07:34
 
 

6841

Posts

11

Resources
2
 

Can AI chat with birds remotely? Adding video and sound can extend this to communication with the elderly, which may be even better.

This post is from DigiKey Technology Zone
 
 
 

6593

Posts

0

Resources
3
 

It would be more perfect if you post a control circuit for this part or a video of the effect.

This post is from DigiKey Technology Zone
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list