Thursday, March 23, 2017

Getting a caller's class and method names in Java

Sometimes a method needs to know which class and method called this method. For example, it can be helpful in a logger. A logger can print information about caller like this:

[SomeClass, main]: main() started
[AnotherClass, method]: hello
[SomeClass, main]: main() finished
There is a couple of ways how we can get information about caller in Java. First of all, Java has an internal `sun.reflect.Reflection.getCallerClass(int)` method, but it might not be good to use classes in `sun` package because they can be changed/removed/updated in any new Java release. Another thing is that you'll need a permission to access `sun` package if you run your application with a security manager (is anybody doing this?). Let's try to use public API.

Monday, March 6, 2017

MicroPython on ESP8266: sending data to ThingSpeak

Here is a tutorial about using MicroPython on ESP8266. The post describes how to use MicroPython to measure temperature and humidity, and send data to ThingSpeak.

MicroPython on ESP8266: sending data to ThingSpeak

MicroPython on ESP8266 with DHT22 and ThingSpeak

Saturday, March 4, 2017

Problems with running MicroPython on ESP8266 with 512K

The post below describes a couple of problems you may run into if you use MicroPython on ESP8266 boards which have less than 512K of flash.

Problems with running MicroPython on ESP8266 with 512K