Sunday, January 15, 2017

Scanning X-Ray Films

So Recently - because of binge running - I ended up with pain in my right thigh. So I had to visit an orthopedic doctor who diagnosed me with a pulled sciatica. We got an X-Ray done to make sure it wasn't the spine that was digging into the nerve to cause pain. It wasn't. No I usually digitize my medical records myself - the prescriptions and lab reports. This time I had an X-Ray film that I needed to scan with a regular scanner.
Drawing inspiration from https://www.youtube.com/watch?v=NM5XzDYfG60 here is what I got:

Trial 1: Regular scan on Epson L550. Regular settings



Trial 2: My friend has a Lenovo yoga 500 laptop - the one whose screen can be
flipped 360 degrees and turned into a tablet PC. I did just that and used it as a backlight
for the X-Ray film. I created a 1920x1080 sized image in mspaint with nothing but white in it.
I used IrfanView to display the image fullscreen and placed the laptop over the X-Ray film on the scanner.
Performed the scan with regular settings and got immediately improved results!
All I needed to do was to somehow remove the magenta and light green lines caused by scanning the screen.
Some sort of diffuser was needed.




Lenovo yoga 500 as a backlight
Lenovo Yoga 500 as backlight



Trial 3: Used a copier paper as a diffuser between the tablet PC screen and X-Ray: No Joy

75 gsm copier paper as diffuser


Trial 4: Used "Clear Plastic Folder Sheet" as diffuser between the X-Ray and backlight (Tablet Pc screen) :  Perfect

Folder sheet as diffuser

Tuesday, December 20, 2016

Setting up TL-WPS510U Wireless Print Server

HP LaserJet 1020 plus working fine with TL-WPS510U wireless print server

We have an HP LaserJet 1020 plus which we wanted to share on our network. Since this is a printer which only has a USB port, it can be shared by connecting it to a windows computer and sharing the printer via homegroup. But this required us to keep the connected computer on all the time.

So I decided to try out the TP-Link Wireless Print Server TL-WPS510U. In India it costs around ₹5000 and so it makes sense for anyone to go for this device to retro fit your old printer into a a network capable one.

But there is a caveat. The supplied CD which allows you to configure the software won't work on any PC. The TL-WPS510U is configured to join an "Ad-Hoc" WiFi network named WLAN-PS. The supplied software on your CD, makes your PC join this Ad-Hoc network and then sends commands and credentials to the TL-WPS510U over this Ad-Hoc network and instructs it to join to your home/office's WiFi network (i.e. your WiFi Router which operates in infrastructure mode).

Now now all WiFi adapters support Ad-Hoc mode. So the software on the CD supplied with TL-WPS510U will not work on all computers. To check if the WiFi adapter on your PC supports Ad-Hoc mode, type the following command in the Command Prompt Window (Press the Windows Key + R and type cmd and press enter):

netsh wlan show drivers

I executed this command on two of the computers I have access to. Check the field "Hosted network supported". If it says "Yes" then your computer can host ad-hoc networks.
The Intel(R) Dual Band Wireless-AC 3165 does not support ad-hoc mode
 Intel(R) Dual Band Wireless-AC 3160 does support ad-hoc mode
Sometimes it might be possible to upgrade your WiFi Chipset drivers and have the ad-hoc capability enabled in the new drivers. But if that does not work for you, make sure you run the CD that came with TL-WPS510U only on a computer that supported hosted networks. Before you run the CD on a particular computer, will need to make sure that the computer has the target printers drivers pre-installed on it. To do that, connect the printer to your computer via USB to the computer and install the driver from the CD supplied with the printer. And once that is done, you can go ahead with setting up the print server for it.

Once you have configured the TL-WPS510U and gotten it connected to your network, you will need to go to each computer on the network and configure them to be able to use the printer. To do that, make sure you have the printer drivers installed on all the computers that you want should be able to print to the printer over network.

Now you can run the CD on each computer you wanted to connect to the printer. When you are doing so, make sure to select "Setup Wizard" instead of "Easy Setup". We use "Easy Setup" on on the first computer when we are trying to configure the TL-WPS510U to connect to our home/office WiFi. For all consecutive computers on which u want to use the printer, select the "Setup Wizard". Once the printer server has connected to the network, you no longer need the computers to support "Hosted network" to be able for it to print to the printer via the print server.
Select Setup Wizard on all consecutive computers

In case you want configure the computer to connect to a printer over the network via print server - without using the print server driver CD, go to "Devices and Printers" and click on "Add a printer". Click on "The printer that wasn't listed" and then from the following screen click on "Add a printer using TCP/IP address or hostname".

If you were using the CD, the support software would have automatically discovered the print server on your network. But while performing the steps manually, you will need to know the IP address of the print server. To do that, you can look up the list of devices and the IP addresses assigned to them from your WiFi router's admin console. It is recommended that you assign a static IP address to the print server during initial configuration (i.e. when you are running the CD to connect the print server to the network).

Once you go ahead with selecting "Add a printer using TCP/IP address or hostname", you will need to know the setting to use with the print server, here are the settings (Change the IP address to your own print server's IP address)


After this screen, it will ask you to select the make and model of the printer that is attached to the print server, make sure that you select the correct one.

Sunday, December 4, 2016

ESP8266 + DHT22 + Arduino + Web Server

So here is a modified version of how to get a DHT22 working on ESP8266 NodeMcu board using the Arduino IDE (not Lua)

The project is based on:
http://randomnerdtutorials.com/esp8266-dht11dht22-temperature-and-humidity-web-server-with-arduino-ide/

  1. Get the components and assemble them. In India you can find these on VishaWorld.com
    1. NodeMcu ESP8266 | Link
    2. DHT22 | 
    3. Male-Male Jumper Wires | 
    4. Bread Board | Link
    5. MicroUSB cable | 
  2. Assemble the circuit as shown. Connect the Data pin of SHT22 to D2 of NodeMcu (which is referred to pin 4 in Arduino IDE)
  3. Install the driver for USB-Serial chip on your PC:
    http://www.silabs.com/products/mcu/pages/usbtouartbridgevcpdrivers.aspx
  4. Install Arduino on your computer and install support for ESP8266 Board, refer:
    https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/installing-the-esp8266-arduino-addon
  5. Install the DHT-sensor-library-master library as outlined here:
    http://randomnerdtutorials.com/esp8266-dht11dht22-temperature-and-humidity-web-server-with-arduino-ide/
  6. You would need to download and place Adafruit_Sensor.h in this same library folder as well. Get that file from: https://github.com/adafruit/Adafruit_Sensor/blob/master/Adafruit_Sensor.h
    Click on "Raw" to get the file.
  7. Copy the code below, and download it into your ESP8266 NodeMcu board. Make sure to select the proper board and COM port.
To test:
  1. Connect your mobile to the WiFi hotspot created by ESP8266 : Temperature_Server
    Password is: vishaworld.com
  2. Make sure to turn off the 3G data connection on your phone. Andorid will report that the wifi network "Temperature_Server" does not provide internet access. Ignore the message.
  3. Open chrome and punch in 10.10.10.10 in the URL field and ESP8266 will serve you with the latest reading from the temperature sensor.




Monday, November 14, 2016

Mounting ARM Linux (OLinuXino/Raspberry Pi) SD card .img files on Desktop PC to access its rootfs

Linux distributions for embedded ARM board like Raspberry Pi or iMX233-OLinuXino-MAXI are available as prebuilt SD card images supplied as raw .img files.
For example, .img files for ArchLinux are available for Raspberry Pi and OLinuXino.
These files can be written to SD cards using the program dd on Linux or Win32 Disk Imager on Windows.

These files contain the image of the SD card as a whole including multiple partitions - bootloader/bootlets, rootfs, swap etc.

At some point of time we might find ourselves wanting to access the files from the rootfs contained within one of the partition of these image files. Accessing the kernel headers folder for cross-compiling kernel modules for these boards can be one such situation. And one does not necessarily need to write the image to an SD card and mount it back on ones desktop to achieve this.

Major Hayden has straightforward instructions here on how to mount .img files which contain multiple partitions.

So when I found myself wanting to extract the rootfs from ArchLinux distribution for OLinuXino (ArchLinuxARM-2014.02-olinuxino-rootfs.img) onto my Ubuntu 12.04 32 bit Desktop, here are the steps I followed:


Analyse the image file using the fdisk and file commands:
There are two partitions, the first one is for the bootloader and the second one is the rootfs. We want to mount the second one

The start sector for the second partition which houses the rootfs is 67584. We need to mount that. Since block size is 512, we need to mount starting from 67584*512 byte 34603008

Make a folder for mounting the rootfs. I named mine "rootfs"

And issue the command to mount:
sudo mount -o ro,loop,offset=34603008 ArchLinuxARM-2014.02-olinuxino-rootfs.img rootfs

The rootfs from the .img file is successfully mounted
You can even use nautilus to browse the mounted folder!!


Compiling Linux Kernel modules on OLinuXino (ArchLinux ARM)

So if you have an OLinuXino and have installed the development tools on the board and successfully compiled userspace programs on it (refer this blog post), and are feeling adventurous, you can try compiling kernel modules as well. (Make sure you have gcc setup – refer to the blog post linked to above)

So at the OLinuXino console (Serial or SSH) logged in as root:
  1. Install kernel headers:
    pacman -S linux-armv5-headers
  2. In your home directory, create the main.c source file:
    nano main.c

    and type the following and save the file:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    #include <linux/module.h> //Needed by all modules
    #include <linux/kernel.h> //Needed for KERN_INFO
    int init_module(void) {
     printk(KERN_INFO "Hello world\n");
    
     //A non 0 return means init_module failed; module can't be loaded.
     return 0;
    }
    
    void cleanup_module(void) {
     printk(KERN_INFO "Goodbye world\n");
    }
    
    MODULE_AUTHOR("Anurag Chugh");
    MODULE_DESCRIPTION("Hello World");
    MODULE_LICENSE("GPL v2");
    
  3. While still in your home directory, create the makefile:
    nano Makefile

    and type the following into it:
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    obj-m += hello.o
    
    hello-objs := main.o
    
    all: uninstall-kernel-module
     make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
     -sudo insmod hello.ko
     sudo dmesg -c 
    
    clean: uninstall-kernel-module
     make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
     sudo dmesg -c
    
    #the '-' in front of the command tells make to continue with the next command incase an error is encountered 
    install-kernel-module:
     -sudo insmod hello.ko
     
    uninstall-kernel-module:
     -sudo rmmod hello
    
  4. Issue the command to clear the kernel message buffer:
    dmesg –c
  5. Build the kernel module, the make file will automatically load the module as well and the kernel messages will report its execution:
    make

image
Successfully compiled and loaded the hellow world kernel module


Sunday, November 13, 2016

Interface USB Mouse to your Arduino using CH375B

CH375B module. It is usually supplied with a 2 way jumper mounted on TXD and RXD pin.
The TXD RXD pins are located next to the female USB receptacle. Please unmount the jumper before use.
  1. Get the following components:
    1. Arduino Nano
    2.  Male to female jumper wires  - 4 pieces
    3. USB Mouse
    4. CH375B module
  2. Download MeUsb.cpp and MeUsb.h from https://github.com/xeecos/Me-USB-Host
  3. On your Windows computer which already has arduino installed, go to your documents folder. There you will find a folder called arduino and within that another folder called libraries. Inside this libraries folder create a new folder called "MeUsb"
  4. Place MeUsb.cpp and MeUsb.h in this folder
  5. In the arduino\libraries folder, create another folder called "SoftwareSerial_fix"
  6. And in this folder download and place SoftwareSerial_fix.cpp and SoftwareSerial_fix.h from the same link as above.
  7. Assemble the circuit on the bread board as follows:
    1. +5V of Arduino Nano to +5V of CH375B
    2. GND of Arduino Nano to GND of CH375B
    3. D10 of Arduino Nano to TXD of CH375B
    4. D9 of Arduino Nano to RXD of CH375B 
      Connecting the CH375B to Arduino Nano

      Connecting the CH375B to Arduino Nano
  8. Start arduino and open a new sketch. Copy the source code into it and download it into the arduino nano.
  9. Once the code is downloaded successfully, start serial monitor on your PC with baud rate set to 115200 and observe the pattern of 4 bytes that are being received.
    Every time you move the mouse, 4 bytes are sent to the Arduino Nano.
    You will observe that there are 4 bytes being printed on the serial monitor. Here are what those 4 bytes mean:
Deciphering the 4 bytes received from CH375B when a mouse is connected to it
You can CH375B module in India from www.vishaworld.com

To interface a USB Joystick, have a look at Me-USB-Host.ino available at https://github.com/xeecos/Me-USB-Host

Source Code to interface USB Mouse.


#include <Arduino.h>
#include "SoftwareSerial_fix.h"
#include "MeUsb.h"

MeUsb usb(10,9);

void setup() 
{
   Serial.begin(115200); 
   usb.init(USB1_0);
}

void loop()
{
  if(!usb.device_online)
  {
    usb.probeDevice(); 
    delay(100);
  }
  else
  {
    int len = usb.host_recv();
    if (len == 4){
      Serial.print(usb.RECV_BUFFER[0],DEC);
      Serial.print(',');
      Serial.print(usb.RECV_BUFFER[1],DEC);
      Serial.print(',');
      Serial.print(usb.RECV_BUFFER[2],DEC);
      Serial.print(',');
      Serial.print(usb.RECV_BUFFER[3],DEC);
      Serial.print('\n');
    }
  }
}

Thursday, November 10, 2016

Automatically rebooting Vstarcam HD C7838WIP Wireless IP Camera

I have 6 IoT devices in my house. Most of them are DIY and I have documented their build processes on this blog. One of them is a commercial product.


  1. Weather Station (OpenWrt) blogpost
  2. Energy Meter (OpenWrt) blogpost
  3. Ambient Sensors (Particle Photon) blogpost
  4. ADS-B Receiver (PiAware on RPi2) instructions on piaware
  5. DIY Security Camera (motionEye/RPi) blogpost
  6. Commercial Security Camera (Vstarcam HD C7838WIP)
Out of these, the ADS-B Receiver and the Vstarcam (both running linux) kept losing connection to the cloud regularly. I have a few theories behind why this might be happening:

  1. Both these devices lie in the fringe area (near door/windows) of my house far away from the home router which is placed in the center of the house. The WiFi signal from my neighbors might be causing interference and decrease in signal quality for these devices and the WiFi driver might be trying hard to maintain connection before giving up. I know this because I looked up the system logs of the fringe devices and video streaming on my laptop hiccups when I sit next to the window. Also this is what my balcony's spectrum looks like:

    Oh soo many WiFi's!!
  2. The WiFi chipset might be buggy
  3. The WiFi drivers might be buggy
  4. Some other application running on these devices causes the freeze up
  5. We experience power failure for very short duration a couple of times in the day. I have a UPS system for my house but the next higher networking device in the hierarchy (my ISPs) reboots everytime this happens - it does not have any backup and the diesel generator to which it is connected takes 10-20 seconds to come online. This might cause the devices to somehow lose connection to the cloud.
The Raspberry Pi2 used for ADS-B receiver is quite capable and I was able to quickly write a cron job that runs every 10 minutes to check if it has a sane connection to the internet and if it doesn't, it reboots the Pi. A blog post documenting it is here.

As for the Vstarcam HD C7838WIP, well its a whole different story. The Linux distro for RPi2 is an SD card image which has many command line utilities pre-installed which makes our life easier. The Vstarcam has its linux running from a flash chip inside it and so the manufacturer had to limit the number of software packages that make it up. But I was able to figure out how to get around those restrictions and have a script running in the background doing its job of detecting internet outage and rebooting the device. Here is how you go about it:


You might have heard of Mirai botnet and there vulnerability it uses to infect security cams like these. Console access to most of these security cams can be gained by simply telnetting into it (although from within the same LAN that they are on) and using the login as "root" and password as "123456" (Read more here). The password "123456" is hard coded into the read only file system and cannot be changed.

Using PuTTY to telnet (not SSH) into the VStarcam
As you can see, the rootfs is mounted in Read Only Mode and so root password cannot be changed.
This is not a big issue since the camera cannot be accessed from outside the LAN anyway.

The df and ls command show us the layout of the memory partitions and filesystem.

The internal flash memory is 32MB
And you can see that I have a 32GB SD card inserted for saving the video recordings.
The /system and /mnt/sda0 (SD card) are the only two read-write areas of this camera. So we can write and save a hand script to chec the "online-ness" of the camera in either of these location. I chose to save it in /system (which is inside the camera itself and not on the easily removed/lost/corrupted SD card)

So I cd over to /system and use the command "vi pingtest.sh" to save the following script.
(Press i to put vi in insert mode, then past the code into your PuTTY, then press Esc and then type :wq! to save and exit)


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
while true; do
        echo "Waiting for 10 minutes"
        sleep 10m
        return_value=$(ping -c 2 -W 4 8.8.8.8)
        return_value=$?

        case $return_value in
                0)echo "Ping result: ONLINE"
                  ;;
                *)echo "Ping result: OFFLINE. Rebooting..."
                  reboot
                  ;;
        esac
done

Once the script is set we need to mark it as executable. Issue the command "chmod +x pingtest.sh".

And now we need to set the script to run in the background at boot up. For that we need to add it to the init script which the manufacturers have created for their on purposes. Issue the command "vi /system/init/ipcam.sh" and add the following line to the end of that script and save it: "/system/pingtest.sh &"

Editing the ipcam.sh


(Use i to insert and Esc and type ":wq!" to save and exit)

The ampersand makes sure that the script is begins running in the background.
After you have saved the script, reboot and check if its is in fact running using the ps command:

ps command shows that the pingtest.sh script is in fact running and so is the "sleep 10"
So what this script does is to check if it is able to ping the Google's Public DNS server. If yes then it goes to sleep for 10 minutes and repeats the process. If the ping fails, it issues the reboot command.

And this will ensure that the camera always stays connected to the internet - ofcourse there will be a downtime of a few seconds when the camera is rebooting and not recording, but that is something I can live with.

Saturday, November 5, 2016

Automatically rebooting piaware and prevent outage (avoid "not feeding ADS-B to FlightAware" emails)

A few months ago, I setup a Raspberry Pi 2 at my house in Pune to monitor the ADS-B signals from aircrafts passing overhead.
I referred the build process outlined here to build my own PiAware setup.



The problem is that roughly twice a week, I used to get this mail saying that my feeder was no longer feeding data to flighaware.

Barring a few rare instances when the trouble was due to internet outage, most of the time it required me to reboot the Raspberry Pi. Eventually I got tired, like a few other users here. Apparently it is due to WiFi dongle hanging or losing connection to the WiFi Router. To get around that, I wrote a script and set it up as scheduled task that runs every 5 minutes. The script checks if the RPi is able to ping Google's Public DNS servers, if yes, then it exits. If the ping fails, it waits for 10 seconds, tries again to ping again and if it fails this time, it issues a reboot command. In both cases, it loges results to a text file (saved on SD card) before exiting. I could then analyse how many times the RPi rebooted later on.

Here is the script (Saved as /home/pi/monitor_gateway.sh):



 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Send two Ping request packets and 4 seconds timeout
Logfile=/home/pi/pingtest.log
 
return_value=$(ping -c 2 -W 4 8.8.8.8)
return_value=$?
# Return code for ping are taken from
# ./OpenWrt-SDK-ar71xx-for-linux-i486-gcc-4.6-linaro_uClibc-0.9.33.2/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/include/sysexits.h
 
case $return_value in
	0)  #Ping reply received
		logger "Ping result: ONLINE"
		TZ="Asia/Kolkata" date | xargs echo -n >> $Logfile
		echo " Ping result: ONLINE" >> $Logfile
		;;
	1)  #Ping sent but reply was not received
		logger "Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds"
		TZ="Asia/Kolkata" date | xargs echo -n >> $Logfile
		echo " Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds" >> $Logfile
		sleep 10
		return_value2=$(ping -c 2 -W 4 8.8.8.8)
		return_value2=$?
		case $return_value2 in
			0)  #Ping reply received
				logger "Ping result: ONLINE"
				TZ="Asia/Kolkata" date | xargs echo -n >> $Logfile
				echo " Ping result: ONLINE" >> $Logfile
				;;
			1)  #Ping sent but reply was not received
				logger "Ping result: OFFLINE (Ping reply not received), Rebooting..."
				TZ="Asia/Kolkata" date | xargs echo -n >> $Logfile
				echo " Ping result: OFFLINE (Ping reply not received), Rebooting..." >> $Logfile
				reboot
				;;
			*)  #Error
				logger "Ping result: OFFLINE (ping return code: $return_value2), Rebooting..."
				TZ="Asia/Kolkata" date | xargs echo -n >> $Logfile
				echo " Ping result: OFFLINE (ping return code: $return_value2), Rebooting..." >> $Logfile
				reboot
				;;
		esac
		;;
	*)  #Error
		logger "Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds"
		TZ="Asia/Kolkata" date | xargs echo -n >> $Logfile
		echo " Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds" >> $Logfile
		sleep 10
		return_value2=$(ping -c 2 -W 4 8.8.8.8)
		return_value2=$?
		case $return_value2 in
			0)  #Ping reply received
				logger "Ping result: ONLINE"
				TZ="Asia/Kolkata" date | xargs echo -n >> $Logfile
				echo " Ping result: ONLINE" >> $Logfile
				;;
			1)  #Ping sent but reply was not received
				logger "Ping result: OFFLINE (Ping reply not received), Rebooting..."
				TZ="Asia/Kolkata" date | xargs echo -n >> $Logfile
				echo " Ping result: OFFLINE (Ping reply not received), Rebooting..." >> $Logfile
				reboot
				;;
			*)  #Error
				logger "Ping result: OFFLINE (ping return code: $return_value2), Rebooting..."
				TZ="Asia/Kolkata" date | xargs echo -n >> $Logfile
				echo " Ping result: OFFLINE (ping return code: $return_value2), Rebooting..." >> $Logfile
				reboot
				;;
		esac
		;;
esac


Here is how my crontab looks like:

You can edit your crontab by issuing the command (on the RPi): sudo crontab -e
I also set my RPi2 to reboot once everyday at 12:00 AM just in case the internet connection
stays alive but dump1090 itself crashes. We could write a script to detect that case as well, but this
preemptive strike seems easy. 


And just for reference, here is what my log file looks like after a day of using the script:
(The Raspberry Pi did reboot a couple of times.)



pi@rpi-lithiumhead-piaware ~ $ cat pingtest.log
Fri Nov 4 10:43:13 IST 2016 Ping result: ONLINE
Fri Nov 4 10:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 11:00:03 IST 2016 Ping result: ONLINE
Fri Nov 4 11:10:02 IST 2016 Ping result: ONLINE
Fri Nov 4 11:20:02 IST 2016 Ping result: ONLINE
Fri Nov 4 11:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 11:40:02 IST 2016 Ping result: ONLINE
Fri Nov 4 11:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 12:00:02 IST 2016 Ping result: ONLINE
Fri Nov 4 12:10:02 IST 2016 Ping result: ONLINE
Fri Nov 4 12:20:02 IST 2016 Ping result: ONLINE
Fri Nov 4 12:30:03 IST 2016 Ping result: ONLINE
Fri Nov 4 12:40:03 IST 2016 Ping result: ONLINE
Fri Nov 4 12:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 13:00:02 IST 2016 Ping result: ONLINE
Fri Nov 4 13:10:02 IST 2016 Ping result: ONLINE
Fri Nov 4 13:20:02 IST 2016 Ping result: ONLINE
Fri Nov 4 13:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 13:40:02 IST 2016 Ping result: ONLINE
Fri Nov 4 13:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 14:00:02 IST 2016 Ping result: ONLINE
Fri Nov 4 14:10:02 IST 2016 Ping result: ONLINE
Fri Nov 4 14:20:02 IST 2016 Ping result: ONLINE
Fri Nov 4 14:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 14:40:02 IST 2016 Ping result: ONLINE
Fri Nov 4 14:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 15:00:02 IST 2016 Ping result: ONLINE
Fri Nov 4 15:10:02 IST 2016 Ping result: ONLINE
Fri Nov 4 15:20:03 IST 2016 Ping result: ONLINE
Fri Nov 4 15:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 15:40:02 IST 2016 Ping result: ONLINE
Fri Nov 4 15:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 16:00:03 IST 2016 Ping result: ONLINE
Fri Nov 4 16:10:04 IST 2016 Ping result: ONLINE
Fri Nov 4 16:20:02 IST 2016 Ping result: ONLINE
Fri Nov 4 16:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 16:40:02 IST 2016 Ping result: ONLINE
Fri Nov 4 16:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 17:00:02 IST 2016 Ping result: ONLINE
Fri Nov 4 17:10:02 IST 2016 Ping result: ONLINE
Fri Nov 4 17:20:02 IST 2016 Ping result: ONLINE
Fri Nov 4 17:30:03 IST 2016 Ping result: ONLINE
Fri Nov 4 17:40:02 IST 2016 Ping result: ONLINE
Fri Nov 4 17:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 18:00:02 IST 2016 Ping result: ONLINE
Fri Nov 4 18:10:03 IST 2016 Ping result: ONLINE
Fri Nov 4 18:20:02 IST 2016 Ping result: ONLINE
Fri Nov 4 18:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 18:40:02 IST 2016 Ping result: ONLINE
Fri Nov 4 18:50:03 IST 2016 Ping result: ONLINE
Fri Nov 4 19:00:02 IST 2016 Ping result: ONLINE
Fri Nov 4 19:10:02 IST 2016 Ping result: ONLINE
Fri Nov 4 19:20:02 IST 2016 Ping result: ONLINE
Fri Nov 4 19:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 19:40:03 IST 2016 Ping result: ONLINE
Fri Nov 4 19:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 20:00:02 IST 2016 Ping result: ONLINE
Fri Nov 4 20:10:02 IST 2016 Ping result: ONLINE
Fri Nov 4 20:20:03 IST 2016 Ping result: ONLINE
Fri Nov 4 20:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 20:40:02 IST 2016 Ping result: ONLINE
Fri Nov 4 20:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 21:00:03 IST 2016 Ping result: ONLINE
Fri Nov 4 21:10:06 IST 2016 Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds
Fri Nov 4 21:10:17 IST 2016 Ping result: ONLINE
Fri Nov 4 21:20:02 IST 2016 Ping result: ONLINE
Fri Nov 4 21:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 21:40:02 IST 2016 Ping result: ONLINE
Fri Nov 4 21:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 22:00:02 IST 2016 Ping result: ONLINE
Fri Nov 4 22:10:02 IST 2016 Ping result: ONLINE
Fri Nov 4 22:20:03 IST 2016 Ping result: ONLINE
Fri Nov 4 22:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 22:40:02 IST 2016 Ping result: ONLINE
Fri Nov 4 22:50:02 IST 2016 Ping result: ONLINE
Fri Nov 4 23:00:02 IST 2016 Ping result: ONLINE
Fri Nov 4 23:10:02 IST 2016 Ping result: ONLINE
Fri Nov 4 23:20:02 IST 2016 Ping result: ONLINE
Fri Nov 4 23:30:02 IST 2016 Ping result: ONLINE
Fri Nov 4 23:40:03 IST 2016 Ping result: ONLINE
Fri Nov 4 23:50:02 IST 2016 Ping result: ONLINE
Sat Nov 5 00:00:02 IST 2016 Ping result: ONLINE
Sat Nov 5 00:10:03 IST 2016 Ping result: ONLINE
Sat Nov 5 00:20:02 IST 2016 Ping result: ONLINE
Sat Nov 5 00:30:02 IST 2016 Ping result: ONLINE
Sat Nov 5 00:40:02 IST 2016 Ping result: ONLINE
Sat Nov 5 00:50:02 IST 2016 Ping result: ONLINE
Sat Nov 5 01:00:02 IST 2016 Ping result: ONLINE
Sat Nov 5 01:10:02 IST 2016 Ping result: ONLINE
Sat Nov 5 01:20:02 IST 2016 Ping result: ONLINE
Sat Nov 5 01:30:02 IST 2016 Ping result: ONLINE
Sat Nov 5 01:40:02 IST 2016 Ping result: ONLINE
Sat Nov 5 01:50:02 IST 2016 Ping result: ONLINE
Sat Nov 5 02:00:03 IST 2016 Ping result: ONLINE
Sat Nov 5 02:10:02 IST 2016 Ping result: ONLINE
Sat Nov 5 02:20:02 IST 2016 Ping result: ONLINE
Sat Nov 5 02:30:02 IST 2016 Ping result: ONLINE
Sat Nov 5 02:40:03 IST 2016 Ping result: ONLINE
Sat Nov 5 02:50:02 IST 2016 Ping result: ONLINE
Sat Nov 5 03:00:06 IST 2016 Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds
Sat Nov 5 03:00:17 IST 2016 Ping result: ONLINE
Sat Nov 5 03:10:03 IST 2016 Ping result: ONLINE
Sat Nov 5 03:20:02 IST 2016 Ping result: ONLINE
Sat Nov 5 03:30:02 IST 2016 Ping result: ONLINE
Sat Nov 5 03:40:02 IST 2016 Ping result: ONLINE
Sat Nov 5 03:50:02 IST 2016 Ping result: ONLINE
Sat Nov 5 04:00:02 IST 2016 Ping result: ONLINE
Sat Nov 5 04:10:02 IST 2016 Ping result: ONLINE
Sat Nov 5 04:20:03 IST 2016 Ping result: ONLINE
Sat Nov 5 04:30:02 IST 2016 Ping result: ONLINE
Sat Nov 5 04:40:02 IST 2016 Ping result: ONLINE
Sat Nov 5 04:50:02 IST 2016 Ping result: ONLINE
Sat Nov 5 05:00:03 IST 2016 Ping result: ONLINE
Sat Nov 5 05:10:02 IST 2016 Ping result: ONLINE
Sat Nov 5 05:20:02 IST 2016 Ping result: ONLINE
Sat Nov 5 05:30:03 IST 2016 Ping result: ONLINE
Sat Nov 5 05:40:03 IST 2016 Ping result: ONLINE
Sat Nov 5 05:50:20 IST 2016 Ping result: ONLINE
Sat Nov 5 06:00:20 IST 2016 Ping result: ONLINE
Sat Nov 5 06:10:27 IST 2016 Ping result: ONLINE
Sat Nov 5 06:20:03 IST 2016 Ping result: ONLINE
Sat Nov 5 06:30:27 IST 2016 Ping result: ONLINE
Sat Nov 5 06:40:02 IST 2016 Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds
Sat Nov 5 06:40:13 IST 2016 Ping result: OFFLINE (Ping reply not received), Rebooting...
Sat Nov 5 06:50:02 IST 2016 Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds
Sat Nov 5 06:50:13 IST 2016 Ping result: OFFLINE (Ping reply not received), Rebooting...
Sat Nov 5 07:00:02 IST 2016 Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds
Sat Nov 5 07:00:13 IST 2016 Ping result: OFFLINE (Ping reply not received), Rebooting...
Sat Nov 5 07:10:02 IST 2016 Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds
Sat Nov 5 07:10:13 IST 2016 Ping result: OFFLINE (Ping reply not received), Rebooting...
Sat Nov 5 07:20:03 IST 2016 Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds
Sat Nov 5 07:20:14 IST 2016 Ping result: OFFLINE (Ping reply not received), Rebooting...
Sat Nov 5 07:30:03 IST 2016 Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds
Sat Nov 5 07:30:14 IST 2016 Ping result: OFFLINE (Ping reply not received), Rebooting...
Sat Nov 5 07:40:02 IST 2016 Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds
Sat Nov 5 07:40:13 IST 2016 Ping result: OFFLINE (Ping reply not received), Rebooting...
Sat Nov 5 07:50:03 IST 2016 Ping result: OFFLINE (Ping reply not received), Retrying after 10 seconds
Sat Nov 5 07:50:14 IST 2016 Ping result: OFFLINE (Ping reply not received), Rebooting...
Sat Nov 5 08:00:02 IST 2016 Ping result: ONLINE
Sat Nov 5 08:10:02 IST 2016 Ping result: ONLINE
Sat Nov 5 08:20:02 IST 2016 Ping result: ONLINE
Sat Nov 5 08:30:02 IST 2016 Ping result: ONLINE
Sat Nov 5 08:40:03 IST 2016 Ping result: ONLINE
Sat Nov 5 08:50:02 IST 2016 Ping result: ONLINE
Sat Nov 5 09:00:02 IST 2016 Ping result: ONLINE
Sat Nov 5 09:10:02 IST 2016 Ping result: ONLINE
Sat Nov 5 09:20:03 IST 2016 Ping result: ONLINE
Sat Nov 5 09:30:02 IST 2016 Ping result: ONLINE
Sat Nov 5 09:40:02 IST 2016 Ping result: ONLINE
Sat Nov 5 09:50:02 IST 2016 Ping result: ONLINE
Sat Nov 5 10:00:03 IST 2016 Ping result: ONLINE
Sat Nov 5 10:10:03 IST 2016 Ping result: ONLINE
Sat Nov 5 10:20:02 IST 2016 Ping result: ONLINE
Sat Nov 5 10:30:02 IST 2016 Ping result: ONLINE
Sat Nov 5 10:40:02 IST 2016 Ping result: ONLINE
Sat Nov 5 10:50:03 IST 2016 Ping result: ONLINE
Sat Nov 5 11:00:02 IST 2016 Ping result: ONLINE
Sat Nov 5 11:10:02 IST 2016 Ping result: ONLINE
Sat Nov 5 11:20:02 IST 2016 Ping result: ONLINE
Sat Nov 5 11:30:03 IST 2016 Ping result: ONLINE
Sat Nov 5 11:40:03 IST 2016 Ping result: ONLINE
Sat Nov 5 11:50:02 IST 2016 Ping result: ONLINE
Sat Nov 5 12:00:03 IST 2016 Ping result: ONLINE
pi@rpi-lithiumhead-piaware ~ $



Sunday, September 11, 2016

MT7688 Duo getting started

Now days I am putting together a basic kit for an IoT course that I am designing.
The kit consists of items purchased from Visha World.
This is what it looks like at the moment.


All of the above components - except MT7688 Duo - can be purchased online from Visha World. For MT7688 Duo, you can visit seeed studio and order it from them. Once I am done designing the course, the details will be available on our training website over at www.seekhow.in and the kit as a whole will be made available at www.vishaworld.com.

As of now, the kit consists of the following:

  1. MT7688 Duo [Buy]
  2. 4GB MicroSD Card
  3. 8 Channel Relay board controllable over USB [Buy]
  4. CH340G Based USB UART
  5. Breadboard [Buy]
  6. Breadboard patch cables 40 way Male to Female 200mm long [Buy]
  7. Breadboard patch cables 40 way Female to Female 200mm long [Buy]
  8. Breadboard patch cables 40 way Male to Male 200mm long [Buy]
  9. USB OTG Cable
  10. DHT11 Temperature Humidity Sensor [Buy]
  11. 0.96" OLED Display [Buy]
  12. microUSB cable for MT7688 Duo's Microprocessor
  13. miniUSB Cable for Relay Board


Step 1: Gaining access to the serial console.
The first thing I did when I got my MT7688 Duo was to get access to its console over UART. For that I used CH340G based USB-TTL convertor with its voltage set to 3.3V. Here is a photo and screenshot:



For wiring details, have a look at Seeed Studio's Wiki Page for MT7688 here.


Step 2: Connecting the MT7688 Duo as a client to your home's WiFi Connection
To know how to connect your MT7688 Duo to your home/office WiFi network, have a look at Seeed Studio's Wiki Page for MT7688 here.

Step 3: Mounting the microSD card
Insert the microSD card and then via the serial console, issue the commands:

cd /dev
mount -t vfat mmcblk0p1 /mnt/

Then issue the command:
df -h
and you will note the microSD card showing up in the list.


Friday, July 22, 2016

Simple chat server and client

Simple Chat IPv4 Server and Client code. Run the server on one computer and the clients on the same network. Whatever one client sents to the server, it is copied and sent to all the clients connected to it. The code is hosted on gist and embedded below.