Mar 2, 2023

Amplifieing analog audio output from 3.5mm audio jack with PAM8403 amplifier

Aim

In this post we will develop an amplifier which amplifies 3.5mm analog audio output, You can use the circuit as a speaker for PC.

Introduction

Required Electronic Components:
1. PAM8403 Class D 3W amplifier
2. 3.3V 5.5V FT232RL FTDI USB to TTL Serial Adapter Module
3. 5V 3A USB power supply
4. USB Cable, A-Male to Mini-B Cord USB cable
5. 3W Speaker
6. Jumper Wires
7. AUX Cable

Detailed video here: https://youtu.be/CaUC_d9g3oc

Feb 27, 2023

C#: Convert any time to time in any timezone

You can use this to convert any server time to india time or any other time zone
here's possible list of all zone IDs which can be used in this method: https://nodatime.org/TimeZones

First add reference to NodaTime nuget package which is built by the ultimate Jon Skeet

Pun intended
/*
1. Jon Skeet can divide by zero.
2. When Jon Skeet's code fails to compile the compiler apologises.
3. If Jon-Skeet's program fails to compile they fix the compiler.
4. Jon Skeet coded his last project entirely in Microsoft Paint, just for the challenge.
5. Jon Skeet keeps a daily backup of the Internet on his USB pendrive.
*/

Jon Skeet handles all my exceptions
try
{
    insert.code.here();
}
catch(Exception ex)
{
  JonSkeet(ex);
}

here's the method
public DateTime ConvertToTimeZoneFromUtc(DateTime utcDateTime, string timezone)
{
    var easternTimeZone = DateTimeZoneProviders.Tzdb[timezone];
    return Instant.FromDateTimeUtc(utcDateTime)
                    .InZone(easternTimeZone)
                    .ToDateTimeUnspecified();
}

usage:
string zoneID = "Asia/Kolkata";
var date = ConvertToTimeZoneFromUtc(DateTime.Now.ToUniversalTime(), zoneID);

SkeetOverflow link: https://stackoverflow.com/questions/75580559/hot-to-change-the-default-datetime-date-of-app-hosted-on-cloud-server-side-to-m/75581290

Jan 28, 2023

Lifetime unlimited money through manual SWP in mutual funds


The ₹1 lac example:

  1. Invest a lump sum in multiple high performing equity mutual fund e.g. ₹1lac
  2. Wait for 1+ year - yea! Let it grow for sometime
  3. Withdraw ₹1k per month on a fixed date (to minimize loss: withdraw only if mutual fund returns are greater than or equal to 13%)

More realistic example

Suppose you have ₹1k society maintainance bill:

Real-Time excel calculations

With initial investment of ₹1,00,000
Here you can see I have withdrawed ₹1,64,759 in 10 years
and still ₹87,361 is remaining in the account
If you keep withdrawing infinitely still money remains in the account
Download Withdrawl plan

Notes:

  1. mutual funds are subject to market risks, market down huwa to samjho paisa gaya
  2. works well if you choose the right mutual fund and start SWP after one year.
  3. Most trading/mutual fund platforms do not allow auto SWP of mutual funds, here's BSE circular https://www.bseindia.com/markets/MarketInfo/DispNewNoticesCirculars.aspx?page=20220713-1. Hence manual SWP needs to be done.
  4. its just a theory, try at your own risk

https://github.com/nitinjs/unlimited-money

Jan 20, 2023

Ethical hacking: Hassle free logging of IP address of any person

Aim

In this article we will write static HTML and javascript client side code to log the IP address of the person just by sending him the web page link.

Introduction

PostMail: used to send email using javascript.
IpApi.co: used to get IP address and geolocation details at client side javascript

First Let's create simple jQuery plugin to send GET the CORS resource hosted at ipapi.com.
With recent version of jQuery it forces us to follow CORS policy so I am using plain JavaScript

jQuery.getCORS = function (source, func) {
    var xmlHttpRequestObject;
    if (window.XMLHttpRequest) {
        xmlHttpRequestObject = new XMLHttpRequest();
        if (xmlHttpRequestObject != null) {
            var sUrl = source;
            xmlHttpRequestObject.open("GET", sUrl, true);
            xmlHttpRequestObject.onreadystatechange = function () {
                func(xmlHttpRequestObject.responseText);
            };
            xmlHttpRequestObject.send();
        } else {
            func("Error creating XmlHttpRequest object. Client is not CORS enabled");
        }
    }
};
 

Following code retrieves the IP address of the user at client side

$.getCORS('https://ipapi.co/json/', function (data) {
	console.log(data);
};
 
For example following is response from ipapi for 8.8.8.8 google ip address:

Now lets get API key from PostMail
Go to the site https://postmail.invotes.com/, enter your email address and after submission you will get link in the email.

POST request to send email from javascript using postmail API

var data = {
	"access_token": "PostMail Access Token Here"
};

data['subject'] = "Send email from javascript";
data['text'] = "This is test email";

$.post('https://postmail.invotes.com/send',
    data,
    function () {
        //success
    }
).fail(function () {
    //error
});


Final version:


    
    

    
Loading...
]]>

This code is available on github, editable at stackblitz⚡️

References

How to send an email from JavaScript: https://stackoverflow.com/a/36656479/223752
PostMail: https://postmail.invotes.com/
IP geolocation API: https://ipapi.co

Note: I am not affiliated with PostMail or ipapi.co

Oct 31, 2022

Arduino for Beginners: IoT basics

Aim

In this article we will have high level overview of Arduino, its parts, sensors and how we can use it with Internet of Things aka IoT sensors. I will take you step by step in creating your first simple Arduino project and reading data from IoT temperature sensor.

Introduction

Arduino is open source programmable circuit board which you can use for creating electronic hardware. This board contains a microcontroller which can be programmed to sense and control the electronic components.

Following image depicts one of the most popular Arduino boards “Arduino UNO” and its components on the board:



1.     Microcontroller: This is the brain of the Arduino where the programs are stored, on UNO board the microcontroller is based on ATmega328P integrated circuit(IC).



2.     USB Port: The USB port can be used to powering up the board and also to connect to PC and flash programs on the board

3.     USB to Serial chip

4.     Digital Pins: Pins 0-13 can be used for digital input or output

5.     Analog Pins: These pins can read the signal from an analog sensor and convert it to digital



6.     5v, 3.3v out Pin: This pin supplies 5/3.3 volts of power to your electronic sensors and circuits

7.     GND Pin: This pin is used to allow the flow of leakage and fault current. Sudden rise in flow current will damage the equipment, hence it is a protection.

Breadboard: The breadboard allows you to create temporary prototypes and experiment with different circuit designs without permanently soldering the circuit together.



 

Jumper Wires: The electronic components are connected to each other using Jumper wires, electricity flows through these jumper cables, Jumper wires are of three types- Male to Male, Male to Female and Female to Female



LED: Light Emitting Diode, an LED can emit any color depending on its make, following LED emits blue light.



Resistor: Resistors resist the flow of electricity and the higher the value of the resistor, the more it resists, and the less electrical current will flow through it.



Your first Arduino Sketch

We can program the Arduino using C/C++ language, the programs in Arduino are called as Sketch, the sketches are saved as “.ino” extension. To write the programs we need to download the Arduino IDE which is available at https://www.arduino.cc/en/software

A minimal Arduino sketch consists of only two functions:

1. setup(): This function is called once when a sketch starts after power-up or reset. It is used to initialize variables, input and output pin modes, and other libraries needed in the sketch. It is analogous to the function main().

2. loop(): After setup() function exits (ends), the loop() function is executed repeatedly in the main program. It controls the board until the board is powered off or is reset. It is analogous to the function while(1).

 





Pin Connections

The above sketch turns the LED on and off each 1 second interval.

Sensors

A sensor, in simple terms, is used to sense its environment, meaning it records a physical parameter, for example temperature, and converts it into an electronic signal.



In this article we will use the temperature sensor.




LM35 is a classic Analog Temperature Sensor. LM35 has 3 pins: VCC, Data and GND.

Place the LM35 anywhere horizontally on your breadboard, the flat side of the sensor must be facing you. Then, connect three wires under the three pins of the sensor.

The wire on the left will go to the 5v pin on the Arduino.

The middle wire will go to A1 (analog pin 1).

The wire on the right will go to GND (-) on the Arduino.

 

Upload below sketch to Arduino.

 



You can see the program output in the Arduino serial monitor console



References

1.     Temperature sensor Arduino project https://bit.ly/3SGSuJ8

2.     Uploading Arduino sketch https://www.youtube.com/watch?v=wzc97nv8heU

3.     Buy electronic components and sensors https://robu.in/

4.     Arduino Wikipedia https://en.wikipedia.org/wiki/Arduino

5.     Arduino IDE https://www.arduino.cc/en/software

6.     Arduino starter kit https://amzn.to/3SEvASw

7.     Make Electronics book pdf https://bit.ly/m4k3elekt

Aug 22, 2022

TicWatch Pro - my new smart watch

Long ago I saw this watch "TicWatch Pro", I was hesitant to buy smart watches because their battery life and thinking that whats the use of buying a smart watch "Its just gonna just show Time", Now in 2022 I purchased latest version, I am quite impressed by TicWatch Pro features. 


 

  1. Dual layerd display - old digital style mode and smart mode
  2. Upto 30 days battery life in essential mode
  3. Sleep Tracker
  4. Physical exercise tracker
  5. GPS
  6. Wi-Fi
  7. Bluetooth - recieve and dial phone calls from watch (futuristic)
  8. Heart rate meter
  9. Phone Notifications (I like this feature most)
  10. Waterproof

To speed up the watch, custom wear OS rom can be installed, here's xda guide

Here's the review posted by random youtuber: