Wednesday 29 November 2017

A Tiny Tiny Solar Project

    
Solar energy is radiant light and heat from the Sun that is harnessed using a range of ever-evolving technologies such as solar heating, photovoltaics, solar thermal energy, solar architecture, molten salt power plants and artificial photosynthesis. - Wikipedia


Overview

    It is the best source of renewable energy that we can harness. There are two type of solar energy systems on grid and off grid. On grid is the one which is connected to your electrical company and off grid will store energy directly to battery. I have built off grid system. As with all type of energy generation systems, initially it requires some invest but you can start with very small project to understand all the components/process. That's what I did.  Let's have a look at some of the advantages and disadvantages first and then I'll describe all the components.


Advantages


  • Pollution free renewable energy source
  • Virtually no maintenance as solar panel last over 30 years
  • Excess power can be sold to electrical company for on grid system
  • Safer than traditional electrical current
    
Disadvantages


  • High initial cost
  • Needs lot of space for big systems
  • Cloudy days will generate less power


    For solar energy generation there are 4 main components solar panel, solar charge controller, battery and inverter. Let's get right into introduction of each components.


Solar Panel


    Solar panel also known as photovoltaics (PV) is a magical(at least that's what I feel 😃) component that converts solar energy to watts. It is usually rated by watts(W). You can buy solar panel anywhere ranging from 10W to 300W or even higher! It also has different voltage ratings which are mostly 12 volts(V) or 24 volts(V). Solar panel has two wires for output positive(+) and negative(-).


    Let's learn some basics regarding volts, amperes and watts. It's rather simple volts multiplied by amperes equals to watts ( V * A = W ). So for an example a 12V panel with 1A rating will generate 12W of energy. Well not quite, you see when it comes to solar panels a 12V panel can generate up-to 18V on fine sunny day !!!



    I have bought 20W 12V panel. As per it's specifications it has max voltage (Vmp) 17.7, max current/ampere (Imp) 1.13 and rated power (W) 20 +/- 3%. So as per our formula 17.7 V * 1.13 A = 20.001 W. There are many companies which create solar panel and there rating may vary.


    You can also connect multiple solar panels to increase volts or amperes. In serial connection where the voltage increases, you connect negative of one panel to positive of other panel and rest connections to charge controller. One thing to note here is, it is highly recommended for both solar panel to have equal ampere ratings. So panels with same company is safe bet. In parallel connection where the amperes increases, you connect positive wires together and negative wires together. For this type of connection voltage ratings of both panel should be equal.


Solar Charge Controller


    The power generated by solar panel is not consistent and obviously it can't get generate energy at night. So we need to store the energy in battery. Battery requires proper charging, a charger which provide power in incremental form till it fully charges. This is where charge controller comes into picture.


    Solar charge controller is special type of charger, it uses power generated from solar panel and stores it into battery. A solar charge controller generally have 6 connections. It consists 2 connection (positive and negative) each for solar panel, battery and load. Solar panel and battery are self explanatory, load is where you connect inverter etc.


    We need to connect battery first so that charge controller powers up and initial setup can be done. In advance charge controllers we can set various settings like max voltage of battery, load on voltage, load off voltage etc. Charge controller also has voltage and amperes ratings. There are two types of charge controllers PWM (Pulse width modulation) and MPPT (Maximum power point tracking). I won't get into more details about this but MPPT is more efficient algorithm and are also considerable more expensive than PWM.





    I have bought 12V 10A PWM charge controller. This means it can handle n number of 12V panels as long as it's total ampere rating is not more than 10A. Since my solar panel has 1.13A rating it is more than capable. In fact I can add approx 8 more of these panels. To be on safer side always stay 1 or 2 amperes blow the charge controller rating. Solar and Load LEDs indicate that charge controller is getting power from solar panel and load is active. 2 LEDs in between indicate status of battery.


    There are 3 stages for charging a battery bulk, absorb and float. When battery is less than 80% charge bulk mode is used where maximum amount of amperes are stored in battery. In 80% to 100% the absorb mode is used where amperes decrease as the voltage increase. The float mode is activated once battery is 100% charged, this mode will trickle charge the battery to keep battery at max level.


Battery


    Do NOT use car batteries !!! There are two reasons for that. One, Car batteries have higher CCA (Cold Cranking Amps) which are required to start a car we don't need that and Two, it should not be discharged below 90%. We can use batteries which are specifically built for inverters.


    There are 4 types of inverter batteries:


  • Lead-acid
  • Sealed lead-acid(SLA)
  • Sealed lead-acid(SLA) gel
  • Sealed lead-acid(SLA) AGM


  1. Lead-acid batteries are cheapest and they are similar to old car batteries where you have to add battery specific purified water. Also as it contains liquid it should be mounted in upright position.
  2. SLA batteries are also known as maintenance free as it is sealed and does not require hassle of adding water etc.
  3. The gel type is also SLA type of battery which has sulphuric acid in gel form. It is shock and vibration resistant and can be mounted any any direction.
  4. The SLA AGM battery is most expensive comparing to others, but has it's advantages also. It has longer life and can be deep cycled meaning can be discharged at significantly lower level.





    I have bought 12V 12AH SLA battery as it's safer then flooded type and cheaper than other batteries. AH stands for Ampere per hour. Simply put a 12AH battery can last 12 hours if the consumption is 1AH, but yes there is but here too, if you fully discharge battery before charging it will greatly reduce it's life cycle. It is recommended to not use battery below 50% of it's capacity. So we should consider 12AH battery as only 6AH battery.


    How do you measure battery charge level you may ponder ? Well, a typical SLA battery is full at 12.70V. Gel and AGM batteries have different levels. Battery is at 50% when it reads 12.20V, 25% at 12.00V and dangerously low 10% at 11.51V. You can easily check the voltage level with multimeter. So you should not discharge or stop using battery beyond 12.20V to get best possible life cycle.


    Battery charging is whole different story and it can be confusing at first, but solar charge controller takes care of it easily. SLA battery charges from current state of voltage to 14.4V !!! This is normal, when it is on stand by mode it will gradually be back to approximately 12.7V. Again to maximise life cycle if there is setting available in charge controller you should limit max voltage limit to 14.1V.


    You can also connect multiple batteries just like solar panels. Serial connection will increase total voltage and parallel connection will increase amperes. Again it is recommended to connect batteries of same type and company.


Inverter


    We get Alternating Current(AC) from wall plugs, which are converted to Direct Current (DC) via appliances’ converter. Batteries store in DC form, but we can't directly use it as appliances require AC. Inverters are used to convert DC to AC. Inverter either convert to 220V(European/Asian etc countries) or 110V(U.S. etc countries). DC flows in linear format while AC flow in wave format.


    There are two types of inverters:


  • Modified sine
  • Pure sine


  1. Modified sine inverter converts to AC in block type wave format which means it’s not perfect conversion. Small appliances which are not sensitive for perfect wave format will not have any issue but some heavy and sensitive appliance for example sound system might not work properly. This type of inverters are cheaper and widely available.
  2. Pure sine inverter as you might have guessed it, it has proper wave format. As you can expect they are expensive, big and heavy in size.





    I have bought 300W 220V modified sine inverter. You can connect it to load on charge controller of directly to battery via proper battery terminal connectors. Inverter has lot of components which are used to convert DC to AC, so it will use lot of power in conversion process.


Tools


    Additional tools required are wires, soldering iron, soldering wire, soldering paste, wire spade connectors and crimping tool. Optional tools are multimeter and small digital voltage LED screen.


Future Upgrade


    In future I will add additional battery for more storage and solar panel for faster charging. I would also change solar charge controller to one with small LCD screen which will display various parameters and has few buttons so that I can change some settings. I would also purchase USB buck converter which will decrease 12V to 5V and has USB port so I can charge small devices like mobiles, tablets etc.


Conclusion


    I have learnt a lot while building and monitoring this system. If you have read this far then give a pat on your back 😎 and I really hope you got some inspiration to build solar energy system. Leave your feedback, queries and suggestions in the comment section below. I will be more than happy to help you out. Thank you.

Update #1: This setup costed me 6,000 to 7,000 INR. Also this can be easily setup in rural area since it does not require to be connected with grid.


    In the end I will only say one thing that I keep telling my friends and family:
Keep Learning


Friday 20 May 2016

Rails on Ubuntu 16.04

Initialization



Update your system.


sudo apt get update


Install all ruby and rails related dependencies.


sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev


Installing ruby



There are various ways you can install ruby. We are going to install ruby with rvm. Rvm lets us manage various versions of ruby. It also provides container for various gem bundles for different applications. This is very convenient for multiple applications development.


Install rvm related dependencies.


sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev


Get latest stable rvm version.


curl -L https://get.rvm.io | bash -s stable


You may encounter an error regarding signature verification. Just follow the instructions on screen and try above command again.


Execute rvm file to load on terminal.


source ~/.rvm/scripts/rvm


Check rvm version.


rvm -v


Install ruby version.


rvm install 2.3.1


This was the latest ruby version while writing this blog. This might take some time, have a coffee or a tea if that’s your thing. :)


Check the ruby version.


ruby -v


Make installed ruby version default.


rvm use 2.3.1 --default


Configuring git



Git is a great version management for your applications. Head towards GitHub and register your account if you haven’t already.


Make color code for git information true.


git config --global color.ui true


Enter your GitHub name and email.


git config --global user.name "YOUR NAME"
git config --global user.email "YOUR@EMAIL.com"


This is important because every Git commit uses this information, and its immutably baked into the commits you start creating.


Generate ssh key. (more information)


ssh-keygen -t rsa -b 4096 -C "YOUR@EMAIL.com"


Just keep pressing enter and ssh key will be generated.


Display the content of generated key file with following command.


cat ~/.ssh/id_rsa.pub


Copy the content and paste it in your GitHub ssh setting.


Enter following command to verify connection.




Installing Rails



Rails requires JavaScript run-time so we will install Node.js. This lets us use CoffeScript and asset pipeline.


curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -


sudo apt-get install -y nodejs


Remember the container I talked about earlier, we will create one for rails installation.


rvm gemset create rails-4.2.6


At the time of writing this blog latest stable version of rails was 4.2.6, so we created gemset related to that.


List gemsets.


rvm gemset list


Use created gemset.


rvm gemset use rails-4.2.6


This will select rails-4.2.6 gemset. You can verify with list command.


gem install rails -v 4.2.6


This will install rails and its dependent gems. Dude that’s going to take some time play some game in your phone, also let me know if really good.


All done ! Check the version just to make sure.


rails -v


Setup MySQL



Rails by default uses SQLite database, but we will install MySQL as its more robust.


sudo apt-get install mysql-server mysql-client libmysqlclient-dev


While installation you will be asked in enter password for MySQL root user, keep it secure one.


Creating first app



rails new myapp -d mysql

This will create rails app skeleton.


Move into application directory.


cd myapp


Change the config/database.yml to set username and password for MySQL setting.


nano config/database.yml


Create database and run application.


rake db:create


rails s


Navigate to http://localhost:3000 to check you application.


Congratulation now your Ubuntu is rocking with rails.

Conclusion


  We have come to an end of installation guide. There are many other packages and awesome gems to be installed but that depends on application requirements. Anyways this is just a beginning. Happy coding !!!



Saturday 23 April 2016

Ubuntu 16.04 LTS along with Windows

Background:


            I had Windows 10 (upgraded from 7) with Ubuntu 14.04 32-bit. I wanted to upgrade to 16.04 so started researching about it. While digging into my system I found out that I have 4 GB ram and yet I installed 32-bit version. So I decided to remove 14.04 and install 16.04 with 64-bit architecture.

Getting started:


            Download the ISO from Ubuntu site and burn it to disk or make a bootable USB flash drive. Make sure that you have proper architecture, 32-bit if you have less than 3 GB else go for 64-bit.

Partitions:


Let talk about hard disk partitions a little because it’s important for advance but rather easy installation. Each hard disk can have 4 primary partitions and that is where OS can be installed.  Now that doesn’t mean you can only install 4 OS in one hard disk. This is where extended and logical partition comes into picture.

            You can create 3 primary partitions and 1 extended partition. This extended partition can have multiple logical partitions. So you can either create 4 primary partitions or create 3 primary partitions and 1 extended partition (which is primary partition in a way) with multiple logical partitions.

            Open ‘Computer Management’ application from start menu and click on ‘Disk Management’. Here you should be able to see various hard disks and its partitions.



            So basically in windows file system each partition is represented as drive letters (c: d: e:  etc.,). In Linux, file system its bit different, it has sda which represents hard disk and sda1, sda2, sda3 etc. as partition representation.

As you can see top three entries without any file system are Ubuntu OS and the forth entry is reserved by laptop manufacturer for OS restore. Rest 4 are NTFS partitions from which one has Windows OS installed (c:), one has boot for Linux (e:) which was created by Ubuntu (more on this later), one has my data (g:) and last one (d:) is reserved by laptop manufacturer for drivers etc.

            You can install Ubuntu in as small as 15 to 20 GB but I have used approx. 46 GB. You need to free up space from either primary or extended partition via disk management utility or various third party tools available online.

Installation:


            Use the disk or bootable USB flash drive that you created earlier and restart the system. Change boot order so that the disk or USB flash drive is accessed prior to hard disk.

Once media is accessed you will see various options as below:

·         Try Ubuntu without installation
·         Install Ubuntu
·         OEM install (for manufacturers)
·         Check disk for defeats

Select Install Ubuntu and let the installation load which might take a little time. You will be greeted at Welcome screen where you should choose language. After continuing you should see Preparing to install Ubuntu screen with following options:

·         Download updated while installing Ubuntu
·         Install third-party software for graphics and Wi-Fi hardware, Flash, MP3 and other media

First options is not selectable because you are installing directly from media, if you chosen
‘Try Ubuntu’ first and installed from there then you should be able to select this option. You should select second option as it’s recommended.

            When you click continue you might get pop up ‘Force UEFI installation?’ UEFI is a new bios firmware that is used with newer OS and hardware. If you have Windows 8 or later you should continue with UEFI method. As mentioned before I had Windows 7 and upgraded to Windows 10 so I did not continue with UEFI method, instead I clicked go back.

            You should see Installation type screen with following options:

·         Install Ubuntu alongside them
·         Erase disk and install Ubuntu
·         Something else

I got first option because I already Ubuntu prior to writing this blog. Select the ‘Something else as we want to custom install Ubuntu.



            Above image is of ‘Gparted’ application from my installed Ubuntu which we will use here as a reference to custom install Ubuntu. Remember the e: drive I mentioned that is where Ubuntu updated boot record. You should see a screen which look little similar to shared image but with some options below.

Swap


‘Swap’ is used for paging. It is used when you RAM memory runs out. You should keep its size as 1.5 to 2 times of RAM memory. Select ‘Unallocated’ and click on ‘+’ button.

·         Size : As I have 4 GB RAM I have kept 6000 MB
·         Type of the new partition : Primary
·         Location for the new partition : Beginning of this space
·         Use as : Swap area

Root (/)

           
This is where Ubuntu OS is installed along with installation of software and updates. Keep this partition size at least 10 to 15 GB.  Again select ‘Unallocated’ and click ‘+’.

·         Size : As you desire. I have allocated 20000 MB
·         Type of the new partition : Primary
·         Location for the new partition : Beginning of this space
·         Use as : Ext4
·         Format : true
·         Mount point : /

Home


            Home is where user data is stored this is similar to user documents in Windows OS. You know the drill select ‘Unallocated’ and click ‘+’ (You are becoming pro now J).

·         Size : Remaining space
·         Type of the new partition : Logical
·         Location for the new partition : Beginning of this space
·         Use as : Ext4
·         Format : true
·         Mount point : /home

            That’s it tuff part is over. Click “Install now” and Ubuntu will start installing. While it is being installed in background you are presented with few basic settings like location, keyboard layout and login credentials.

            After installation is competed you might get a pop up to set boot record for Ubuntu click ok. You might also get pop up regarding UEFI, select the option you selected earlier. Restart PC and remove bootable media. You should see menu with different OS options.

OOPS !!!


            If you do not see Windows OS option in boot menu don’t panic. Boot into Ubuntu, open terminal and enter following command:

            sudo update-grub

            Restart PC and you should see Windows OS option in menu.

Conclusion


            We have reached to the end of Ubuntu 16.04 LTS Installation. If you have any queries or feedback let me know in comment section below.