Kacang Bawang

ESP8266 SDK: os_printf() prints garbage, uart_init() doesn’t work…

Espressif SDK provides a function os_printf() for printing to the debug uart. However, when used out of the box it prints garbage. What gives?

Consider a default project with the following in user_main.c.

Compile, run, what do you see? That’s right – garbage. Well, it’s not really garbage, it’s actually outputting “hello world” at the default (non standard) baud rate. Ok, easy enough – we’ll just set the baud rate using uart_init() function from the SDK! Oh, wait… that function is not defined in any header that comes with the SDK… Paging Espressif, please pick up the white courtesy telephone!

That’s ok, there’s an easier way – we will use uart_div_modify() to achieve the same result. Change the hello world to this and try again:

Much better! Hat tip to unfoundbug at this reddit thread.

Old School Methods: Transformer-less Power Supplies

If you’ve read my previous posts you may be aware that I am in the process of trying to build an electronic device in Indonesia. To this end, I’ve tried to find some local talent to help me. I’ve interviewed a couple of people affiliated with an Indonesian appliance manufacturer who has a factory nearby. Ultimately, none of the candidates were a good fit, but I did learn something new, about which I would like to tell you today.

It turns out that it is possible to transform 110/220 VAC to 5 VDC really, really cheaply and without the use of a transformer. Don’t get too excited though – this method is more of a clever hack and is rather unsafe. It is presented here for educational purposes only.

Read more »

OpenWrt – Reduce Hostapd Verbosity

A quick note about how to reduce the log level of hostapd, as it tends to dominate log entries in /var/log/messages.

Read more »

Review of Fosc-21 (Focus Oscilloscopes) – a $20 USB Oscilloscope from ebay

Fosc-21 usb oscilloscope

Sometimes we make a bad spontaneous purchase. It must have happened to everyone at least once. This is the story of one such purchase.

Without doing my research I clicked ‘buy’ on a really cheap Chinese USB oscilloscope from ebay – Focus Oscilloscopes 21 (Fosc-21). The crappy-ness of this “oscilloscope” is matched only by its “software”. Instead of kicking myself, I decided to extract the maximum good that can possibly be extracted from this experience by writing a “review”. Hopefully, some poor soul about to buy this atrocity will find this post first.

Read more »

Say Bye to Provider’s DNS Servers – Be Your Own DNS Resolver

Have you ever wanted to NOT use your provider’s DNS services? Maybe they are engaged in censorship, or are modifying non-existent domains to point at pages full of advertisement? One popular solution is to use public DNS servers, such as Google’s. But ask yourself this – how much information are you giving up to a DNS server? Every time you visit a new web page, the DNS server will know about it. You can build a pretty nifty profile on a person using just that info. Well, how else would you do it? You’ve got to ask somebody for the IP address. Actually there is a better way – ask the source, and avoid the middlemen.

In this article I will show you how to set up your OpenWrt router to do its own DNS resolution. We will look up domains starting from root DNS servers, without the use of 3rd parties such as provider/Google/OpenDNS.

Read more »

My Smart Switch, or How I Built a Smarthome Gadget with No Electronics Experience, While Living in a Village in Indonesia

smart switch

They say that laziness is the mother of progress. It certainly was in my case. I am currently residing in Indonesia, where the outside lighting of one’s house is somewhat of a security practice, and it so happened that it became my job to ensure that these lights went on every evening, and equally importantly, off every morning. This involved making a trip around the perimeter of the house each evening and flipping all the light switches I came across. It is especially hard to remember to do this in the morning, because the sunlight makes it is hard to see that the lights are on. Sure enough, after about a week I no longer saw the joy in this daily routine and decided to do something about it. I was going to make a remote-controlled switch that would automate this task, and at the same time, become the foundation of a smart home installation I’ve been dreaming about. There was only one little problem – I knew absolutely nothing about designing electronics and PCBs.

In the title picture you can see the result of my efforts. The physical switch consists of two wall wells – one containing the switch itself and the other containing its “brains” (seeing how it is a smart switch and all). The virtual interface is provided by OpenHab2 running on a RaspberryPi2.

Read more »

Latest AT Firmware for ESP8266 with 512k Flash

The AT firmware is the default firmware for ESP8266 and provides AT style commands for actions such as join access point and send tcp packet. It is distributed in binary form by Espressif, but it can also be built from source (binary blobby as it may be). Typically one can find a new version of AT firmware in each release of Espressif’s SDK.

Since SDK version 1.0.1 the binary distribution of AT has become too large to fit on a 512kB flash. However, at this point in time (end of May 2015) most of the ESP8266 units out there are of the 512 kB variety. Thus begging the queston: how can one update their AT firmware to the latest version?
Read more »

Breadboarding an ESP-03

Here is my method of mounting esp8266‘s, specifically ESP-03 on a breadboard without the use of a breakout board. Details inside.

breadboard esp8266 esp03

Read more »

Uncle Lao’s Surprise

I have a ATX power supply that I use to power my electronics creations, and I noticed that I’ve been getting shocked with electricity 😯 whenever I touched it! How could it be!? I used a grounded plug, a grounded wall socket, and still… I went on like this for a while, not wanting to shut down my device zoo, until one day there was a power outage and that left me no choice but to finally get around to diagnosing the issue.

Read more »

PIC24 and EEPROM

If you’re reading this, chances are you are in the same boat I was in before writing this text – I wanted to save some data to EEPROM on a PIC24F and … it doesn’t have one. (The manual claims that PIC24F has EEPROM, but that is not fully so – only select models, namely PIC24F___K_, do). What to do? Well, there is this nice lib (AN1095) from Microchip that implements software EEPROM. The lib is well written, lots of docs, but alas – it does not run out of the box. This post is about the additional steps that it took to get it running.
Read more »