Voltage Regulator

To use the ESP8266 and the PPD42NS together we need 5V and 3.3V.

There are some ways to achieve this.

First option

Buy a LM1117.

Second option

I didn't have a LM1117, but got a LM317 and two resistors.

The schema to build a voltage regulator with this is:

schema

The source of the image is in https://github.com/opendata-stuttgart/sensors-software/blob/master/schematics/voltage-divider.fzz

Important: The LM317 pins are not as expected! The ADJ is the left pin. For reference see: http://www.st.com/web/en/resource/technical/document/datasheet/CD00000455.pdf

Test the voltage

Using the Arduino it's really easy to measure the voltage. The program is:

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(analogRead(A0) * (5.0 / 1023.0));
  delay(1000);
}

The resulting voltage should be around 3.16V.

First steps with the ESP8266

The first steps are with an ESP8266-01.

Step 1

Connect via a FTDI to the usb of your PC. I'm using FTDI Basic Program Downloader USB to TTL FT232 and Ubuntu 14.04.

Pin layout

see http://playground.boxtec.ch/doku.php/wireless/esp8266

Now map your ftdi pins to the esp8266 pins like this:

ESP <-> FTDI
RX   TX
TX   RX
CH_PD   3.3V
GPIO 0   GND
VCC   3.3V
GND   GND

Step 2

Clone https://github.com/themadinventor/esptool

and run esptool flash_id to see if everything works.

The output for my unflashed esp8266 was:

Manufacturer: c8
Device: 4013

Step 3

Get your new firmware to flash on your esp8266. For example the nodemcu one: https://github.com/nodemcu/nodemcu-firmware/tree/master/pre_build/latest

And now flash it:

sudo python esptool.py write_flash 0x00000 nodemcu_latest.bin

Step 4

Before using the esp8266, the remove GPIO from GND!!

Test with a simple wifi connection in Lua.

One way to upload your lua code is https://github.com/4refr0nt/luatool .

Another quite easy way with GUI is http://esp8266.ru/esplorer/

Imagegeneration for Kindle 4

Task: Generate images displayable on a Kindle 4.

Example code using Python and Pillow:

# -*- coding: utf-8 -*-
from PIL import Image, ImageDraw, ImageFont

image = Image.new("P", (600,800), 255)

# generate a 8 bit greyscale palette
def palette():
  for i in range(0,256):
    yield i;yield i; yield i

image.putpalette(
  list(palette())
)

draw = ImageDraw.Draw(image)

# needs a TrueType font
font_name = "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono-Bold.ttf"
font = ImageFont.truetype(font_name, 100)
# set some text including some unicode
txt = u"TEXT \u2600 \u2602 \u2603"

draw.text((10, 0), txt, 0, font=font)
image.convert('L').save("kindle-image.png", "png")