mkdir -p /mnt/ram sudo mount -t tmpfs -o size=1024M tmpfs /mnt/ram
Author Archives: bild
Linux split and merge
Split:
split -b1m file
Merge:
cat x* >file
Arduino Temperature/Humidity Web Sensor
Used:
- Arduino Duemilanove
- Arduino Ethernet Shield
- DHT22 Sensor
- DHT-sensor-library
- DHT Example
Connect Sensor-Pin1 to +5V
Connect Sensor-Pin2 to Digital In 2
Connect Sensor-Pin4 to GND
Connect Sensor-Pin1 with a 10K resistor to Sensor-Pin2
Programm Used (Combination of WebServer and DHT Example):
/*
Web Server
A simple web server that shows the value of the analog input pins.
using an Arduino Wiznet Ethernet shield.
Circuit:
* Ethernet shield attached to pins 10, 11, 12, 13
* Analog inputs attached to pins A0 through A5 (optional)
created 18 Dec 2009
by David A. Mellis
modified 4 Sep 2010
by Tom Igoe
*/
#include
#include
// Example testing sketch for various DHT humidity/temperature sensors
// Written by ladyada, public domain
#include "DHT.h"
#define DHTPIN 2 // what pin we're connected to
// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor
DHT dht(DHTPIN, DHTTYPE);
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
// Request
int Request; // any function will see this variable
void setup() {
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
// Serial.begin(9600);
// Serial.println("DHTxx test!");
// Request
Request = 0;
// DHT
dht.begin();
}
void WEBloop()
{
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
// output the value of each analog input pin
//for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
//client.print("analog input ");
//client.print(analogChannel);
//client.print(" is ");
//client.print(analogRead(analogChannel));
//client.println("
");
//}
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
// Serial.println("Failed to read from DHT");
//
client.print("Failed to read from DHT");
client.println("
");
} else {
// Serial.print("Humidity: ");
// Serial.print(h);
// Serial.print(" %\t");
// Serial.print("Temperature: ");
// Serial.print(t);
// Serial.println(" *C");
//
client.print("Request: ");
//client.println(random(1000));
Request = Request + 1;
client.println(Request);
//
client.print("Humidity: ");
client.print(h);
client.print(" %\t");
client.print("Temperature: ");
client.print(t);
client.println(" *C");
client.println("
");
}
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
}
}
void loop() {
//DHTloop();
WEBloop();
}
void DHTloop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
float t = dht.readTemperature();
// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h)) {
Serial.println("Failed to read from DHT");
} else {
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.println(" *C");
}
}
Install development environment on Debian or Fedora based systems
Debian:
aptitude install make automake gcc g++ kernel-package fakeroot libncurses-dev kernel-source-`uname -r` linux-headers-`uname -r`
or:
aptitude install build-essential
Fedora:
su - yum install make automake gcc gcc-c++ kernel-devel
of:
su - yum groupinstall "Development Tools" "Development Libraries"
Install Eclipse Indigo IDE for C/C++ on Windows
– download and install Java Runtime Environment (JRE)
– download and install the C/C++ Compiler CygWin (FULL install)
– download and extract Eclipse IDE
– add “C:\cygwin\bin” to your PATH environment variable
– start Eclipse and create HelloWorld Test Project and compile 😀
Adobe Flash on Fedora 17 x86_64
download latest Flash (YUM)
install repository:
rpm -ivh adobe-release-x86_64-1.0-1.noarch.rpm
add GPG Key
rpm -import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
update repos:
yum repolist yum check-update
or:
yum update
install Flash:
yum -y install flash-plugin AdobeReader_enu adobe-release-x86_64
Install LAMP (Apache2, MySQL, PHP, PHPMyAdmin) on Fedora 17
install:
yum install mysql mysql-server httpd php phpmyadmin
or:
yum groupinstall 'Web Server'
secure the installation
mysql_secure_installation
start the services
systemctl enable httpd.service systemctl start httpd.service systemctl enable mysqld.service systemctl start mysqld.service
test the installation, open
http://localhost/
when write access to files is needed try
setenforce 0
Secure MySQL Server Installation
run
sudo mysql_secure_installation
Check Harddisk/USB Stick for bad blocks / sectors
run
badblocks -wsv /dev/<device>
e.g. “badblocks -wsv /dev/sdb
badblocks -w -s -o usbstick.log /dev/sdc
Warning! Data will be overwritten when using option “-w”
Compile RetroShare on Debian 6 Squeeze
#needed Packages: aptitude install libupnp3 gnupg-agent libqt4-dev g++ libgpgme11-dev libgpg-error-dev libupnp-dev libssl-dev libgnome-keyring-dev libxss-dev subversion
#Get RetroShare svn co https://retroshare.svn.sourceforge.net/svnroot/retroshare/trunk/ retroshare #or wget http://sourceforge.net/projects/retroshare/files/RetroShare/0.5.3b/RetroShare-v0.5.3b.tar.gz/download
#Build cd $RetroSharePath/libbitdht/src qmake make cd ../../libretroshare/src qmake make cd ../../retroshare-gui/src qmake make
#Run retroShare $RetroSharePath/retroshare-gui/src/RetroShare