Saturday, October 17, 2015

I've controlled character LCD through Web

I've controlled character LCD via command line last time. I will control the LCD via Web this time.

I installed apache2 and php5. Then, I called  /usr/sbin/i2cset and i2cget via exec command from PHP script. i2cset can't run because apache2 run on www-data user by default. /var/log/apache2/error.log shows there is no root privilege.

I added the following lines into /etc/sudoers:

www-data ALL=(ALL) NOPASSWD:/usr/sbin/i2cget
www-data ALL=(ALL) NOPASSWD:/usr/sbin/i2cset

Now I can call "sudo /usr/sbin/i2cset" by exec command. I can access it from Android Tablet by setting PHP URL.

No comments:

Post a Comment