I am doing a PAP (Final Course Project), I have as a plan to make a program that I can see the RaspBerry temperature through wifi / internet, is there any way to do this through AppInventor?
Hi
We have a lot of examples using Arduino Microprocessors, but info on App Inventor and Raspberry Pi is sparse.
See my website:
https://www.professorcad.co.uk/appinventortips#TipsRaspberryPi
Suggest using HTTP / php and shell_exec, I assume your linux system on the raspberry is logging the data ?
I use a code to see the temperature, it is not always registering, what I think was a way for me to connect to the raspberry by phone so I can see the temperature
hank you very much i went to see but i don't know if it will help but i will see better thank you very much
I use a code to see the temperature, it is not always recorded, what I want is to connect via wifi ip any way over the internet, connect my phone to the raspberry and see the temperature without touching the raspberry
How are you logging the temperature on your raspberry ? What command do you use to see the output ?Is it going to a file ?
!/bin/bash
Shell script: temp.sh
Autor: Santiago Crespo - Modificado por Marcos Matas
cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
echo "Equipo => $(hostname)"
echo "$(date)"
echo "------------------------------"
echo "Temp.CPU => $((cpu/1000))'Cº"
echo "Temp.GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
echo "------------------------------"
echo "CPU"
echo "$(vcgencmd measure_clock arm)Hz"
echo "$(vcgencmd measure_volts core)"
echo "Mem. del Sistema $(vcgencmd get_mem arm)"
echo "Mem. de la $(vcgencmd get_mem gpu)"
echo "------------------------------"
echo "Consumo de memoria"
echo "$(egrep --color 'Mem|Cache|Swap' /proc/meminfo)"
this is code I use
Your script:
cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
echo "Equipo => $(hostname)"
echo "$(date)"
echo "------------------------------"
echo "Temp.CPU => $((cpu/1000))'Cº"
echo "Temp.GPU => $(/opt/vc/bin/vcgencmd measure_temp)"
echo "------------------------------"
echo "CPU"
echo "$(vcgencmd measure_clock arm)Hz"
echo "$(vcgencmd measure_volts core)"
echo "Mem. del Sistema $(vcgencmd get_mem arm)"
echo "Mem. de la $(vcgencmd get_mem gpu)"
echo "------------------------------"
echo "Consumo de memoria"
echo "$(egrep --color 'Mem|Cache|Swap' /proc/meminfo)"
OK
If your raspberry does not have an http server with php setup, run these commands:
sudo apt update
sudo apt install apache2 -y
sudo apt install php libapache2-mod-php -y
full howto: https://www.raspberrypi.org/documentation/remote-access/web-server/apache.md
Then create a php file - getTemp.php
, in your /var/www/html directory:
<?php
$output = shell_exec("sudo /home/<user>/temp.sh 2>&1"); // use correct full path to script
echo $output;
?>
Then test this by running the php file from a remote computer:
http://<raspberryIP>/getTemp.php
See what happens - there may be some permissions issues to resolve....
Your script requires some elevated privileges, so you may need to make apache user www-data a sudoer:
sudo visudo
(pick nano if offered)
add to the bottom of the file:
www-data ALL=(ALL) NOPASSWD: ALL
In your app, you can either use a webviewer to see the output, or web component to get the return value in .GotText
Nice script
Here it is working for me (I edited the script to English)
thank you very much i will see the script with my teacher to be able to do everything without any problems, thank you very much, if you have any questions i will contact you