All Posts By

Kunal Gautam

RTC Clock [ DS3231 ] and FM Receiver [ TEA5767 ] Experiment

By | Arduino Code

Preface:

I’ve always fancy of using battery power devices, I run many of the my projects on Battery only, which are powered by Solar Panel(s). Music has very important place in my day to day life, and I didn’t have any speaker which can run on battery. Hence I purchased Audio amp (PAM8403), and made a custom speaker powered by 5v DC. Although plugged to Raspberry Pi 1 B+ and using Internet Radio Stream, I found it very interrupting whenever there is a power cut. As my routers are not powered by Battery, there is Internet disconnection to Raspberry Pi and I can not play Internet Radio.

Hence to the call of the requirement, I purchased TEA5767 Module with Antenna and Audio Jack. Since I am planning to do some alarm clock type music system, which will turn on at required time and turn off in night, hence I added DS3231 RTC Module.

In future I might consider controlling it via wireless system (ESP8266 or NRF24l01). But let start this project with simple demo. Both of the module use I2C interface hence I used to share the wires between them.

Libraries:

Default installed library : https://www.arduino.cc/en/Reference/Wire

I’ve used following Library, which were not installed by default.

Library for DS3231(Available for install via Library Manger in Arduino): https://github.com/adafruit/RTClib

Library for TEA5767 : https://github.com/mroger/TEA5767

Pinouts:

BoardI2C pins of DS3231 and TEA5767
Uno, EthernetA4 (SDA), A5 (SCL)
Mega256020 (SDA), 21 (SCL)
Leonardo2 (SDA), 3 (SCL)
Due20 (SDA), 21 (SCL), SDA1, SCL1
5vVcc
GNDGnd

Project Description:

After pushing the code to microcontroller (Arduino Uno in my case), the default station set in the code is played. I open Serial Console, set baud rate at 115200 and send the desired frequency between 88MHz to 108MHz, and press send button. It play that FM station. Alternatively I can use to send “+” or  “-” keys, to scan FM frequency and halt whenever a broadcasting frequency is found.

Final Word:

There are other options like Mute sound, or put device to sleep in the GitHub code of TEA5767 which I have not included in this code.

Yes this is not consumer friendly project, as there is no option of controlling the device easily. The device can have option of using buttons or using wireless communication methods. I’ll leave that part of exploration with my dear readers. Feel free to contact me via https://ikunal.in/contact/

 

I wish I could tell you…

By | Editorial, Poem

I wish I could tell you, what’s going on in my mind…

I wish I could tell you…

A thousand things I want to have…. and a thousand things I want to do…
But as I get near to them… I feel that my reality isn’t even true.

I wish I could tell you the things going around.
I was just looking for simple happiness. Even that I could not found…

There are voices in my head, and I listen to music to shut them down.
But all I could listen are just noises… to calm your soul there aren’t enough sounds…

There are a million things I want to show and a million things I want to say.
I hope that God is looking down on us… and just to get enough time, I pray…

Not sure if there are enough words or there is enough time.
And to tell you all that…I’m just making this rhyme…

 

-Anurag Upadhaya

Controllers in Laravel 5.3

By | Laravel

As we have seen in previous example of passing arguments to view, the route file actually looks ugly and hard to read. As we know Laravel use MVC (Model View Controller) , it is best to use a controller for that example. In short it is best to include any logic in controller. A controller may have one or more than one action.

Lets understand controller with an example. To create an boilerplate code for an controller we have to pass following command in root of the project directory.

php artisan make:controller UsersController

The above command will create UsersController.php file under app/Http/Controllers/ directory with the required boilerplate.

Now we will delete the users route and replace this with following code:

By saving the file and running laravel development server, we will see the same output. This time logic are placed inside controller file. This not only make code readable, but very easy to understand. Consider scenario where there are lot of users related function such as create, delete etc. All logic will be placed inside this controller file under different function/method. And we will call required function in the routes file. Example is given below.

Route::post('users', 'UsersController@create');

Route::delete('users', 'UsersController@delete');