-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d7ea616
commit 89b99cc
Showing
6 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
printf "Content-type: text/html\n\n" | ||
printf "<html><head>" | ||
printf "<meta charset=\"UTF-8\">" | ||
printf "<title>Beagle Board Temperature</title></head>" | ||
printf "<body><h1>Beagle Board Temperature</h1><para>" | ||
printf "The temperature in the room is " | ||
/usr/local/bin/tmp36raw | ||
printf " degrees Celsius</para></html>" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
printf "Content-type: text/html\n\n" | ||
printf "<html><head>" | ||
printf "<meta charset=\"UTF-8\">" | ||
printf "<title>Hello Beagle Board</title></head>" | ||
printf "<body><h1>Hello Beagle Board</h1><para>" | ||
hostname | ||
printf " has been up " | ||
uptime | ||
printf "</para></html>" | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <iostream> | ||
#include <sstream> | ||
#include <fstream> | ||
using namespace std; | ||
|
||
#define ADC_PATH "/sys/bus/iio/devices/iio:device0/in_voltage" | ||
#define ADC 0 | ||
|
||
float getTemperature(int adc_value) { // from the TMP36 datasheet | ||
float cur_voltage = adc_value * (1.80f/4096.0f); // Vcc = 1.8V, 12-bit | ||
float diff_degreesC = (cur_voltage-0.75f)/0.01f; | ||
return (25.0f + diff_degreesC); | ||
} | ||
|
||
int readAnalog(int number){ | ||
stringstream ss; | ||
ss << ADC_PATH << number << "_raw"; | ||
fstream fs; | ||
fs.open(ss.str().c_str(), fstream::in); | ||
fs >> number; | ||
fs.close(); | ||
return number; | ||
} | ||
|
||
int main(){ | ||
//std::cout << "Starting the TMP36 example" << std::endl; | ||
//std::cout << "The ADC value input is: " << readAnalog(ADC) << endl; | ||
float temp = getTemperature(readAnalog(ADC)); | ||
float fahr = 32 + ((temp * 9)/5); // convert deg. C to deg. F | ||
//cout << "Temperature is " << temp << "°C (" << fahr << "°F)" << endl; | ||
cout << temp; | ||
} | ||
|