21. January 2017

How to freeze 1st row and 1st column in LibreOffice Calc 5

I was wondering how to freeze 1st row and 1st column in Calc. The solution is quite simple. Here is how to freeze cells in Calc for Linux.

Select cell B2 (it will serve as reference point), click Window (documentation often refer to View menu, which was not my case), click Freeze.

Done ūüôā

21. January 2017

How to freeze 1st row and 1st column in Excel

Tables in Microsoft Excel could be really big and it’s easy to loose track about information from the first column or the top row. There is simple way how to lock these two parts on screen.

Select cell B2 (it will serve as reference point), click View, click Freeze Panes.

Select Freeze Panes from drop-down menu.

Done ūüôā

17. January 2017

How to disable autocorrect in Skype on Windows 10

The default autocorrection in Skype on Windows 10 might be annoying sometimes. The question is how to disable it? It’s little bit hidden.

Click menu Tools and select Options… or press CTRL+,

Select IM settings in left pane, click Show advanced options

Uncheck Auto correct and highlight misspelled words, click Save

1. January 2017

Excellent talks from GOTO Stockholm 2016

I’d like to share with you references to great talks from GOTO Stockholm 2016 related to software development. These speakers are talking about concepts and ideas that are definitely breaking comfort zone of software development.

It is not just Microservices – Fred George

Key takeaway: “If you are doing iteration cycles by two or three weeks and you did it last year or year before. You’re not agile anymore. You should be going faster and faster.”

Software that Fits in Your Head – Dan North

Key takeway: “This is uncomfortable truth. Code is not an asset. Code is the cost.”

26. December 2016

How to build app with MobX annotations via webpack using Babel 6

I was searching for hints how to build games based on React. There is nice simple react-game-kit. The kit contains demo where you can as a player discover the kit itself.

Just type:

git clone git@github.com:FormidableLabs/react-game-kit.git
cd react-game-kit
npm install
npm start

Then you can open the demo in your browser: http://localhost:3000/

react-game-kit-demo

I was trying to build my own game based on code from react-game-kit. I hit one problem that webpack was not able to process MobX annotation @observable in GameStore.

Module build failed: SyntaxError: Unexpected token (4:2)

  2 | 
  3 | class GameStore {
> 4 |   @observable characterPosition = { x: 0, y: 0 };
    |   ^

The problem is described in MobX documentation. The annotation @observable is available only in ES7 which is fairly new. In case of Babel 5 or 6 you should use “Stage 0” processing.

Here is how to fix the problem:

npm install babel-plugin-transform-decorators-legacy --save-dev
npm install babel-preset-stage-0 --save-dev

The first package “transform-decorators-legacy” allows you to use decorators with Babel 6. The second package allows you to enable plugins in Stage 0 of build by Babel.

Then you need to tell webpack to use the plugin for decorators transform. Add list of plugins to query section of webpack.config.js:

...
  query: {
    presets: ['es2015', 'react'],
    plugins: ['transform-decorators-legacy', 'transform-class-properties']
  }
...

Now you can start the webpack and @observable will be processed.

If you want to learn more about MobX, there is nice tutorial at Egghead.io.

1. December 2016

ESP8266 WiFiManager gotchas

Thanks to PlatformIO it is very easy to add further functionality from libraries to the code for ESP8266. When you need to install library, just start Library Manager from ide and type:

pio lib install WiFiManager

PlatformIO will resolve dependencies and download all necessary stuff. Even better option is to add dependency to platformio.ini file:

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps =
  ArduinoJson
  esp8266_mdns
  PubSubClient
  WiFiManager

PlatformIO will manage the installation after you save the file. That is very neat.

Then new problems occurred when I started with integration of WiFiManager. Do not take me wrong. WiFiManager is very handy library, but you may experience some tricky issues.

The first problem that I hit was that WiFiManager interface was not visible at 192.168.4.1 port 80. ESP was apparently running in AP mode for configuration, but there was no web interface. This issue was caused by this line in my code:

ESP8266WebServer server(80);

I had web server in the main code before I merged the code from WiFiManager. Web server was serving simple REST API for controlling relay. Unfortunately this construct blocked the port so the AutoConnect web server. The server was not able to bind the port. Solution was simple. It was sufficient to instantiate web server after WiFi was working.

The second problem was that AutoConnect from WiFiManager was always turning in AP mode. I was hunting the problem for several hours without any result. One idea was that WiFiManager is not saving the password. That was not true. Other idea was that the memory is corrupted and reformat would help. Unfortunately it didn’t. I gave up.

That solved the problem. Seriously. I gave up and that solved the problem. I let the device running and then ding. It was online. For some strange reason ESP8266 was not able to establish connection with particular WiFi router at first shot. Then it turned on AP mode and after timeout of Config Portal it connected to the WiFi network. Remedy? Just shorten ConfigPortalTimeout:

wifiManager.setConfigPortalTimeout(60);

The third problem was that Config Portal was not displaying information stored as extra custom parameters. I stored there host name of MQTT broker and other options so they won’t be hardcoded. The problem was caused by WiFiManagerParameter constructed in global scope. Issue was similar the first problem with web server.

Solution was to move construction of WiFiManagerParameter to the method after loading configuration values from file config.json stored on file system.

File configFile = SPIFFS.open("/config.json", "r");
...
WiFiManagerParameter custom_mqtt_host("mqtt_host", "MQTT host", configMqttHost, 40);

After resolving these issues WiFiManager is working and it is possible to set values for configuration via Config Portal and there is no need to hardcode them anymore.

Original code is stored at GitHub – LampESP branch v0.1. The new version is at Github – LampESP branch master. I made also small refactoring and the functionality was divided into smaller files which resembles modules for better code maintenance.

27. November 2016

Controlling relay connected to ESP8266 via MQTT from Android

After successful implementation of MQTT into Lamp Relay with ESP8266 there was one remaining challenge. Communication of Android Lamp App with ESP8266 via MQTT. It was little bit harder than I expected, because examples were not very clear.

Sending commands to MQTT broker was relatively easy. There was just a catch. It is necessary to declare the MQTT service in AndroidManifest.xml:

<service android:name="org.eclipse.paho.android.service.MqttService">
</service>

Thanks to tutorial from HiveMQ I was able to send messages to MQTT broker.

The problem was the opposite direction. How to receive messages?

Well, there is support in the same MQTT library for topic subscriptions. The issue¬†is that incoming message is being processed on background thread and it’s not possible to update UI. It took me some time to realize the source of problem. I was hunting ghosts. I thought that there is some problem in ImageButton or TobbleButton.

Correct solution was to move communication to Android service class. Then bind the service so UI can send commands to the service and the last part was to add broadcast receiver to pass message from service to UI.

Here is small schema which describes delivery of message from broker to app.

mqtt-broker-to-android

It was necessary to make also small update in ESP8266 in order to tell Mosquitto to persist the state of a lamp (the last bool parameter):

mqttClient.publish(topicName("relay"), "off", true);

The result is nice. I can turn on the lamp via web interface and all connected Android apps are updated and user can see the state of the lamp.

lamp-app-mqtt

The code for Android app is available at Github – LampApp. Previous code with REST API was moved to branch v0.1. The code for ESP8266 module is also at Github – LampESP. Feel free to customize the app. You can find instructions in README.md.

I see the next challenge for LampApp: display lamp control widget at lock screen. Maybe I’ll be more successful than the last time.

22. November 2016

IoT and waiting for the sun

It took me some time to implement all features to ESP8266 controlling relay of my lamp.

smart-home-lidl-salt-lamp

Thanks to examples from PlatformIO I was able to use all neat features in one code:

You can find complete code at github repo LampESP. Just replace HOST_NAME_HERE and ROOM_NAME_HERE with your MQTT server and your room name.

Once you deploy code to ESP8266 you can use Over-the-air update (OTA). Just change the value in platformio.ini and set upload_port to IP address of your device.

The implementation allows control via simple GET API by accessing the web of device or LampAndroidApp.

As I wrote few weeks ago, my goal was to add MQTT. I’ve installed Mosquitto and connected the device to the server.

It is possible to watch states of device is possible via MQTT client:

mosquitto_sub -v -h HOST_NAME_HERE -t '/#'

Here is example how to change states of relay:

mosquitto_pub -h HOST_NAME_HERE -t '/home/ROOM_NAME_HERE/command' -m 'on'
mosquitto_pub -h HOST_NAME_HERE -t '/home/ROOM_NAME_HERE/command' -m 'off'

I had an idea about next cool feature: turn on/off lamp based on sunset and sunrise. I found very simple and elegant solution that I would like to share with you.

Download Sunwait and compile it. The program just starts and waits until the time of sunrise or sunset based on geographic coordinates. You can also specify offset (how long before or after event) should program end.

Now you can put the sunwait into your local cron table and chain it with command that should be executed after sunrise/sunset occurs.

Here is example how to configure cron to turn on the lamp 15 minutes before sunset and turn it off 15 minutes after sunrise.

crontab -e
10 15 * * * /usr/bin/sunwait sun down -0:15:00 49.230738N, 16.576802E; /usr/bin/mosquitto_pub -h HOST_NAME_HERE -t /home/ROOM_NAME_HERE/command -m "on"
4 15 * * * /usr/bin/sunwait sun up +0:15:00 49.230738N, 16.576802E; /usr/bin/mosquitto_pub -h HOST_NAME_HERE -t /home/ROOM_NAME_HERE/command -m "off"

The lamp is now working. The only problem is the Android app. I thought that adding MQTT client to Android app will be as easy as adding it to ESP8266, but it’s far from truth. There are still some challenges ūüėČ

19. November 2016

Programming ESP8266 in Go language? Not yet. November 2016

I was wondering if it would be possible to use Go language to write code for ESP8266.

The very first search result seemed to be the right choice – Gobot.

I read the instructions and typed:

go get -d -u github.com/hybridgroup/gobot/...

After a while Go asked for password to git.eclipse.org. I had no account there so I registered the account. And again:

go get -d -u github.com/hybridgroup/gobot/...

New error:

package git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git: cannot download, git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang uses insecure protocol

Go was trying to get repository from Eclipse using unsecure HTTP. Luckily there was feature request to add switch for accessing insecure repositories by Go get – issue #9637. The solution was just to add “-insecure” parameter:

go get -insecure -d -u github.com/hybridgroup/gobot/...

New error:

# cd .; git clone git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang .../projects/gobot/src/git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git
fatal: repository 'git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang' does not exist
package git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git: exit status 128

Yay, that’s cute. I’ve searched through issue tracking system in hybridgroup/gobot and the answer was issue #339.

The workaround is to change line 4 in github.com/hybridgroup/gobot/platforms/mqtt/mqtt_adaptor.go to:

"github.com/eclipse/paho.mqtt.golang"

Ron Evans recommended just to switch to dev branch.

Thanks to Go integration with Git it was very easy:

cd src/github.com/hybridgroup/gobot
git checkout dev
go get -d -u github.com/hybridgroup/gobot/...

Only after this sequence of steps from magic dance Gobot was ready to build application on my computer.

My next step was attempt to build MQTT ping. Easy? Just grab a code from gobot.io documentation, paste it to file and run it.

go run mqtt-ping.go

Another funny error:

# command-line-arguments
./mqtt-ping.go:11: undefined: gobot.NewGobot
./mqtt-ping.go:13: undefined: "github.com/hybridgroup/gobot/platforms/mqtt".NewMqttAdaptor

The documentation on the web is from master. Ou, but I switched to dev branch. What a simple mistake. I grabbed the code from github repo everything was ok.

cp  ./github.com/hybridgroup/gobot/examples/mqtt_ping.go .
go run mqtt_ping.go

The application was able to connect to Mosquitto Broker and send messages.

The last step would be to deploy it to ESP8266. Unfortunately this is not possible yet. The platform is not supported by Gobot and there is issue with plaftom-request #301.

Ok, never mind. It was interesting experiment and I can see potential of Go for programming IoT.

What will be my next experiment? Developing the code for ESP8266 using PlatformIO.

13. November 2016

Silicon Germany – book recommendation

There are many books about startups and lean thinking from USA. They have one big problem in common. These books does not match with situation and environment in Europe. Buying those books and trying to apply them in Europe is in many cases waste of time.

I’ve been searching for books based on European context. I have found only few European authors.

Prof.¬†G√ľnter Faltin¬†wrote book Kopf schl√§gt Kapital¬†which apply similar thinking like Steve Blank and Lean Canvas.

Stefan Merath wrote several books about customer relationship and how to build working business model. He has similar style like Eric Rise and Lean Startup.

Recently I discovered very intriguing book with the title Silicon Germany written by Christoph Keese. Christoph is investigating reasons why products from German or other European companies are simply bellow average and why they struggle so much to catch with latest products from California.

silicon-germany

If you want get better understanding why Europe has so many problems with innovations then I recommend this book to you.

 

  • Where’s the fish?

  • Translations

  • Further info

  • Twitter

    Follow @jurajmichalek on twitter.

  • Comments

  • Tags

  • Topics