My Arduino fun projects: Part1 (UPDATED: with full code and schematics): Electricity data logging system by mokluc

View this thread on steempeak.com
· @mokluc ·
$100.84
My Arduino fun projects: Part1 (UPDATED: with full code and schematics): Electricity data logging system
<p><img src="http://yapelesolutions.co.za/mine/current1.png" align="middle"></p>
<p>This is an UPDATE for <a href="https://steemit.com/technology/@mokluc/my-arduino-fun-projects-part1-electricity-data-logging-system">My Arduino fun projects: Part1: Electricity data logging system</a> </p>
<p>The update was request by <a href="https://steemit.com/@blocktrades">@blocktrades</a>
 to grow the “Arduino” tag on Steemit.</p>
<p><img src="https://picload.org/image/rdladoal/blocktrades.jpg" align="middle"></p>
<p>Comments can be found on my other blog (which will also be updated to include all the coding and schematics): <a href="https://steemit.com/technology/@mokluc/my-arduino-fun-projects-part2-fingerprint-scanner-which-enrols-and-authenticate-users-then-takes-a-picture-and-uploads-it-to">My Arduino fun projects: Part2: Fingerprint scanner which enrolls and authenticate users then takes a picture and uploads it to Dropbox</a> </p>
<hr>
<p>I will breakdown the project into fewer parts and conclude by combining all the parts as a final design.</p>
<h4>Parts to be discussed:</h4>
<ul style="list-style-type:square">
<li>ATMega328P-PU</li> 
<li>FTDI</li> 
<li>Real Time Clock (RTC)</li>
<li>Current clamp</li> 
<li>SD card module for data logging.</li> 
<li>Final design</li> 
</ul>

<hr>
<h3>ATMega328P-PU</h3>
<p><img src="https://picload.org/image/rdladaga/atmega.png" align="middle"></p>
<p>ATMega328P-PU to Arduino pinout.</p>
<p>ATMega328P-PU, a low-power version of the traditional ATMega328-PU was taken from an Arduino Uno with a pre-burned boot loader.</p>
<hr>

<h3>FTDI</h3>
<p><img src="https://picload.org/image/rdlaggcg/ftdi.png" align="middle"></p>
<p>SparkFun FDTI breakout module.</p>
<p>FTDI uses an FT232RL IC to convert USB signals to UART signals (serial communication).</p>
<p><img src="https://picload.org/image/rdlagrda/ftditable.png" align="middle"></p>
<h4>Wiring:</h4>
<p><img src="https://picload.org/image/rdlagoir/ftdicon.png" align="middle"></p>
<p>The above circuit can also be used to program the ATMega directly from Arduino IDE using the FTDI.</p>
<h4>More information and drivers:</h4> 
<p><a href="https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers">https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers</a></p>
<hr>
<h3>Real Time Clock (RTC)</h3>
<p><img src="https://picload.org/image/rdlagdpl/rtc.png" align="middle"></p>
<p>RTC breakout module</p>
<p>RTC is built around DS1307 IC with an external 32.768 kHz crystal and communicates with the ATMega (Arduino) through Inter-Integrated Circuit (I²C) protocol. RTC has a built-in power-sense circuit that detects power failures and automatically switches to the backup supply (coin battery) to continue keeping time.</p>
<h4>Wiring:</h4>
<p><img src="https://picload.org/image/rdladoiw/rtccon.jpg" align="middle"></p>
<h4>Code:</h4>
<p><img src="https://picload.org/image/rdlagldg/rtcprog.png" align="middle"></p>
<p>Please note I have modified the example code to give me time and date as: day/month/year hour:minutes:seconds (e.g. 19/10/2016 14:00:00)</p>
<h4>More information:</h4> 
<p><a href="https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/overview">https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/overview</a></p>
<hr>

<h3>Current clamp</h3>
<p><img src="https://picload.org/image/rdlagccc/clamp.png" align="middle"></p>
<p>I used the YHDC SCT-013-000 with an input current: 100 A as seen below.</p>
<p><img src="https://picload.org/image/rdlagcgi/ctdatasheet.png" align="middle"></p>
<h4>Wiring and operation:</h4>
<p><img src="https://openenergymonitor.org/emon/sites/default/files/Arduino%20AC%20current%20input%20A.png" align="middle"></p>
<p>Image credit: openenergymonitor.org</p>
<p>Detailed operation and calculations are <a href="https://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface">here</a> </p>
<h4>Code:</h4>
<p><img src="https://picload.org/image/rdlagiwp/currentprog.png" align="middle"></p>
<p>Please note in South Africa we use <b>220-230 VAC at 50-60 Hz</b>, so kindly read  <a href="https://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface"> operation and calculations</a> to calibrate for correct readings.</p>
<h4>Results:</h4> 
<p><img src="https://picload.org/image/rdlagwwd/results.png" align="middle"></p>
<hr>

<h3>SD card</h3>
<p><img src="https://picload.org/image/rdlargcl/sd.png" align="middle"></p>
<p>SD card breakout board</p>
<p>SD cards are popular for storing files and photos and widely used in almost every mobile device. SD card breakout board communicates with the ATMega (Arduino) through Serial Peripheral Interface (SPI) protocol. </p>
<h4>Wiring:</h4>
<p><img src="https://picload.org/image/rdlaroga/sdcon.png" align="middle"></p>

<h4>Code:</h4>
<p>The SD library comes with the Arduino IDE. It needs to be included at the beginning of the sketch.</p>
<p><img src="https://picload.org/image/rdlarodo/sdlib.png" align="middle"></p>
<p>Including `SD.h` automatically creates a global “SD” object which can be interacted within a similar manner to other standard global objects like “Serial”.</p>
<h4>To “read” from SD card, first open the file:</h4>
<p><img src="https://picload.org/image/rdlarlcl/sdopen.png" align="middle"></p>
<p>It will return false if it fails to open the file, so check dataFile before using it. The “read” function reads the file line by line, so will have to use a while loop, until it fails to reach the end of the file. </p>
<h4>To “Write” to SD card:</h4>
<p>First open the file to write to with “FILE_WRITE” parameter.</p>
<p><img src="https://picload.org/image/rdlarccr/sdopen2.png" align="middle"></p>
<p>The “open” function takes two parameters, file location and mode (only required for “Write”, if missing by default it opens the file in Read-Only mode).</p>
<p>It will return false if it fails to open the file, so check dataFile before using it and can write to the file using the following:</p>
<p><img src="https://picload.org/image/rdlarccd/sddatafile.png" align="middle"></p>
<p>Close the file after writing to it and open one file at a time.</p>
<h4>Check if a File Exists:</h4>
<p><img src="https://picload.org/image/rdlarccp/sdexists.png" align="middle"></p>
<h4>Create a Text/Excel File on SD Card:</h4>
<p>There is not a function for this purposes, but you can open a file with “FILE_WRITE” mode to create a file, if this file does not exist.</p>
<p><img src="https://picload.org/image/rdlarccw/sdwrite.png" align="middle"></p>
<p>Please note name.csv its Excel file and name.txt its normal text file.</p>
<p><img src="https://picload.org/image/rdlarcig/sdfinal.png" align="middle"></p>
<hr>
<h3>Final design</h3> 
<p><img src="https://picload.org/image/rdlagpip/schematicmain.png" align="middle"></p>
<h4>Final sketch:</h4>
<p>Final coding is just combination of all the codes explained above. Note I do not discuss the LED blink rate and percentage change as they are optional but I have included them on the final sketch.</p>

<h2>The full Arduino sketch is very long so I uploaded it on <a href="https://github.com/Yapele/Electricity-data-logging-system">Github</a> </h2>
<h2>Feel free to use it and have fun with it</h2>
<p>Kindly upvote and follow me: <a href="https://steemit.com/@mokluc">@mokluc</a>….I will upload another project soon: <b>My Arduino fun projects<b></p>
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 165 others
properties (23)
post_id1,209,410
authormokluc
permlinkmy-arduino-fun-projects-part1-updated-with-full-code-and-schematics-electricity-data-logging-system
categorytechnology
json_metadata"{"links": ["https://steemit.com/technology/@mokluc/my-arduino-fun-projects-part1-electricity-data-logging-system", "https://steemit.com/@blocktrades", "https://steemit.com/technology/@mokluc/my-arduino-fun-projects-part2-fingerprint-scanner-which-enrols-and-authenticate-users-then-takes-a-picture-and-uploads-it-to", "https://learn.sparkfun.com/tutorials/how-to-install-ftdi-drivers", "https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/overview", "https://openenergymonitor.org/emon/buildingblocks/ct-sensors-interface", "https://github.com/Yapele/Electricity-data-logging-system", "https://steemit.com/@mokluc"], "image": ["http://yapelesolutions.co.za/mine/current1.png"], "tags": ["technology", "arduino", "iot"]}"
created2016-10-19 16:26:39
last_update2016-10-19 16:26:39
depth0
children6
net_rshares83,683,640,586,423
last_payout2016-11-19 17:22:57
cashout_time1969-12-31 23:59:59
total_payout_value78.362 SBD
curator_payout_value22.475 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length7,370
author_reputation42,548,954,077,680
root_title"My Arduino fun projects: Part1 (UPDATED: with full code and schematics): Electricity data logging system"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (229)
@pery ·
It's really interesting for me as I'm an engineer. Can you show some traces you made with it? What did you exactly constructed it for?
properties (22)
post_id1,209,547
authorpery
permlinkre-mokluc-my-arduino-fun-projects-part1-updated-with-full-code-and-schematics-electricity-data-logging-system-20161019t164902889z
categorytechnology
json_metadata"{"tags": ["technology"]}"
created2016-10-19 16:49:03
last_update2016-10-19 16:49:03
depth1
children0
net_rshares0
last_payout2016-11-19 17:22:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length134
author_reputation4,999,066,211,110
root_title"My Arduino fun projects: Part1 (UPDATED: with full code and schematics): Electricity data logging system"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@fuzzytew ·
You don't quite directly state what it does ...  Is this to create a log of how much electricity a given appliance burns?
properties (22)
post_id1,209,643
authorfuzzytew
permlinkre-mokluc-my-arduino-fun-projects-part1-updated-with-full-code-and-schematics-electricity-data-logging-system-20161019t13715862z
categorytechnology
json_metadata"{"tags": "technology"}"
created2016-10-19 17:07:21
last_update2016-10-19 17:07:21
depth1
children0
net_rshares0
last_payout2016-11-19 17:22:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length121
author_reputation37,535,693,521
root_title"My Arduino fun projects: Part1 (UPDATED: with full code and schematics): Electricity data logging system"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@mokluc ·
@pery @fuzzytew: On the previous post: <a href="https://steemit.com/technology/@mokluc/my-arduino-fun-projects-part1-electricity-data-logging-system">My Arduino fun projects: Part1: Electricity data logging system</a>  "I was getting frustrated with wrongful billing by the municipality and decided it’s about time I kept a record of my electricity usage." So the idea was to be able to record my electricity usage on a daily basis for example:<p><img src="https://picload.org/image/rdlaiowi/current4.png" align="middle"></p>
properties (22)
post_id1,212,912
authormokluc
permlinkre-mokluc-my-arduino-fun-projects-part1-updated-with-full-code-and-schematics-electricity-data-logging-system-20161020t055329730z
categorytechnology
json_metadata"{"links": ["https://steemit.com/technology/@mokluc/my-arduino-fun-projects-part1-electricity-data-logging-system"], "users": ["pery", "fuzzytew"], "image": ["https://picload.org/image/rdlaiowi/current4.png"], "tags": ["technology"]}"
created2016-10-20 05:53:33
last_update2016-10-20 05:53:33
depth1
children0
net_rshares0
last_payout2016-11-19 17:22:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length525
author_reputation42,548,954,077,680
root_title"My Arduino fun projects: Part1 (UPDATED: with full code and schematics): Electricity data logging system"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@linkback-bot-v0 ·
This post has been linked to from another place on Steem.


  - [Advanced Steem Metrics Report for 19th October 2016](https://steemit.com/steemit/@ontofractal/advanced-steem-metrics-report-for-19th-october-2016) by @ontofractal




Learn more about and upvote to support [**linkback bot v0.5**](https://steemit.com/steemit/@ontofractal/steem-linkback-bot-v0-5-the-reddit-awareness-release). Flag this comment if you don't want the bot to continue posting linkbacks for your posts.

Built by @ontofractal
properties (22)
post_id1,214,752
authorlinkback-bot-v0
permlinkre-mokluc-my-arduino-fun-projects-part1-updated-with-full-code-and-schematics-electricity-data-logging-system-linkbacks
categorytechnology
json_metadata{}
created2016-10-20 14:29:00
last_update2016-10-20 14:29:00
depth1
children0
net_rshares0
last_payout2016-11-19 17:22:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length504
author_reputation1,915,235,672,807
root_title"My Arduino fun projects: Part1 (UPDATED: with full code and schematics): Electricity data logging system"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@cryptomined ·
Arduino looks like a lot of fun, I was checkout projects a litle while back and was thinking what a great learning experience it is...  would love to play around with it one day.
properties (22)
post_id1,230,352
authorcryptomined
permlinkre-mokluc-my-arduino-fun-projects-part1-updated-with-full-code-and-schematics-electricity-data-logging-system-20161023t121500146z
categorytechnology
json_metadata"{"tags": ["technology"]}"
created2016-10-23 12:15:00
last_update2016-10-23 12:15:00
depth1
children1
net_rshares0
last_payout2016-11-19 17:22:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length178
author_reputation1,560,749,963,092
root_title"My Arduino fun projects: Part1 (UPDATED: with full code and schematics): Electricity data logging system"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
@mokluc ·
It is very fun
👍  
properties (23)
post_id1,230,436
authormokluc
permlinkre-cryptomined-re-mokluc-my-arduino-fun-projects-part1-updated-with-full-code-and-schematics-electricity-data-logging-system-20161023t123545801z
categorytechnology
json_metadata"{"tags": ["technology"]}"
created2016-10-23 12:35:48
last_update2016-10-23 12:35:48
depth2
children0
net_rshares0
last_payout2016-11-19 17:22:57
cashout_time1969-12-31 23:59:59
total_payout_value0.000 SBD
curator_payout_value0.000 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length14
author_reputation42,548,954,077,680
root_title"My Arduino fun projects: Part1 (UPDATED: with full code and schematics): Electricity data logging system"
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (1)