วันจันทร์ที่ 30 กันยายน พ.ศ. 2556

Arduino - Ethernet Shield

Arduino - Ethernet Shield


How to build an arduino energy monitor - measuring mains current only. :ref http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor-measuring-current-only?page=1


How to build an arduino energy monitor - measuring mains current only.

This little guide details how to build a simple electricity energy monitor on a breadboard that you could use to measure how much electrical energy you use in your home. It measures current and takes a set value for voltage (if your in the uk 230V) to calculate apparent power all the calculations are done on an arduino, although not as accurate as when a voltage measurement is taken, it is a method commonly used in whole house energy monitors for reasons of simplicity and lower cost. Here's how to do it:

Step One – Gather Components

You will need:
1x Arduino
Current sensing electronics
1x CT sensor yhdc SCT-013-000
1x Burden resistor 18 Ohms if supply voltage is 3.3V or 33 Ohms if supply voltage is 5V.
2x 10kOhm resistors (or any equall valued resistor pair upto 470kOhm)
1x 10uF capacitor
Other
1x A breadboard and some single core wire.
Oomlout do a good arduino + breadboard bundle here £29

Step Two – Assemble the electronics

The electronics consist of the current sensor (which produce signals proportional to the current in the mains) and the sensor electronics that convert these signals into a form the Arduino is happy with.
For a circuit diagram and detailed discussion of sensors and electronics see:
Assemble the components as in the diagram above.

Step Three – Upload the Arduino Sketch

The Arduino sketch is the piece of software that runs on the Arduino. The Arduino converts the raw data from its analog input into a nice useful values and then outputs them to serial.
a) Download EmonLib from github and place in your arduino libraries folder.
Download: EmonLib
b) Upload the voltage and current example:
#include "EmonLib.h"                   // Include Emon Library
EnergyMonitor emon1;                   // Create an instance

void setup()
{  
  Serial.begin(9600);
  
  emon1.current(1, 111.1);             // Current: input pin, calibration.
}

void loop()
{
  double Irms = emon1.calcIrms(1480);  // Calculate Irms only
  
  Serial.print(Irms*230.0);        // Apparent power
  Serial.print(" ");
  Serial.println(Irms);         // Irms
}

c) Open the arduino serial window
You should now see two columns of values. Apparent power on the left and rms current on the right.
Regeneractiv's picture

Re: How to build an arduino energy monitor - measuring current only

Guten Morning!
I translated this tutorial into German. It´s not perfect but I hope it could help someone.-->Link.
Ich hab´ den Tutorial übersetzt, ist sehr schlecht geschrieben, da Deutsch nicht meine Muttersprache ist, aber verständlich sollte es sein... für fragen:
http://electronics.stackexchange.com/questions/23591/ac-current-sensor
http://forum.arduino.cc/index.php/topic,12921.0.html
http://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface
http://openenergymonitor.org/emon/buildingblocks/how-to-build-an-arduino-energy-monitor-measuring-current-only?page=1

วันพฤหัสบดีที่ 19 กันยายน พ.ศ. 2556

Auto reboot rPI hang By Watchdog นำมาจาก https://www.facebook.com/RaspberryPi66

Auto reboot Raspberry Pi เมื่อมัน hang ไปซะเฉยๆ ด้วย Watchdog

16 กุมภาพันธ์ 2013 เวลา 6:48 น.

บางครั้งเราเปิด rPi ไว้บ้านเพื่อนทำ Home automation หรือ load bit ก็ว่ากันไปแล้วมันหยุดทำงาน ตอนเราไม่อยู่บ้าน แหมเหมือนใจมันจะขาดรอนๆ จะสั่งใครให้ reboot ให้ก็ไม่ได้

วันนี้เรามาดูวิธีติดตั้ง watchdog เพื่อให้มันเฝ้าดูการทำงานของเครืองให้เรากันครับ โดย watchdog timer นัั้นจะเป็นการทำงานด้านฝั่ง hardware เลย โดยจะนับถอยหลังจากค่าที่เรากำหนดไว้จนได้ค่าเป็น 0 มันจะสั่งให้ rPi reboot ทันที ซึ่งโดยปกติถ้าระบบทำงานปกติค่าตัวแปรจะถูกอัพเดตให้มีค่าสูงไว้ตลอด ถ้านับได้ 0 แปลว่ามัน หยุดทำงานไปแล้วนั่นเอง

ซึ่งโชคดีมากที่ Broadcom BCM2835 SoC ของ Raspberry Pi เรามาพร้อมกับ hardware-based watchdog timer ทำให้เราสามารถใช้งานได้ตามนิยามในย่อหน้าแรก

Load the bcm2708_wdog kernel module

ทำได้โดยเปิดไฟล์ /etc/modules แล้วเพิ่มบรรทัดนี้ลงไป

bcm2708_wdog
จากนั้นสั่ง load module เพื่อให้ทำงานได้ทันที ไม่ต้อง reboot

sudo modprobe bcm2708_wdog


Install the software watchdog daemon

ติดตั้ง package watchdog ด้วยคำสั่ง

sudo apt-get install watchdog

และสั่งให้ทำงานทุกครั้งเมื่อเริ่มระบบ

sudo update-rc.d watchdog defaults

Configure the watchdog daemon
เปิดไฟล์ /etc/watchdog.conf ขึ้นมาแก้ไข โดยเอาเครื่องหมาย # ออกจากหน้าบรรทัดเหล่านี้เพื่อให้โปรแกรมอ่านค่า parameter เหล่านี้

#watchdog-device
.
.
.
#max-load-1 = 24

หลังจากนั้นสั่งให้ service watchdog ทำงานด้วยคำสั่ง

sudo /etc/init.d/watchdog start
ลองหางานหนักๆให้มันทำงานแล้วดูว่าระบบมัน auto reboot ให้รึเปล่า
เท่านี้ก็ได้ผู้ช่วยคนใหม่มาคอย reboot ให้แล้วครับ

Driving Raspberry Pi GPIOs from Scratch



Thank you and REF :http://www.youtube.com/watch?v=uPvHY-KvelI

BASIC PROGRAMMING PI and Hardware


Within these instructions, we shall only cover some very basic programming, more detailed examples and tutorials will be made available from the “Meltwater Raspberry Pi Hardware” site (http://pihw.wordpress.com/) in the learning section.