Serial Comms between NodeMCU & Arduino Nano

Here’s how to set up serial comms between a NodeMCU V1 (ESP-12E) and Arduino Nano. Note, you could replace the Nano with any Arduino board but I have only tested with a Nano.

Here are parts required:

Here’s the diagram:

circuitAnd the source code is available here: https://github.com/coytar/Snippets/tree/master/NodeMCU_To_Nano

Good luck! 🙂

 

Advertisements

HTTP GET using Volley

I was making an Android app using Android Studio (3.1.3) which sends a HTTP GET request. The code was very similar to this:

String serverURL = "http://192.168.0.150/main_light/switch";
URL url = new URL(serverURL);
HttpURLConnection connection = null;
try {
    connection = (HttpURLConnection) url.openConnection();
    connection.setRequestMethod("GET");
    BufferedReader in = new BufferedReader(
    new InputStreamReader(con.getInputStream()));
    //Do something with this InputStream
    // handle the response
    int status = connection.getResponseCode();
    // If response is not success
    if (status != 200) {
        throw new IOException("Post failed with error code " + status);
    }
} catch (Exception e) {
    Log.e(TAG,e.toString());
} finally {
     if(connection != null)
         connection.disconnect();
}

The request was never sent. I tried everything but I just couldn’t make it work. However!

I found a solution using Volley (https://developer.android.com/training/volley/simple). This code is in Kotlin but as you can see it is very simple and mostly importantly it works!

val queue = Volley.newRequestQueue(this)
val url = "http://192.168.0.150/main_light/switch"
val stringRequest = StringRequest(Request.Method.GET, url, null, null)
queue.add(stringRequest)

Don’t forget to add these lines to the AndroidManifest.xml file:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

 

NodeMCU ESP8266 CP1202 Programming (Blink)

This is the tutorial for programming the NodeMCU CP1202 board using the Arduino IDE. The code that will be used is the Blink example. And the board that I’m using looks like this.

Image result for cp1202 nodemcu

Here are the steps I followed:

  1. Install the drivers from https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
  2. Download the ESP8266 board information for Arduino
    1. Open the Arduino IDE
    2. Click on the File menu and then Preferences
    3. In the Additional Boards Manager URLs, enter this: http://arduino.esp8266.com/stable/package_esp8266com_index.json
    4. Click Ok
    5. Click on the Tools menu, click Boards and then click Boards Manager
    6. Wait for it to download the new boards information
    7. Search for ESP8266 and install it
  3. From the Tools menu, select the following:
    1. Board: NodeMCU 1.0 (ESP-12E Module)
    2. Flash Size: 4M (3M SPIFFS)
    3. CPU Frequency: 80MHz
    4. Upload Speed: 115200
    5. Port: (whichever COM port it is)
    6. Erase Flash: Sketch Only
  4. From the File menu, click Examples, click ESP8266 and then click Blink
  5. Compile and download
  6. Voila! 🙂

Cisco Packet Tracer on Ubuntu 16.04 LTS

When you’re trying to download Cisco Packet Tracer, you’ll notice it says “Ubuntu 14.04” only. Well it works on 16.04 LTS as well with a little addition.

Here are all the steps to installing Cisco Packet Tracer:

  1. Download the Ubuntu version of Cisco Packet Tracer
  2. Extract and run “install” script
  3. If you run packettracer now it will say “Starting…” but it won’t actually run.
  4. You need to download this package, libicu52_52.1-3ubuntu0.8_amd64.deb. If you google that you’ll find various mirrors. I found it here: http://mirrors.kernel.org/ubuntu/pool/main/i/icu/libicu52_52.1-3ubuntu0.8_amd64.deb
  5. Install it via “sudo dpkg -i libicu52_52.1-3ubuntu0.8_amd64.deb”
  6. Run packettracer from terminal
  7. Voila!

 

Wireshark on Kali Linux 2008

If you encounter this issue running Wireshark on Kali Linux:

Capture

Perform the following:

  1. Edit /usr/share/wireshark/init.lua with your favourite editor
  2. Find the line (near the top) which has “disable_lua = false”
  3. Change it to “disable_lua = true”
  4. Save and close the editor
  5. Voila 🙂

FPGA Editor

If you’re trying to run the FPGA Editor on Ubuntu 16.04.03 then you’ll encounter these errors, and how to fix them.

./fpga_editor
/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/_fpga_editor: error while loading shared libraries: libXm.so.3: cannot open shared object file: No such file or directory

Navigate to https://launchpad.net/ubuntu/xenial/amd64/libmotif4/2.3.4-8ubuntu1 and download the .deb file.

sudo dpkg -i libmotif4_2.3.4-8ubuntu1_amd64.deb

During this process it will complain abot not having libmrm4, libuil4, and libxm4 in that order.

Now simply run the following command to fix the unmet dependencies:

sudo apt-get -f install
sudo apt-get install libXp

./fpga_editor
/opt/Xilinx/14.7/ISE_DS/ISE/bin/lin64/_fpga_editor: error while loading shared libraries: libXp.so.6: cannot open shared object file: No such file or directory

Navigate to https://packages.ubuntu.com/trusty/amd64/libxp6/download and download the .deb file.

sudo dpkg -i libxp6_1.0.2-1ubuntu1_amd64.deb
sudo apt-get install libstdc++5

./fpga_editor
Wind/U Error (193): X-Resource: DefaultGUIFontSpec (-*-helvetica-medium-r-normal-*-14-*) does not fully specify a font set for this locale

sudo apt-get install xfonts-100dpi xfonts-75dpi

reboot your computer

./fpga_editor
Cannot register service: RPC: Unable to receive; errno = Connection refused
unable to register (registryProg, registryVers, tcp)
Wind/U Error (248): Failed to connect to the registry on server ise-VirtualBox

sudo apt-get install rpcbind portmap

./fpga_editor