Categories
ESP8266 (ESP-01/01S) Microcontrollers

Flash ESP8266 firmware using USB ESP01 Programmer Adapter (Windows 10)

USB ESP01 Programmer Adapter (Hardware) and CP201x drivers installed on PC/Laptop.

  • USB Type A interface
  • One 2x4P 2.54mm female header
  • One 2x4P 2.54mm male header
  • On board Reset button for ESP01
  • CP201x Chip

Mount the EPS01 module (Blue board, Flash 4MBit) on the header of USB ESP01 Programmer Adapter

Connect the USB ESP01 Programmer adapter to the USB port of the Windows installed PC/Laptop

Download the ESP8266’s Flash Download Tool (Espressif)

https://www.espressif.com/en/support/download/other-tools

Use the extract tool to extract the compressed file from your download folder

Download the ESP8266 Firmware (ESP8266 Forum)

https://bbs.espressif.com/index.php

Join the ESP8266 forum, On the Download section, choose SDK and choose “ESP8266_NONOS_SDK_V2.0.0 download link to download the firmware. Then use the extract tool to extract the compressed file in your download folder.

Setup the Flash Tool

SPI SPEED26.7MHz
SPI MODEQIO
FLASH SIZE4Mbit
blank.bin0x78000
esp_init_data_default.bin0x7C000
blank.bin 0x7A000
blank.bin 0x7E000
eagle.flash.bin0x00000
eagle.irom0text.bin0x10000
COMCOM3 (a Port value from Device Manager)
BAUD115200

Putty (Serial Terminal Software)

AT+GMR command to check the SDK version installed.

Type AT+GMR then follow by CTRL+M CTRL+J

Categories
Microcontrollers

WebAssembly

WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications. (Source: https://webassembly.org/)

Here is a list to summarize the preceding information:

  • Wasm is a new language that officially became the fourth language of the web, after HyperText Markup Language (HTML), Cascading Style Sheets (CSS), and JavaScript. Source: https://www.w3.org/2019/12/pressrelease-wasm-rec.html.en
  • Wasm is a binary format. It does not aim to be human-readable.
  • Wasm is so low-level that it brings performance improvements compared to high-level languages such as JavaScript.
  • Go code can be compiled in the Wasm binary format.
Categories
Internet Of Things Microcontrollers MQTT

MQ Telemetry Transport (MQTT)

Specifications

MQTT is a Client Server publish/subscribe messaging transport protocol. It is light weight, open, simple, and designed so as to be easy to implement. These characteristics make it ideal for use in many situations, including constrained environments such as for communication in Machine to Machine (M2M) and Internet of Things (IoT) contexts where a small code footprint is required and/or network bandwidth is at a premium.

Goals

The MQTT protocol aims for these goals:

  • Efficiency: the clients are usually very small and don’t have many resources.
  • Lightweight: the message header are small to optimize network bandwidth.
  • Reliable Delivery: it is important for devices to make sure the message was delivered.
  • Bi-directional: both client and server can send messages.
  • Data agnostic: it doesn’t matter the format of the message being sent.
  • Session: many IoT devices connect over unreliable networks, so it’s important to reduce the time to reconnect the client.
  • Security: it is easy to encrypt messages using TLS.

Architecture

The MQTT is a publish-subscribe protocol. That is a client sends a message (or publish it) without knowing directly who is going to receive the message, if anyone. The same way, another client can receive messages (or subscribe) without knowing which device has sent it.

Source: MQTT.org

In this way, to send or to receive messages, the publishers and subscribers only need to know the broker address. Another advantage is that a broker can deliver a message for a client that is not online at the time it was published.

Go Client

Let’s create a simple application in Go to send and receive messages using MQTT.

Categories
ESP8266 (ESP-01/01S) Microcontrollers

Setup WiFi SSID and Password with Arduino IDE

// Import required libraries
#include <ESP8266WiFi.h>

// Wifi parameters
const char* ssid = "HackerWifi6";
const char* password = "sklim01@@";

void setup() {
  // put your setup code here, to run once:
  // Start Serial
  Serial.begin(115200);
  // Connect to WiFi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");
  // Print the IP address
  Serial.println(WiFi.localIP());
}

void loop() {
  // put your main code here, to run repeatedly:

}
Categories
ESP8266 (ESP-01/01S) Microcontrollers

Using USB ESP01 Programmer Adapter with Arduino IDE

Assumption of Arduino IDE has been already configured for ESP8266 modules installed

USB ESP 01/01s Programmer Adapter (Hardware)

  • USB Type A interface
  • One 2x4P 2.54mm female header
  • One 2x4P 2.54mm male header
  • On board Reset button for ESP01

Download the USB to Serial Drivers for your OS platform. Select specific the Serial Chip drivers files match the USB programmer adapter – CP201x)

https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers

Install the USB to Serial software drivers as per default setting

Check the Windows Device Manager, Ports for COM integer value

Setup Port and Speed (baud rate) on the Arduino IDE from Tool menu

USB to UART / USB to TTL Serial (Hardware)

Arduino Uno R3 / Maker Uno X (Hardware)

Categories
ESP8266 (ESP-01/01S) Microcontrollers

Setup Arduino IDE (Windows/MacOS – Intel)

Download the Arduino IDE software and Setup the software

https://www.arduino.cc/en/software

Install the ESP8266 modules under the Additional Boards in Boards Manager

http://arduino.esp8266.com/stable/package_esp8266com_index.json

 Open boards manager and search for esp and install it

Categories
Microcontrollers TinyGO

TinyGO

TinyGo – Go compiler for small places

Support boards/targets

You can compile TinyGo programs for microcontrollers, WebAssembly and Linux.

The following microcontroller boards of my stock are currently supported:

  • Arduino Mega 1280
  • Arduino Uno
  • BBC micro:bit
  • Digispark
  • ESP32
  • ESP8266
  • Raspberry Pi Pico

Resources

https://tinygo.org/getting-started/

https://github.com/tinygo-org/tinygo

Categories
Arduino UNO and Maker UNO Microcontrollers TinyGO

Hello World (TinyGo)

package main

import (
   "machine"
   "time"
)

func main() {
   led:= machine.LED
   led.Configure(machine.PinConfig{Mode: machine.PinOutput})
   for {
      led.LOW()
      timeSleep(time.Millisecond * 300)
      led.HIGH()
      time.Sleep(time.Millisecond * 300)
   }
}
Categories
Microcontrollers

Visual Studio Code (IDE) for TinyGO

Install the Go extension using the VSC’s Extensions

Install all dependencies

By hitting Ctrl + Shift + P and entering the following command

Go: install

Select all dependencies by checking the box on the left side and click OK. Wait till the log message appears as follows: All tools were successfully installed. You are ready to Go :).

Install TinyGo extentions

Configure TinyGo extension

TinyGo target set to Arduino

Sometimes a popup similar to the one in the following screenshot will appear. Do not click on Update tools; just close it.

Checking the Environment

tinygo info arduino

Write the Hello World code (Go lang)

package main

import (
   "machine"
   "time"
)

func main() {
   led:= machine.LED
   led.Configure(machine.PinConfig{Mode: machine.PinOutput})
   for {
      led.LOW()
      timeSleep(time.Millisecond * 300)
      led.HIGH()
      time.Sleep(time.Millisecond * 300)
   }
}

Flashing the program

tinygo flash –target=arduino main.go

Result

LED blink at Digital pin 13

Categories
Arduino UNO and Maker UNO TinyGO

Install TinyGo (MacOs, Intel)

You must have Go v1.14+ already installed on your machine in order to install TinyGo

brew tap tinygo-org/tools
brew install tinygo

$ tinygo version
tinygo version 0.15.0 darwin/amd64 (using go version go1.15 and LLVM version 10.0.1)

brew tap osx-cross/avr
brew install avr-gcc
brew install avrdude

Resources

https://tinygo.org/getting-started/install/macos/