koneksi serial data arduino ke Phyton ke php


dari postingan sebelum nya membuat sensor temperature sederhana kita ingin menampilkan dalam web browser berikut step2 nya:

– install python
– install pyserial

script python sebagai berikut

import serial
ser = serial.Serial('/dev/ttyACM1',9600)
print ser.readline()

simpan dalam format .py misal deteksisuhu.py

setelah itu coba run di terminal

python /home/alibaba/deteksisuhu.py

akan muncul di terminal text yg kita lihat di serial monitor arduino, namun tidah berulang

setelah itu jika ingin ditampilkan dalam format php ketik script sebagai berikut

<?php
//header("refresh" 2");
$command = "python /home/alibaba/suhutest.py 2>&1";
$pid = popen( $command,"r");
while( !feof( $pid ) )
{
 echo fread($pid, 256);
 flush();
 ob_flush();
 usleep(100000);
}
pclose($pid);
//header("Refresh: 2")
//header('Refresh: 1; url=localhost/arduinotemp15.php');
?>

jika permission denied
ubah permission dengan mengetik

sudo chmod 666 /dev/ttyACM1

tampilan dalam browser akan sebagai berikut

Screenshot from 2015-04-30 01:23:04

Menampilkan serial monitor di terminal


dari postingan sebelumnya tentang sensor suhu sederhana menggunakan arduino kali ini kita mencoba menampilkan hasil temperature yang telah terdisplay di serial monitor ke dalam terminal

/dev/ttyACM0 9600 ==> disesuaikan dengan port yg dipakai

stty -F /dev/ttyACM0 cs8 115200 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts

screen /dev/ttyACM0 9600

Screenshot from 2015-04-29 22:29:03

Sensor suhu sederhana Arduino


bahan:
Arduino (Uno)
LM 35


LM 35 mempunyai 3 kaki yaitu (Vin, Out, ground).

LM35 Vin – Arduino +5V
LM35 Reference – Arduino A1
LM35 ground – Arduino Ground

Upload kode sebagai berikut:

float temp;
int tempPin = 2;
 
void setup()
{
Serial.begin(9600);
}
 
void loop()
{
 temp = analogRead(tempPin);
 temp = temp * 0.48828125; //(5V * 100C)/1024
 Serial.print("TEMPERATURE = ");
 Serial.print(temp);
 Serial.print("*C");
 Serial.println();
}

setelah itu lihat data di serial sebagai berikut (ctr+shift+m)

Screenshot from 2015-04-29 21:09:51
untuk pengembangan selanjutnya bisa dapat ke LCD, atau dengan mengunakan kombinasi If dan LeD

Water level Sensor dengan Arduino


Peralatan:

Beardboard & Jumper
Arduino (saya menggunakan Uno)
Resistor 470 ohm (3)
Resistor 22 Kohm (4)
Transistor BC548C (3)
LED (3)
Kabel secukupnya

kali ini saya menggunakan sensor sebanyak 3 titik sebab itu resistor, transistor dan LED juga berjumlah 3. Khusus resistor 22 Kohm diperlukan 1 buah lagi.

Media percobaan
Botol bekas yang sudah dibolongi sebanyak 4 titik. Bolong 1 adalah tegangan referensi, bolong 2,3, dan 4 adalah sensor yang kita inginkan.

masukan keempat kabel kedalam lobang masing2 botol tersebut, gunakan lem plastik agar tidak keluar air. setelah itu sambungkan ke Breadboard untuk selanjutnya masuk kedalam rangkaian

untuk lebih jelasnya lihat rangkaian berikut

DSC_0659

untuk program arduino sebagai berikut


byte sensorPin[] = {8, 9, 10};
byte ledPin[] = {11, 12, 13}; 
const byte sensors = 3;
void setup() {
  for(int i = 0; i < sensors; i++) {
     pinMode(sensorPin[i], INPUT); 
     pinMode(ledPin[i], OUTPUT);
  }
 
}


 
void loop() {
 
  if(digitalRead(sensorPin[0]) == HIGH && digitalRead(sensorPin[1]) == LOW && digitalRead(sensorPin[2]) == LOW )   {                                                                                                                                                                                                                          
        digitalWrite(ledPin[0], HIGH);
        digitalWrite(ledPin[1], HIGH);
        digitalWrite(ledPin[2], HIGH);
     } 
  else if (digitalRead(sensorPin[0]) == HIGH && digitalRead(sensorPin[1]) == HIGH && digitalRead(sensorPin[2]) == HIGH){
        digitalWrite(ledPin[0], LOW);
        digitalWrite(ledPin[1], LOW);
        digitalWrite(ledPin[2], LOW);
       }    
       
  else if (digitalRead(sensorPin[0]) == HIGH && digitalRead(sensorPin[1]) == LOW && digitalRead(sensorPin[2]) == HIGH){
        digitalWrite(ledPin[0], HIGH);
        digitalWrite(ledPin[1], HIGH);
        digitalWrite(ledPin[2], LOW);
       }    
       
  else if (digitalRead(sensorPin[0]) == LOW && digitalRead(sensorPin[1]) == HIGH && digitalRead(sensorPin[2]) == HIGH){
        digitalWrite(ledPin[0], HIGH);
        digitalWrite(ledPin[1], LOW);
        digitalWrite(ledPin[2], LOW);
       }    
       
       
  delay(5);  
 }


kira-kira hasil yang akan dihasilkan sebagai berikut

untuk advancenya dapat mengunakan alarm, motor, pompa, LCD, dan lain lain

Link inspirasi: http://www.electroschematics.com/9964/arduino-water-level-indicator-controller/

[DIY] Membuat Bohlam berbasis LED


Alat alat
1. Lampu bekas/rusak
2. Botol bekas
3. Karton bekas
4. Solder
5. Timah secukupnya
6. Lem Aibon / Lem power Glue
7. Tang
8. kabel secukupnya
9. Isolasi kabel

Komponen Elektronik
1. Resistor 470K (1 buah)
2. Resistor 330 (1 buah)
3. Capasitor Elco 4.7µF / 450V (1 buah)
4. Diode IN4007 (4 buah)
5. LED 3.3v (25 buah)
6. Capasitor 330 nF / 450 V (1 buah)

langkah-langkah

1. Pecahkan bohlam secara hati2, bisa menggunakan plastik. atau jika lampu Flurosent bisa membuka di bungkus putihnya, dan jika beruntung rangkaian didalamnya bisa dipakai)

DSC_0543

2. Potong botol menjadi dua 
DSC_0541DSC_0542

3. tempelkan kepala bekas lampu ke mulut botol menggunakan lem

DSC_0544

4. Tahap yang paling penting adalah membuat rangkaian elektrik dengan bagan sebagai berikut, jika tidak mempunya pcb dapat menggunakan karton bekas dan disolder antar komponen. Isolasi bagian belakang jangan sampai point-point yang sudah disolder saling beradu. Siapkan 2 point untuk Input 220v dan 2 point output DC

DSC_0574

DSC_0546

DSC_0550

5. Hubungkan dengan solder+timah ke kutub lampu (kutub tidak masalah) karena rangkaian AC. Namun jangan sampai beradu satu sama lain dan jangan sampai beradu juga dengan rangkaian/komponen

DSC_0556

6. Bolongkan pantat botol dan masukan led dan hubungkan menggunakan tang secara perlahan, dan rangkaian secara seri, seperti digambar dibawah ini. perhatikan kutub LED + dan – secara tepat (kutub led http://id.wikipedia.org/wiki/Berkas:Ledmrp.jpg)

DSC_0557

DSC_0558

DSC_0559

DSC_0561

7. Hubungkan dengan solder+timah rangkaian elektronik ke rangkaian LED, perhatikan + dan – nya

DSC_0563

8. Berikan Lem dipantat botol dan sambung ke bagian Botol lainnya

DSC_0564

DSC_0565

9. Bungkus botol dengan kertas atau cat dengan warna putih agar pemantulan cahaya lebih baik

DSC_0568

10. Selesai

DSC_0578

History of our nation in 1998.


1998 at that time I was 12 years old and until now I still remember what’s happened especially when I was with my father. In practically my father taught me many good things that I didn’t felt and that incident always still in my mind. Shortly at that time for me started to know good thing or bad thing, I still remember that KKN (Korupsi, Kolusi, Nepotisme) corruption, collusion and nepotism is a worst, because every day at that moment people always said that. And also my father told to me about that. In 1997 when Indonesia has election, at that moment I know a little about politic. My father taught me about politics, in this case how politic that contra-goverment. Actually, I saw and read some bulletin in my home that in the cover has Megawati Soekarnoputri and my father always told me to not tell everybody about this bulletin. I always like a secret, and I asked to him why, and he explained to me, we could put in the jail because this bulletin. And I thought Okey.

Every body told about politics, in our home, in television. But in school we don’t care about politics. We just care, if something happened like chaos or dangerous situation it’s mean holiday, and we was very happy!. Back to 1998, I’ve my brother who studied at Trisakti university which has some dangerous situation, a few of students was killed in the middle May. And of course my father has attention of this situation, and we have home where placed not so far between Trisakti, Istana Negara, and Gedung MPR/DPR where was mass concentration at that place. If something happened in Gedung MPR/DPR it’s mean exactly, I could go to school because we’ve to pass that way to go my school, I was happy like usually students at that moment.

My brother appeared several times in Television, and it’s became a good news for our family because he still alive. In the middle of May, I remember that peoples made some damage, they broke everything, they burned everything, they stole every thing and many bad thing. And I still remember that time my father took me to saw everything what’s happened. Because our home near in the trade center and also Metro (that largest supermarket at this time), I saw many people broke the door and stole everything inside that supermarket. And also they wanted to burn that supermarket. And I remember that my father prevent people to do this, but he couldn’t prevent to the people not to stole or etc. But he taught me that is bad to stole every thing that you have although many people do that.

I with my father just looked not far away, it’s far about 50 meter. And I saw many people that we knew each other who take everything from this supermarket. Until now, that condition always in my mind, I never forget about that. I learned many thing about that. Before it’s happen, around that supermarket, we have a many thing, culinary,  playing ground for the children, and also economic around there was life. And I had a goat which my father gave to me keep, my goat ate an expensive food that we said, because the food like vegetables or fruits which wasn’t fresh anymore, they put into the trash which near in my home. The goat, Jackson that we gave him the name was very lucky goat.

Back to the chaos condition, in other side my our home. Many building that sold cars also got chaotic condition, people not stole cars but just destroyed and burned. I remember that BMW was burned that I saw directly with my father. My father didn’t forbid me to see this situation, instead on he took me to see but of course, I couldn’t go with my himself. But until now, sometime I still think about that. And I also saw many of tanks went in the road, and destroyed a road and some pots. And I also remember that I saw PHH (Pasukan Huru Hara) which drove trail motorcycle which I very impressed that. Actually people judge PHH or Police was an enemy because they were very repressive, reserve of Marinir (Marine). That’s why at this time many people liked marine with tanks although tanks destroy pots.

Now, when I’m writing this words, I’ve already 29 years old, it’s 17 years ago. I’m very lucky that I has dad. He passed away two years after Soeharto was resigned.

People said that era is Reformation, but until know I still think is not Reformation.