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:


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.

5. May 2015

C language in our world 2015 – slides

Slides available in formats: PDFSlideShare

Source code: GitHub/ysoftdevs/cpp-examples

  • Where is the fish?

  • Further info

  • Twitter

    Follow @jurajmichalek on twitter.

  • Comments

  • Tags

  • Topics