tag:blogger.com,1999:blog-29551506293838787542024-03-19T05:52:21.438-07:00Do it easily!Darshan Prajapatihttp://www.blogger.com/profile/14748477692933200980noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-2955150629383878754.post-73877577610342418582021-03-10T10:44:00.006-08:002021-03-10T10:44:59.130-08:00Homemade HomeKit supported night light with ESP32<p><i>Homemade?! Sounds like food, huh!</i></p><p><b><span style="font-size: medium;">What is the need?</span></b></p><p>I purchased various night lights and was not happy with brightness, color selection and ease of control. In the US, power outlets are generally at bottom of the wall so the night light plugged in that outlet does not illuminate the room well. So I needed a night light which I can attach to the wall at height to better illuminate the room.</p><p><b><span style="font-size: medium;">ESP32 Devkit selection</span></b></p><p><a href="https://docs.espressif.com/projects/esp-idf/en/latest/esp32s2/hw-reference/esp32s2/user-guide-saola-1-v1.2.html" target="_blank">ESP32-S2 Saola</a> devkits come with WS2812 LED. This is not a general LED that can be controlled with GPIO on-off. These LEDs can be chained in a strip and can be connected to a single GPIO to control the whole LED strip. On the board, there is only one LED and it's enough for my use as a night light.</p><p><b><span style="font-size: medium;">Software Development</span></b></p><p>I have used Espressif Opensource HomeKit SDK and Espressif IDF SDK to develop the night light functionality. I have made the source code available under GPL 3.0 license on <a href="https://github.com/iDarshan/ESP32-HomeKit-Night-Light" target="_blank">GitHub</a>. Follow the steps in README on that repo to build and use the project at your home.</p><p><b><span style="font-size: medium;">How I am using this at my Home!</span></b></p><p>I have shot a small video on how I am using this night light.</p><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen="" class="BLOG_video_class" height="266" src="https://www.youtube.com/embed/BrvPK77oO1I" width="438" youtube-src-id="BrvPK77oO1I"></iframe></div><br /><p><br /></p><p>Enjoy! Happy Coding!</p>Darshan Prajapatihttp://www.blogger.com/profile/14748477692933200980noreply@blogger.com0tag:blogger.com,1999:blog-2955150629383878754.post-66441547145035270382021-03-09T13:42:00.004-08:002021-03-10T10:39:31.806-08:00Debugging on ESP32 with OpenOCD and SEGGER J-Link<p>ESP32 is one of the popular chipsets for Wi-Fi and BLE-based IoT development. ESP32 provides the facility to flash the board via the UART port. However, there is no on-chip debugger available to step debug your program on ESP32. Either you need to buy an ESP Debugger kit or you can use your existing Debugger like J-Link to debug your program. Debugging with J-Link is not explained on official Esperessif Docs. Most Embedded developers have J-Link already available, so it's obvious to use that one instead of purchasing an ESP debugger.</p><p>In this post, I'll explain in detail how to use J-Link with ESP32 boards to debug your programs on Ubuntu 20.04 Linux OS.</p><p>Please make sure that you have <b>not</b> installed Segger J-Link drivers as we are going to use OpenOCD here.</p><p>Before we start the Software part, let's ensure proper hardware connection between J-Link and ESP32 board.</p><p>I am using ESP32-S2-WROVER and J-Link Pro for my setup.</p><p><b><span style="font-size: medium;">ESP32-S2 and J-Link Pro connection</span></b></p><p style="text-align: center;"><google-sheets-html-origin style="text-align: start;"></google-sheets-html-origin></p><table border="1" cellpadding="0" cellspacing="0" dir="ltr" style="border-collapse: collapse; border: none; font-family: Arial; font-size: 10pt; table-layout: fixed; width: 0px;" xmlns="http://www.w3.org/1999/xhtml"><colgroup><col width="254"></col><col width="166"></col></colgroup><tbody><tr style="height: 21px;"><td data-sheets-value="{"1":2,"2":"ESP32-S2-WROVER Pin & it's Function"}" style="background-color: #cccccc; border: 1px solid rgb(0, 0, 0); font-weight: bold; overflow-wrap: break-word; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: middle;">ESP32-S2-WROVER Pin & it's Function</td><td data-sheets-value="{"1":2,"2":"J-Link Pin & it's Function"}" style="background-color: #cccccc; border-color: rgb(0, 0, 0) rgb(0, 0, 0) rgb(0, 0, 0) rgb(204, 204, 204); border-image: initial; border-style: solid; border-width: 1px; font-weight: bold; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: bottom;">J-Link Pin & it's Function</td></tr><tr style="height: 21px;"><td data-sheets-value="{"1":2,"2":"39 (MTCK)"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0); border-image: initial; border-style: solid; border-width: 1px; overflow-wrap: break-word; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: middle;">39 (MTCK)</td><td data-sheets-value="{"1":2,"2":"TCK"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0) rgb(204, 204, 204); border-image: initial; border-style: solid; border-width: 1px; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: bottom;">TCK</td></tr><tr style="height: 21px;"><td data-sheets-value="{"1":2,"2":"40 (MTDO)"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0); border-image: initial; border-style: solid; border-width: 1px; overflow-wrap: break-word; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: middle;">40 (MTDO)</td><td data-sheets-value="{"1":2,"2":"TDO"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0) rgb(204, 204, 204); border-image: initial; border-style: solid; border-width: 1px; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: bottom;">TDO</td></tr><tr style="height: 21px;"><td data-sheets-value="{"1":2,"2":"41 (MTDI)"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0); border-image: initial; border-style: solid; border-width: 1px; overflow-wrap: break-word; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: middle;">41 (MTDI)</td><td data-sheets-value="{"1":2,"2":"TDI"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0) rgb(204, 204, 204); border-image: initial; border-style: solid; border-width: 1px; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: bottom;">TDI</td></tr><tr style="height: 21px;"><td data-sheets-value="{"1":2,"2":"42 (MTMS)"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0); border-image: initial; border-style: solid; border-width: 1px; overflow-wrap: break-word; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: middle;">42 (MTMS)</td><td data-sheets-value="{"1":2,"2":"TMS"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0) rgb(204, 204, 204); border-image: initial; border-style: solid; border-width: 1px; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: bottom;">TMS</td></tr><tr style="height: 21px;"><td data-sheets-value="{"1":2,"2":"3V3"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0); border-image: initial; border-style: solid; border-width: 1px; overflow-wrap: break-word; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: middle;">3V3</td><td data-sheets-value="{"1":2,"2":"VTRef"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0) rgb(204, 204, 204); border-image: initial; border-style: solid; border-width: 1px; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: bottom;">VTRef</td></tr><tr style="height: 21px;"><td data-sheets-value="{"1":2,"2":"GND"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0); border-image: initial; border-style: solid; border-width: 1px; overflow-wrap: break-word; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: middle;">GND</td><td data-sheets-value="{"1":2,"2":"GND"}" style="border-color: rgb(204, 204, 204) rgb(0, 0, 0) rgb(0, 0, 0) rgb(204, 204, 204); border-image: initial; border-style: solid; border-width: 1px; overflow: hidden; padding: 2px 3px; text-align: center; vertical-align: bottom;">GND</td></tr></tbody></table><br /><div>Following is the picture of ESP32-S2-WROVER, J-Link 20 Pin header and my setup.</div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRRewpHUVjTsIMLfewmJyZgeXYqqLtddsS4g1yEMpGvBBiSbGBvPFvhSAZgchEeMlUFY-C04X1cR6M7slYQu1hiVw1LHXXbLNhc6aAny6MEYUdxYp9OMenc2n10mt8srRp9DMO0yG35Q/s2048/IMG_4460.jpg" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="2048" data-original-width="1208" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRRewpHUVjTsIMLfewmJyZgeXYqqLtddsS4g1yEMpGvBBiSbGBvPFvhSAZgchEeMlUFY-C04X1cR6M7slYQu1hiVw1LHXXbLNhc6aAny6MEYUdxYp9OMenc2n10mt8srRp9DMO0yG35Q/s320/IMG_4460.jpg" /></a></div><br /><div><br /></div><div><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibtPYKPbLXHE2xLLMGHo4DZpITqQz9smkH_QtDsiJwgJ2r5j3UWsNrxSNz4jaGGO9vI-GvayWLbaPGqvcBkBfv2vl5z3NwJYRe9jCimQWpYT7MFfWztNHUeZam1aYFQw6pMSq6jSHttA/s408/JTAG-20-Pin-Header.png" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="312" data-original-width="408" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibtPYKPbLXHE2xLLMGHo4DZpITqQz9smkH_QtDsiJwgJ2r5j3UWsNrxSNz4jaGGO9vI-GvayWLbaPGqvcBkBfv2vl5z3NwJYRe9jCimQWpYT7MFfWztNHUeZam1aYFQw6pMSq6jSHttA/s320/JTAG-20-Pin-Header.png" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvB9APlQxroEebanNA27c26OziXLiTpaZPk-6iTSnuLqZgqSxIKiINkyeg8Oxkh2d_5JypTxmyWtR5bDwO88-g1sCFHOnO5qxzeWX-usKV1Yj27XCGu90R2xfi6s6hyphenhyphenyKnZI_m_oLtag/s2048/IMG_4464.JPG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" data-original-height="2048" data-original-width="1536" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvB9APlQxroEebanNA27c26OziXLiTpaZPk-6iTSnuLqZgqSxIKiINkyeg8Oxkh2d_5JypTxmyWtR5bDwO88-g1sCFHOnO5qxzeWX-usKV1Yj27XCGu90R2xfi6s6hyphenhyphenyKnZI_m_oLtag/s320/IMG_4464.JPG" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both; text-align: center;"><br /></div><div class="separator" style="clear: both;"><b><span style="font-size: medium;">Software Development Environment Setup</span></b></div><br /><div class="separator" style="clear: both;">In this section, we will focus on setting up the development environment for debugging. I am going to use Eclipse here. However, it is possible to use Visual Studio Code as well.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Follow this <a href="https://github.com/espressif/idf-eclipse-plugin/blob/master/README.md" target="_blank">guide</a> provided by Espressif to setup Eclipse with ESP-IDF Eclipse plugin.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;">Once you are done setting up your Eclipse and a sample project, build the project and check its building without errors. After that, let's configure debugger settings for the project so that we can debug the project right from Eclipse.</div><div class="separator" style="clear: both;"><br /></div><div class="separator" style="clear: both;"><b><span style="font-size: medium;">Debugger setup</span></b></div><div><ul><li>Right-click on the project, click on Debug As -> Debug configurations.</li><li>Click on "ESP-IDF GDB OpenOCD Debugging" in left column on Dialog.</li><li>Click on "New Configuration" Icon on top left corner.</li><li>You will see that new configuration is filled with default values.</li><li>Click on the second Debugger tab and modify "Config options:" field with following value.</li><li>-s ${openocd_path}/share/openocd/scripts -f interface/jlink.cfg -f target/esp32s2.cfg -c 'adapter_khz 2000'</li><li>Click on Debug button. Make sure that ESP32 and J-Link are connected to your PC.</li></ul><div><br /></div></div><div>You should see in the console log the OpenOCD logs and step debug started in the editor. Enjoy!</div><div><br /></div><div>Let me know if you face any problems in following these steps. Happy Coding!</div>Darshan Prajapatihttp://www.blogger.com/profile/14748477692933200980noreply@blogger.com3tag:blogger.com,1999:blog-2955150629383878754.post-23388363256928830172014-06-02T04:56:00.004-07:002021-03-02T14:41:56.356-08:00Video Colorspace conversion with ffmpegcolorspace and similar Gstreamer Plugin<div dir="ltr" style="text-align: left;" trbidi="on">
There are cases when we need colorspace conversion when decoding video with gst-launch tool of Gstreamer. We can use ffmpegcolorspace or videoconvert gstreamer plugin for the same.<br />
<br />
<br />
$ gst-launch-0.10 -v filesrc location=big_buck_bunny.mp4 ! qtdemux ! vmetadec ! 'video/x-raw-yuv,format=(fourcc)UYVY' ! ffmpegcolorspace ! 'video/x-raw-yuv,format=(fourcc)I420' ! autovideosink<br />
<br />
<br />
Above example gives you idea about how to tell ffmpegcolorspace plugin about from which format to convert and in what format to give output.<br />
<br />
'video/x-raw-yuv,format=(fourcc)UYVY' ! ffmpegcolorspace ! 'video/x-raw-yuv,format=(fourcc)I420'<br />
<br />
<br />
So just remember above pipeline to convert from UYVY colorspace to I420 colorspace. You can change formats in above pipeline as per your need.<br />
<br />
In newer version of gstreamer, ffmpegcolorspace is replaced with videoconvert plugin. So above pipeline for newer version of gstreamer can be represented as below.<br />
<br />
'video/x-raw-yuv,format=(fourcc)UYVY' ! videoconvert ! 'video/x-raw-yuv,format=(fourcc)I420'<br />
<br />
Hope that's clear. Let me know should you have any further questions !</div>
Darshan Prajapatihttp://www.blogger.com/profile/14748477692933200980noreply@blogger.com0tag:blogger.com,1999:blog-2955150629383878754.post-26071524650981858652013-09-05T23:00:00.001-07:002021-03-02T14:42:37.153-08:00Take backup of your Android phone<div dir="ltr" style="text-align: left;" trbidi="on">
Always you might be wondering that how to take backup of your phone if your Phone manufacturer does not provide you backup software. Also you may have seen option of "Backup password" in your Android phone. Do you wonder what's that ?<br />
<br />
Following is the way to backup your Android phone and it will answer all your above questions.<br />
<br />
1). You need to have "adb" tool in your system. If you don't know what's this, then simply install Android SDK in your system by following procedure on developer.android.com. If you don't want to install whole SDK then just search for adb on google and just download single file for adb.<br />
<br />
2). Once USB debugging is on, connect your phone to your PC. Go to the directory where "adb" is placed. Now on the command prompt or terminal write command "adb devices" (for Linux "./adb devices"). The output of the command should list your device with its serial number. If device is not listed then go here and do the settings needed for your device.<br />
<br />
3). Now once your device is listed in "adb devices", give command " adb backup -apk -shared -all" (For Linux "./adb.."). This command will ask for confirmation on your phone. Give confirmation and password if you want to encrypt backup file on your phone screen. This will backup everything on your phone including data on your memory card. In your current directory backup.ab file will be created. Keep it safe.<br />
<br />
4). When you want to restore your backup after factory reset of your phone, connect your phone and give command "adb restore <your backupfile location>". You will need to provide password on screen of phone if backup file is encrypted. Now wait till command completes its task and you have prompt available again.<br />
<br />
That's it. You have your data back again. Enjoy !<br />
<br />
Let me know if you have any problems.</div>
Darshan Prajapatihttp://www.blogger.com/profile/14748477692933200980noreply@blogger.com0tag:blogger.com,1999:blog-2955150629383878754.post-80129245045578718762013-09-03T01:25:00.000-07:002013-09-05T22:30:19.992-07:00Flashing Galaxy Nexus with Android 4.3<div dir="ltr" style="text-align: left;" trbidi="on">
In this post I will let you know how to flash your Galaxy Nexus having device type "maguro" and yakju** build of Android OS, with latest Android 4.3 factory image provided by Google. (<span style="color: red;">Disclaimer: I have flashed my own phone in the following described way. However do the procedure at your own risk. Don't blame me if you brick your phone.</span>)<br />
<br />
1). First of all check that your Galaxy Nexus has device type "maguro" and OS build name "yakju**". You can know this with Android app Android Info under section Software. You can download at <a href="https://play.google.com/store/apps/details?id=Android.Info">https://play.google.com/store/apps/details?id=Android.Info</a><br />
<br />
2). Now you need to have "adb" and "fastboot" tool in your system. If you don't know what's this, then simply install Android SDK in your system by following procedure on <a href="http://developer.android.com/">developer.android.com</a><br />
<br />
3). Once you have installed "adb" and "fastboot", download the Android 4.3 factory image "yakju" for Galaxy Nexus "maguro" from <a href="https://developers.google.com/android/nexus/images#yakju">here</a>.<br />
<br />
4). Now open the command prompt (in windows) or Terminal (in Linux). Write "adb" and press enter. It should not give you message like "No such command". Similarly enter "fastboot" and press enter. It also should not give message like "No such command". If both adb and fastboot are working fine its time to move ahead.<br />
<br />
5). Now extract the factory image downloaded in step 3.<br />
<br />
6). Turn USB debugging on in your Galaxy Nexus. Go to Settings and then Developer options and turn on USB debugging. If you are not able to see the Developer options then go to "About Phone" in Settings and press on Build number 7 times. After that you will be able to see the Developer options.<br />
<br />
7). Once USB debugging is on, connect your phone to your PC. Now on the command prompt or terminal write command "adb devices". The output of the command should list your device with its serial number. If device is not listed then go <a href="http://developer.android.com/tools/device.html">here</a> and do the settings needed for your device.<br />
<br />
8). Once device is listed in output of "adb devices" command, go to the extracted factory image directory in command prompt or terminal.<br />
<br />
9). First you need to unlock your boot loader. So first reboot your phone into boot loader by giving command "adb reboot bootloader". You can see on the phone the bootloader screen. Now give command "fastboot oem unlock". This command will unlock the bootloader. A confirmation dialogue will be shown on phone screen. To select Yes, drag with volume up and down button and press power button to select. When you press Yes, it will again reboot the phone and the bootloader screen will be shown again.<br />
<br />
10). Now you are in the directory of extracted factory image. In the directory you can see file named flash-all.bat, flash-all.sh and others.<br />
<br />
11). Windows users execute the flash-all.bat file by simple entering "flash-all.bat" on command prompt and then press enter. Linux users execute the flash-all.sh file by writing "./flash-all.sh" on terminal and then press enter. Make sure you are in the directory of extracted factory image.<br />
<br />
12). Now wait till script flashes factory image on your phone. Don't unplug phone. Once all is done, you phone will reboot with new Android 4.3. Enjoy !<br />
<br />
13). Once your phone is up, you can lock your boot loader again. To do so, enable USB debugging on phone, connect to PC, and give command "adb reboot bootloader". Once boot loader screen is shown on phone, give command "fastboot oem lock". Your phone is lock and secure again. Enjoy once more !<br />
<br />
<br />
Let me know if you face some problem in this.</div>
Darshan Prajapatihttp://www.blogger.com/profile/14748477692933200980noreply@blogger.com0