Wednesday, April 26, 2017

Classroom Timer V1

If you have ever been a teacher at any point in your life, you would have realized the importance of keeping your students engaged and on task at all times during the short period every day that you get to spend time teaching them. If you have just 30 minutes per day, you want to maximize the learning by having a structured lesson plan that moves smoothly from Introduction to New Material to Guided Practice and into Independent Practice. And if you have planned for the lecture properly, you would know how much time you want to spend at each stage doing each activity with the kids to ensure that the lesson is completed on time and doesn't spill over onto the next lecture.

You may have a clock in your class, but having a countdown timer makes more sense in competitive and group activities. When the kids see the time ticking down, and they rush to try to finish the activity on time, it can give them an adrenalin rush and bring excitement to the activity.

I am an engineer by profession and passion. So during as a fellow at Teach For India, I was always looking for ways to enhance teaching through use of technology. And so I made a small classroom timer based on Arduino. The first version had a dot matrix display and switches. Soon, I figured that adding WiFi and controlling the timer using a mobile phone would allow the time to be permanently installed above the blackboard in the classroom and avoid the need to touch the timer repeatedly and hence avoid any breakage due to accidentally dropping the timer.

The first version based on Arduino UNO and 8x8 Matrix display
For the first version I used an Arduino UNO along with a 4 panels of 8x8 LED Matrix Displays. The left most 2 displays displayed the time remaining in minutes and the right most two displays were for the two digits which reported the seconds remaining. These display modules are powered by MAX7219 which allows you to control the displays using just 3 pins of the Arduino UNO. I connected the pins 2,3,4 of Arduino UNO R3 respectively to the DataIn_Pin, Clock_Pin, Load_Pin of the 4 module display. I powered the device using a portable power bank and put everything in a box. There are four switches connected to pins 8, 9, 10 and 11 of the Arduino which allows you to start / pause / stop the countdown as well as set the time that you want to countdown from in increments of 30 seconds.

There are four switches. When you power up the timer, it starts counting down from 1:00 (1 minute). You can pause this by pressing the stop button once, and continue the countdown when you press start button. If you press stop twice, the timer is reset to the last set value (1:00 by default). When the timer is stopped (press stop twice), you can use the up and down buttons to set a new reload time. Once you have set the time, you can press start to start counting down. the switches are wired in active low mode. There are pullups enabled on the 4 points. I have also added external pullup resistors. When the switches are presses, they short the corresponding arduino pin to ground.

Here is a video and photo of the internals:




The first time I set about assembling the device, I used a plastic box. Soon after the plastic box broke and the power bank mal-functioned and so I got a switch box and transferred all the circuitry to the new box. the new box was sturdier and looked neater!

Classroom Timer V1 in a better box


Code

I have made use of the following 3 libraries:

  1. TimerOne - for using a Timer Interrupt to update the display once every second.
  2. LedControl - This one is used for interfacing to MAX7219 displays. I had to modify this library because I used the modules upside down.
  3. PinChangeInt - Since the 4 buttons are connected to interrupt pins, I have sued Pin Change interrupts to respond to button presses. 
Many of these libraries are continuously updated, and the newer version might not work with my existing code. Also I had to modify LedControl library as mentioned above - so I have created a github repository for the code as well as a library here: https://github.com/lithiumhead/ClassroomTimerV1
In case you want to use the code, download the 3 library folders to your Documents\Arduino\libraries folder, then download the .ino file and put it in a new folder on your computer. make sure this folder has the same name as the .ino file. double click on the .ino file and use Arduino to download the code onto your Arduino UNO R3.
The ClassroomTimerV1.ino file is present in the github repo above and is also embedded as a gist below:


Tuesday, April 25, 2017

tweet.sh on LinkIt Smart 7688 Duo (OpenWrt)

Temboo-less tweeting from the shell

LinkIt 7688 Duo is a cheaper ($15.9 vs $74.95) and breadboardable version of Arduino Yun. Arduino Yun comes preloaded with Temboo whereas LinkIt does not have that preloaded. Temboo is a great go between service that allows your IoT project to talk to existing services like google drive, twitter or dropbox - but to do anything long term and meaningful with it, you have to upgrade from a free temboo plan to a paid plan - Arduino Yun is already expensive and this makes it even moire expensive. I used Arduino Yun and Temboo to make a shimmering lamp that reacts to tweets from your sweetheart - But now it was time to move on to better yet cheaper builds.

A Raspberry Pi running Node Red can achieve a lot but here I want to focus on LinkIt because I am using it as a part of a larger "art" project. Since LinkIt has an AVR microcontroller (Arduino programmable over WiFi and Arduino Bridge), it allows for greater flexibility in interfacing to sensors and modules via the microcontroller. Also, until someone (or me) ports Node Red to OpenWrt platforms, I would prefer to use bash scripts and Arduino code to get my bidding done.

So one of the first things on my agenda was to figure out a Temboo less way of fetching tweets. What is outlined below is how I got https://github.com/piroor/tweet.sh (which is a bash script to fetch tweets)to work on OpenWrt - more specifically LinkIt 7688 Duo. For this, we wont be writing any Arduino code since the Microcontroller does not come into play (yet). But what we will be doing is playing around with bash scripts and cross compiling 2 packages for OpenWrt.

My LinkIt 7688 Duo as a part of a larger project.
The LinkIt is the one in the middle. The one on a bottom is a 5V powersupply.
And the one on top is a dimmer circuit - similar to the one I used in my twitter lamp project

Step 1 - Cross compiling packages required by tweet.sh

Since tweet.sh is just a bash script, it requires certain packages to exist on your system. They are curl, jq, nkf, openssl. Of these openssl and curl can be installed on your LinkIt since they are a part of the OpenWrt repositories. But jq and nkf - these you will have to cross compile on a Linux PC and transfer them to LinkIt.

Here are the steps to make sure you have all the packages required by tweet.sh on your LinkIt:


  1. Connect your LinkIt to your home's WiFi network - check this
  2. Figure out your LinkIt's IP address - there are many ways to do this:
  3. Using my router's page to figure out the IP addresses of my 2 LinkIts connected to my home network.
    The MAC addresses of LinkIt begin with 9e:65:f9
    (Yes I have OpenWrt installed on my home router as well)
    Using Arduino IDE to figure out the IP addresses of LinkIt
    1. You may need to log on to your WiFi Router's page from your PC and look at the list of devices and IP addresses.
    2. You can install Arduino on your PC, add support for LinkIt 7688 Duo and then wait for a few moments till Arduino automatically discovers the LinkIt. Then you can look under Tools>Ports
  4. Use PuTTY to login to your LinkIt 7688 Duo. Login will be "root" and password would be whatever you set during the getting started stage.
  5. Lets install the basic packages that are required and available - execute the following commands on LinkIt over PuTTY:

    opkg update

    opkg install ip curl openssl bash nano grep getopt bc ca-certificates 
  6. We still need to install nkf and jq. For that, we will need to use a Linux computer - preferable one running Ubuntu and perform the following steps (on your Linux PC not LinkIt):
    1. Download OpenWRT SDK for Linux from here onto your x64 Ubuntu Laptop. (I used Ubuntu 15.10 x64 on a VirtualBox Virtual Machine - I used a virtualbox image from http://www.osboxes.org/)
    2. Extract the folder to your home folder:
      tar -xvf OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar
    3. Install some required build tools on your Ubuntu PC:
      sudo apt-get install autoconf build-essential
    4. Set the environment variables:

      export PATH=~/OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_uClibc-0.9.33.2/bin:$PATH

      export STAGING_DIR=~/OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/staging_dir
    5. Change to ~/OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar/package :
      cd ~/OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64.tar/package
    6. Create two folders here:
      mkdir jq
      mkdir nkf
    7. Create the makefile for jq and place it in the jq directory that you just created. (Appended Below):
      gedit jq/Makefile
    8. Create the makefile for nkf and place it in the nkf directory that you just created (Appended Below)
      gedit nkf/Makefile
    9. Go back to ~/OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64:
      cd ~/OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64
    10. And issue the make command:
      make
    11. cd to the ourput directory:
      cd ~/OpenWrt-SDK-ramips-mt7688_gcc-4.8-linaro_uClibc-0.9.33.2.Linux-x86_64/bin/ramips/packages/base
    12. You will find the two .ipk files:
      jq_1.5_ramips_24kec.ipk
      nkf_2.1.4-1_ramips_24kec.ipk
    13. Copy these two ipk files to your LinkIt 7688 duo. you can do this in many ways but the best way is to use scp protocol. In my case I simply copied the files from my Ubuntu Virtual Machine to my Windows machine and used WinSCP (Make sure file protocol is set to SCP) to login into my LinkIt and copied the .ipk files to the /root folder there.
    14. Issue the following commands to install jq and nkf on your LinkIt (Issue commands over PuTTY while in /root directory):
      opkg install jq_1.5_ramips_24kec.ipk
      opkg install nkf_2.1.4-1_ramips_24kec.ipk
    15. And you are done with installing the required packages
Here are the Makefiles for cross compiling jq and nkf

Makefile for nkf:

 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
include $(TOPDIR)/rules.mk

PKG_NAME:=nkf
PKG_VERSION:=2.1.4
PKG_RELEASE:=1

PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_SOURCE_SUBDIR).tar.gz
PKG_SOURCE_URL:=http://dl.osdn.jp/nkf/64158/
PKG_MD5SUM:=dbce0a2131cd4e30f73cbfdcc57c06ec

PKG_BUILD_PARALLEL:=1
PKG_INSTALL:=1
PKG_USE_MIPS16:=0

PKG_LICENSE:=MIT
PKG_MAINTAINER:=Yoshio HANAWA <for-openwrt@hnw.jp>

include $(INCLUDE_DIR)/package.mk

define Package/nkf
  SECTION:=utils
  CATEGORY:=Utilities
  TITLE:=Network Kanji code conversion Filter (NKF)
  URL:=https://osdn.jp/projects/nkf/
endef

define Package/nkf/description
  Network Kanji code conversion Filter (NKF)
endef

MAKE_INSTALL_FLAGS += \
  prefix="$(PKG_INSTALL_DIR)" \
  MKDIR="mkdir -p"

define Package/nkf/install
 $(INSTALL_DIR) $(1)/usr/bin
 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/nkf $(1)/usr/bin/
endef

$(eval $(call BuildPackage,nkf))

Makefile for jq:
 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
#jq is written in C and has no runtime dependencies, so it should be possible to build it for nearly any platform. Prebuilt binaries are available for Linux, OS X and Windows.
#The binaries should just run, but on OS X and Linux you may need to make them executable first using chmod +x jq.
#jq is licensed under the MIT license. For all of the gory details, read the file COPYING in the source distribution.

include $(TOPDIR)/rules.mk

PKG_NAME:=jq
PKG_VERSION:=1.5
PKG_RELEASE:=

PKG_SOURCE_URL:=https://github.com/lithiumhead/jq
PKG_SOURCE_PROTO:=git
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_VERSION:=b3078a3b1c1b3285926151e0e3af886877e7395d
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz

PKG_FIXUP:=autoreconf -i
PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk

define Package/jq
  SECTION:=Utilities
  CATEGORY:=Utilities
  DEPENDS:=
  TITLE:=jq json interface
  URL:=
endef

define Build/Compile
 $(MAKE) -C $(PKG_BUILD_DIR) CFLAGS=-msoft-float
endef

define Package/jq/install
 $(INSTALL_DIR) $(1)/usr/bin
 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/jq $(1)/usr/bin/
endef

$(eval $(call BuildPackage,jq))

Step 2 - Cross compiling packages required by tweet.sh

Next we need to get tweet.sh onto LinkIt and configure it.
  1. Visit https://github.com/lithiumhead/tweet.sh download tweet.sh and tweet.client.key to your PC and transfer it to your LinkIt using WinSCP. You can also download the two files directly to your LinkIt by issuing 2 commands over PuTTY:
    curl -O https://raw.githubusercontent.com/lithiumhead/tweet.sh/master/tweet.sh
    curl -O https://raw.githubusercontent.com/lithiumhead/tweet.sh/master/tweet.client.key
  2. Mark tweet.sh as executable:
    chmod +x tweet.sh
  3. Now we need to configure the keys and add them to tweet.client.key on LinkIt. Visit twitter.com and login to your twitter account.
  4. Next open a new tab in the same browser and visit https://apps.twitter.com/
  5. Click on "Create New Apps"
  6. Enter something in Name, Description and Website
  7. Accept the Developer Agreement and click "Create your Twitter Application"
  8. Now click on your newly created application and click on "Keys and Access Token"
  9. Open tweet.client.key over WinSCP and copy and past key from the webpage to tweet.client.key
    1. Enter your twitter handle next to MY_SCREEN_NAME=
    2. Enter "en" next to MY_LANGUAGE=
    3. Copy the string mentioned next to Consumer Key (API Key) to CONSUMER_KEY=
    4. Copy the string next to Consumer Secret (API Secret) to CONSUMER_SECRET=
    5. Copy Access Token to ACCESS_TOKEN=
    6. Copy Access Token Secret to ACCESS_TOKEN_SECRET=
    7. Click save
Editing tweet.client.key
The original tweet.sh is published at https://github.com/piroor/tweet.sh but I had to fork it and make some modification to it so that it would run on OpenWrt. I have forked it at https://github.com/lithiumhead/tweet.sh and that's what we have used. (Modifications involved creating symbolic links to stdin and stdout in proc file system - these are lacking by default in OpenWrt)

Finally everything is set and we can test our tweet.sh setup by fetching the latest tweet from - say - elonmusk, piping it through jq and printing only the unique tweet id and the text of the tweet itself:

./tweet.sh search -q "from:elonmusk" -c 1 | jq '.statuses[0].id, .statuses[0].text'


tweet.sh running in a PuTTY window with Twitter open in Google Chrome


Thursday, April 20, 2017

Dealing with WiFi IP Cameras and .264 files

On a recent visit to China, I purchased a cheap IP camera which looks like a robot:

You can get one online from amazon for twice the amount that you might pay for it when you buy it from one of the shops in ShenZhen (I got it for around 150 CNY or 1500 INR). The camera is supposed to be installed in your house where you can configure it to connect to your home's WiFi router. That way you can connect to the camera from anywhere in the world (using your web browser or smart phone app) and watch and hear what ever the camera picks up. Here are some of the features of this camera:

  • Tech Specs (you can find these on the amazon page as well, although the model might say something else)
    • Model: The packaging for my camera said "Mini Robot Wireless Camera H811 IP Camera"
    • Power: DC Input 5V 2Amps (via microUSB connector)
    • Image quality: 960P 1.3Megapixel
  • WiFi:
    • Out of the box, the camera defaults to WiFi master mode (i.e. wifi hotspot) . This is so that you can use the app on your smartphone to connect to it and if required, you can configure the camera to switch to client mode and connect to your home's WiFi router.
    • By default, when you look for it, the SSID of the WiFi signal emitted by the camera would be something like: "HSL-337026-GDDEN"
    • The default WiFi WPA2 key is 0123456789
    • Android app:
      • The app for your smart phone is called NetCam (Google Play Store link)
    • Computer:
      • In case you connect to the camera using a laptop, punch in the following URL into your web browser: http://192.168.246.1:81/
      • It will ask you for login credentials, enter "admin" as login and leave the password blank.
  • Reset button and microSD card slot:
    • The camera has a microSD card slot on the back. If you install a microSD card, the camera will also record the video (only video no audio) onto the SD card.
    • The small hole next to the camera on the back is for resetting the camera in case you forget its login password (this is separate from the WiFi password)
  • Physical structure:
    • The bottom part of the camera is made of iron and the camera head itself has a magnet in it. This allows you to screw in the bottom of the camera wherever you want and them attach the camera head and orient it in any direction you want.
    • The bottom of the camera also has a QR code which you can scan with your smart phone app to connect to it for the first time. The QR code has the WiFi Master SSID encoded into it.

So what did I do with the camera? I mounted it in my car as my dashcam. The problem is that the camera does not have a battery backed real time clock (RTC) and there is no internet (which would have helped re-sync the clock because the camera supports network time protocol or NTP) in my car so the camera does not maintain the time when I turn off the car (and power to the camera is cut). I use a 2 amp 5V smart phone charger that plugs into my cigarette lighter to power the camera. I could have connected the camera directly to the 12V battery and that would have ensure that the camera ran continuously and never lost time, but then my car battery would get drained as well.






I installed the base (made of iron) of the camera onto my rear view mirror and the camera heat got attached to the base thanks to the magnet present inside the head.

About RTC and NTP:
As mentioned above, this camera does not have any battery (neither Li-ion or coin cell) to main clock when the car is turned off. The camera can act as a WiFi client and can synchronize its time at boot up using an NTP server. But for I would need to get an internet connection for my car - possibly a 3G/4G hotspot. In cases where one does not want to do all that, there is a way out. The Global Positioning System is essentially made up of atomic clocks orbiting Earth. We can use a GPS receiver along with a WiFi capable microcontroller and implement the NTP server functionality. There is a tutorial on instructable on how to go about it: http://www.instructables.com/id/ESP8266-Wireless-NTP-Stratum1-Server/ - what this instructable allows you to do is to make a small WiFi Access Point (using ESP8266) that doubles up as an NTP server. When you connect your devices (this camera or your smart phone) it would be able to access the internet but you can configure the NTP server address to point to this ESP8266 device and atleast your time synchronization will work. (Another similar project)

About handling the .264 media files on a Windows desktop
You can connect to the camera using the Android app to watch live video and configure the camera, but there is no way for you to review the video recorded by the camera while the memory card is inside the camera. The android app has no option to playback the recordings. The only way is for you to remove the memory card and insert it into a memory card reader and either connected it to your computer or to your android phone using a USB OTG cable.
The moment you remove the microSD card and insert it into a card reader and attach it to your Windows PC, this is what you see:


The camera fills up the microSD card with equal sized stub files

The camera has filled up the memory card with stub files. The camera starts recording the video into first file. When one file fills up (around 5 minutes worth of video), it continues recording in to the next file in sequence. This ensures that in case the power is cut to the camera (e.g. car accident/break in), atleast the last file would have been saved properly and would help in investigation.

Playing back on Desktop:
You can use VLC Media Player to play these .264 files. You have to make a small change in the settings:

  1. Select View>Preferences
  2. Switch to "All" under Show Settings
  3. Click on "Demuxers" under Input/Codecso
  4. Select "H264 video demuxer" from the drop down list and click Save
  5. Now you can drag and drop .264 files into VLC media player and play them back
  6. Make sure to change the Demux module setting from "H264 video demuxer" back to "Automatic" once you are done with playing .264 files. This will allow you to play your regular video files correctly.
Here are the screenshots to clarify the above steps:





You will note that when playing .264 files, you don't hear any audio. I am not sure if the camera records audio or not but, according to what I have read in discussion forums, no one has gotten any audio playback from these raw H264 format video files.

Converting videos on Desktop:
In case you want to convert the video to mp4 format, there are two steps that you have to follow:

  1. Use ffmpeg to convert the .264 file in to raw uncompressed AVI file. This will take care of stream errors which usually creep in when the power supply to the camera (like in a car) is not reliable or when the camera experiences vibration.
  2. Use ffmpeg to convert the uncompressed file to mp4

Here are the steps in the conversion process:
  1. Visit http://ffmpeg.zeranoe.com/builds/ and download the latest stable, static 32bit version.
  2. Unzip the file into a folder on your computer.
  3. Move your .264 video file into the bin folder of the ffmpeg folder
  4. Open a command prompt and cd to the ffmpeg/bin folder
  5. Issue the command ffmpeg -i apf00047.264 -vcodec rawvideo -y output.avi
    This will begin converting the file apf00047.264 into a raw uncompressed file.
    During the conversion process, ffmpeg will display a number of messages about finding errors in the stream and compensating for it. Once the conversion process is done, you will realise that the 64MB file has been converted to an .avi file occupying 6.8 GB of space. You can try playing this file in VLC player (make sure to set Demux module back to Automatic)
  6. Finally you can convert the uncompressed avi file to mp4 format using the command:
    ffmpeg -i output.avi output.mp4
    Once that is done, you can delete the output.avi uncompressed video file. The output.mp4 video file can be uploaded to Youtube and Facebook if required. The .mp4 file can also be played using VLC player. It of course wont have any audio - that's the issue of the camera. The output.mp4 would be around 107 MB in size.
Here some screenshots outlining the above steps:

Downloading the ffmpeg utility for Windows

Copy your .264 video file to the bin folder within the extracted ffmpeg folder

Opening a command prompt and navigating to the ffmpeg's bin folder

Issuing a command to start conversion of .264 to uncompressed .avi format
ffmpeg spews messages regarding stream errors while creating uncompressed .avi file
The uncompressed output.avi file is huge - 6.8 GB
You can play the uncompressed output.avi in VLC Player

Executing ffmpeg a second time to convert uncompressed .avi to .mp4 format

Playing output.mp4 in VLC Player


Playing back on Android Phone:
You can use a USB OTG cable along with a card reader to connect the microSD card to your android phone. Once you do that - and if your phone supports USB OTG - a notification will pop up allowing you to explore the files on the microSD card. Now you can use this file explore feature and long press the .264 file that you are interested in to select it. Once selected, copy it to your phones internal memory. Then start the MX player app. The MX player (Free version with ads | pro version) app scans the phone's memory for video files, and this .264 file will show up as well. Just tap on it and the video will start playing.

Use the OTG Cable to connect card reader to the Android phone.
Explore the file using Android's builtin feature an copy the files to phone's internal memory.

MX Player app shows the recently copied .264 video file.


Tap on the file to play it.





Thursday, February 23, 2017

Arduino code for ESP8266 to take readings from DHT11 and upload them to InitialState.com

www.initialstate.com is a great data broker and visualization platform for IoT devices. Up until now it was out of reach for ESP8266 fans because the Arduino environment for ESP8266 did not support SSL/TLS connections. But now it does. So here is how to get HTTPS working on ESP8266 using Arduino IDE and upload readings from DHT11 every 10 seconds.

ESP8266 and DHT11
 Steps for Windows computers:

  1. Install CP2102 drivers for the USB-UART chip onboard the ESP8266 NodeMcu v1.0 board
  2. Get the latest offline Arduino IDE Windows Installer from https://www.arduino.cc/en/Main/Software
  3. Install Board support for ESP8266 in your Arduino IDE, follow instructions here:
    https://learn.sparkfun.com/tutorials/esp8266-thing-hookup-guide/installing-the-esp8266-arduino-addon
  4. Assemble your ESP8266 and DHT11 circuit. You will need 3 jumper cables and a breadboard to connect 3 signals from ESP8266 to DHT11 module. Connect pin marked D2 on ESP8266 to DHT11's data pin. Also supply 3.3V and GND from ESP8266 to DHT11's Vcc and GND.
  5. Plug your ESP8266 into your computer's USB port using a microUSB cable.
  6. Get a free account on www.initialstate.com, create a new bucket and make a note of the Bucket key and Access key.
  7. Download shown below and open it in your Arduino IDE
  8. Modify 4 things by supplying your own:
    1. WLAN_SSID
    2. WLAN_PASS
    3. INITIALSTATE_ACCESS_KEY
    4. INITIALSTATE_BUCKET_KEY
  9. Download the code into your ESP8266 board and watch it go! Keep the Serial Monitor within Arduino IDE open to watch what data is being sent to www.initialstate.com
Data received on initialstate.com
Watch the code go on Serial Monitor
InitialStateDHT11.ino:

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