Monday, April 10, 2017

ESP01 Break-in board

I created several projects with EPS8266 wifi modules.
The small cheap ESP01 module has only a few IO pins so i did not used it until now.
In one of my recent Aliexpress China orders i also added a small cheap ESP01S module to my shopping list. I also ordered some boards to easy test and use of this module: ESP01 has 2x4 pins close to each other.
 Not easy to use on a breadboard therefore i also added to my shopping list.
(Right to left. [First is the ESP01 module itself] ) 
  • ESP01 - Breadboard interface. 
  • ESP01 - TTL interface
  •  ESP01 - USB interface
My plan was to use the ESP01 - USB interface board to program an test the ESP8266 module.
Then the disappointment : to program the small ESP01 module you need to pull GPIO0 to ground. My cheap interface USB module has no jumper or switch to do that!
A reset button would also be nice.
And perhaps easy access to all the pins to experiment.
If i would use the TTL interface wired this to a USB TTL / RS232 (FTDI) interface cable i would have the same problem.
An option would be start from zero, using a breadboard interface, and make my own interface.
 (Later i found there are some ESP01 USB modules with programming switch. I did not find one with programming switch and reset button!)
ESP01 with USB Module 

But what is the use of these cheap "ready to use" interfaces. For programming, testing and debugging I decided to make my "ESP01 Break-in board". A board to put between the ESP01 and the boards with the 2*4 connector.
(I decided to call it "Break in board". It is not a "Break out board" to use and get access to chip pins but a "Break in" to put between the existing connections to add features.)
It needed (minimal) a programming switch, a reset button and access to the pins.
Later on i decided to add also some additional features. (See photo, final specs/feature list below.) This are additional features but not really needed.
I used a small double Side Prototype PCB Bread board Tinned Universal 20x80 mm FR4 28*6 holes.
ESP01 "Break in board"
 with EPS and USB
connected.
 (All holes are plated through). I added pins to fit in a 2*4 pin connector (on bottom) and additional 2 times 4 pins to get easy access to all pins and a female 2*4 connector for the ESP01 module (on the top). On my (current) laptop free USB connectors are at the left side. I wired my "Break-in board" with this in mind. (USB connector pointing to the right when using this board).
Mark on the PCB with an arrow the direction of the ESP01 module.
A push button is used for the reset, (Bottom of the PCB) wired to ground and reset.
While uploading a program i do not want to continuously press a button. I decided to use a small slide switch (Top).
In stock i had a three position switch. If you have a small two position slide switch you use that. The three position switch i used has 6 pins: (and two shield pins)
Left no pins are connected
Middle pin 1 and 4 are connected ' / pin 3 and 5 connected "
Right pin 1 and 4 are connected '
Pin 2 and 6 have no use (n.c.), i did bend them away and soldered the switch on the PCB. I decided to use the middle position as programming position and wired pin 2 and 5 ' to ground and GPIO0.
3 position switch
At this point my basic minimal "ESP01 Break-in board" was ready.
ESP01 "Break in" board. (top view)
 On my board i also added some other things i had in stock:

  • 6 female pins connected to to ground (and next to it a) 
  • 25 Points Mini Solderless Prototype Tie-point Breadboard 
  • A micro switch (three pins Common, Normal open, Normal closed ) with connections to pins to easy wire them for experiments. (on bottom next to reset pushbutton).
  • Passive electromagnetic impedance 16 ohm AC buzzer/2KHz 3V 5V universal buzzer (- connected to ground, other side to a pin and 100 ohm resistor with a second pin. -
On my slide switch at pin 1 and pin 4 ' contacts available are (Left open, Middle and Right closed), i wired them to two pins on the PCB.
The condensator on the ESP01 - USB interface board comes very close to PCB. Some insulation tape was added. As a final touch i used cable ties to join some cable bundles.

ESP01 "Break in" board (bottom view)
RESULT: "ESP01 Break-in board":
Switch for programming the ESP01,
Reset button,
Easy access to all pins of the ESP01.
Some additional switches.
A mini buzzer (One side connected to ground. Connect the other side e.g. with a Dupont cable to GPIO2)
Mini solderless prototype board for additional components/experiments.
ESP01 "Break in" with ESP01 and USB (bottom view)

Saturday, April 8, 2017

Funduino Joystick shield

Funduino Joystick shield

From Aliexpress i got a Arduino Gamepads JoyStick KeypadShield PS2  (I recently found it at another seller for 2,33 Euro ) 


Using Google i found out there are some different versions.
My shield  (V1.A ) uses the following connections

D2 Key A UP
D3 Key B RIGHT
D4 Key C DOWN
D5 Key D LEFT

D6 Key E Start
D7 Key F Select

D8 Analog button
A0 AnalogX Joystick
A1 AnalogY Joystick

There are some headers to get to the other Arduino pins.

Some headers are pre arranged for special interfaces (On my board I2C, Bluetooth, Nokia5110 display, nRF24L01)
A slide switch to select between 3V3 and 5V mode.
A red power led

TestScript

/*
JoystickArduinoBasicExample

A basic sketch to demonstrate reading values from the joystick shield

How to use:
* Connect joystick shield to your Arduino
* Upload this sketch to your Arduino
* Open the Arduino IDE Serial Monitor (set to 9600 baud)
* Waggle joystick, push buttons

Requires:
* Arduino
* Joystick Shield

April 2017 by JJ adapted version of a version
written for SparkFun Arduino Inventor's Kit CIRC-JOY
Based on original example by Ryan Owens
*/

// Store the Arduino pin associated with each input

const byte PIN_BUTTON_UP = 2;
const byte PIN_BUTTON_RIGHT = 3;
const byte PIN_BUTTON_DOWN = 4;
const byte PIN_BUTTON_LEFT = 5;

const byte PIN_BUTTON_START = 6;
const byte PIN_BUTTON_SELECT = 7;

const byte PIN_BUTTON_JOY = 8; // Select button is triggered when joystick is pressed
const byte PIN_ANALOG_X = 0;
const byte PIN_ANALOG_Y = 1;

void setup() {
Serial.begin(9600);
// Specify each pin connected to a pushbutton as an input.
// Also enable the Arduino's internal "pull-up" resistors
// for each pushbutton we want to read--this means the shield
// doesn't need to have resistors on it.
// Note that when a pull-up resistor is used on a pin the
// meaning of the values read are reversed compared to their
// usual meanings:

// * HIGH = the button is not pressed
// * LOW = the button is pressed

pinMode(PIN_BUTTON_RIGHT, INPUT);
digitalWrite(PIN_BUTTON_RIGHT, HIGH);

pinMode(PIN_BUTTON_LEFT, INPUT);
digitalWrite(PIN_BUTTON_LEFT, HIGH);

pinMode(PIN_BUTTON_UP, INPUT);
digitalWrite(PIN_BUTTON_UP, HIGH);

pinMode(PIN_BUTTON_DOWN, INPUT);
digitalWrite(PIN_BUTTON_DOWN, HIGH);

pinMode(PIN_BUTTON_START, INPUT);
digitalWrite(PIN_BUTTON_START, HIGH);

pinMode(PIN_BUTTON_SELECT, INPUT);
digitalWrite(PIN_BUTTON_SELECT, HIGH);

pinMode(PIN_BUTTON_JOY, INPUT);
digitalWrite(PIN_BUTTON_JOY, HIGH);
}

void loop() {
// Print the current values of the inputs (joystick and
// buttons) to the console.
Serial.print("l:");
Serial.print(digitalRead(PIN_BUTTON_LEFT));
Serial.print(" ");
Serial.print("r:");
Serial.print(digitalRead(PIN_BUTTON_RIGHT));
Serial.print(" ");

Serial.print("u:");
Serial.print(digitalRead(PIN_BUTTON_UP));
Serial.print(" ");

Serial.print("d:");
Serial.print(digitalRead(PIN_BUTTON_DOWN));
Serial.print(" / ");

Serial.print("g:");
Serial.print(digitalRead(PIN_BUTTON_START));
Serial.print(" ");

Serial.print("s:");
Serial.print(digitalRead(PIN_BUTTON_SELECT));
Serial.print(" / ");

Serial.print("j:");
Serial.print(digitalRead(PIN_BUTTON_JOY));
Serial.print(" ");

Serial.print("x:");
Serial.print(analogRead(PIN_ANALOG_X));
Serial.print(" ");
Serial.print("y:");
Serial.print(analogRead(PIN_ANALOG_Y));
Serial.print(" ");

Serial.println();
}

Links

Friday, April 7, 2017

Arduino_LCD_TFT_SDcard_shield_breakout

Using a Arduino TFT LCD shield in your project has some disadvantages.
1) The LCD TFT and SDcard occupy most of the IO pins on an Arduino Uno.
2) The IO pins are not easy accessible to connect other hardware.
This blogpost describes how i solved this second issue.
When using the shield with the LCD TFT the SDcard fee IO pins are :


  • A5 Analog5
  • D0 RX
  • D1 TX

  • D0 and D1 are also used for serial communication over USB but can be used if the Arduino is used standalone.
    For interfacing i also wanted access to GND, +5V and 3V3.
    I used some colored cables with a female Dupont connectors on one side. Male connectors can easy give short circuit if not in use, so i used female.
    You can easy create them from cutting a long Dupont Cables in two parts.
    I put them trough heat shrink tube and soldered them on my LCD TFT shield.
    You can use any color scheme, but Black for GND  and Red for the Power can give less confusion in your projects. I used this colors:
    3V3Orange
    +5VRed
    GNDBlack
    A5 Analog5Brown
    D0 RXGreen
    D1 TXYellow
    After soldering and arranging the cables i heated heat shrink tube.
    The female Dupont connectors are available to interface your project.
    As there are some differences between the shields i do not provide a script to display the analog signal on the TFT LCD for testing. Better use the Arduino program below that sends the Analog signal A5 to the serial (USB) port.

    /* 2016 Analog A5 JanJeronimus
    Get Analog 5 value every second
    Writes time [ uptime millis() ]  , 
     analog gas sensor value to the serial port
    */

    const int PinA5 = A5 ; //Connect Arduino analog A5 pin to sensor

    int val = 0;     // variable to store the Digital read value

    void setup()
    {
    Serial.begin(9600); //Initialize serial port - 9600 bps
    }

    void loop()
    {
    Serial.print( millis() ) ;
    Serial.print( " ,  " ) ;
    Serial.println( analogRead(PinA5) );
    delay(1000); // Print value every 1 sec.
    }

    On codebender :





    Thursday, April 6, 2017

    Arduino Multi Function Shield

    Intro

    The Multi Function Shield is a nice shield with some components to so some experiments with your Arduino. On the shield are two jumpers. It is always the question in what position do you need to put the jumpers. The answer will be in this post.

    Before using this shield I added some isolation tape at the bottom as is am not happy with some pins of 7 segment displays close to the metal USB connector. On http://arduinolearning.com/code/multi-function-shield-examples.php i found some easy experiments to start. (using 4 leds, button1, button2, pot1 and the 7 segment display)

    Code Examples

    Blinking LED

    ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    int led = 13;
    void setup()
    {
    // initialize the digital pin as an output.
    pinMode(led, OUTPUT);
    }
    void loop()
    {
    digitalWrite(led, HIGH);
    delay(1000);
    digitalWrite(led, LOW);
    delay(1000);
    }

    All LEDS blinking

    ?
    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
    int led1 = 13;
    int led2 = 12;
    int led3 = 11;
    int led4 = 10;
    void setup()
    {
    // initialize the digital pin as an output.
    pinMode(led1, OUTPUT);
    pinMode(led2, OUTPUT);
    pinMode(led3, OUTPUT);
    pinMode(led4, OUTPUT);
    }
    void loop()
    {
    digitalWrite(led1, HIGH);
    digitalWrite(led2, HIGH);
    digitalWrite(led3, HIGH);
    digitalWrite(led4, HIGH);
    delay(1000);
    digitalWrite(led1, LOW);
    digitalWrite(led2, LOW);
    digitalWrite(led3, LOW);
    digitalWrite(led4, LOW);
    delay(1000);
    }

    Switches example

    ?
    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
    const byte LED[] = {13,12,11,10};
    #define BUTTON1 A1
    #define BUTTON2 A2
    void setup()
    {
    // initialize the digital pin as an output.
    /* Set each pin to outputs */
    pinMode(LED[0], OUTPUT);
    pinMode(LED[1], OUTPUT);
    pinMode(LED[2], OUTPUT);
    pinMode(LED[3], OUTPUT);
    }
    void loop()
    {
    if(!digitalRead(BUTTON1))
    {
    digitalWrite(LED[0], HIGH);
    digitalWrite(LED[1], HIGH);
    digitalWrite(LED[2], HIGH);
    digitalWrite(LED[3], HIGH);
    }
    if(!digitalRead(BUTTON2))
    {
    digitalWrite(LED[0], LOW);
    digitalWrite(LED[1], LOW);
    digitalWrite(LED[2], LOW);
    digitalWrite(LED[3], LOW);
    }
    }
    I discovered that you need add jumper J2 to use the buttons!

    Potentiometer 1

    ?
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    #define Pot1 0
    void setup()
    {
    Serial.begin(9600);
    }
    /* Main Program */
    void loop()
    {
    Serial.print(“Potentiometer reading: “);
    Serial.println(analogRead(Pot1));
    /* Wait 0.5 seconds before reading again */
    delay(500);
    }

    Pot and led

    ?
    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
    const byte LED[] = {13,12,11,10};
    #define Pot1 0
    void setup()
    {
    Serial.begin(9600);
    // initialize the digital pin as an output.
    /* Set each pin to outputs */
    pinMode(LED[0], OUTPUT);
    pinMode(LED[1], OUTPUT);
    pinMode(LED[2], OUTPUT);
    pinMode(LED[3], OUTPUT);
    }
    /* Main Program */
    void loop()
    {
    int PotValue;
    //Serial.print("Potentiometer reading: ");
    PotValue = analogRead(Pot1);
    /* Wait 0.5 seconds before reading again */
    if(PotValue < 400)
    {
    digitalWrite(LED[0], LOW);
    digitalWrite(LED[1], LOW);
    digitalWrite(LED[2], LOW);
    digitalWrite(LED[3], LOW);
    Serial.print("Potentiometer: ");
    Serial.println(PotValue);
    }
    else
    {
    digitalWrite(LED[0], HIGH);
    digitalWrite(LED[1], HIGH);
    digitalWrite(LED[2], HIGH);
    digitalWrite(LED[3], HIGH);
    Serial.print("Potentiometer: ");
    Serial.println(PotValue);
    }
    delay(500);
    }

    segment display

    ?
    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
    /* Define shift register pins used for seven segment display */
    #define LATCH_DIO 4
    #define CLK_DIO 7
    #define DATA_DIO 8
    /* Segment byte maps for numbers 0 to 9 */
    const byte SEGMENT_MAP[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0X80,0X90};
    /* Byte maps to select digit 1 to 4 */
    const byte SEGMENT_SELECT[] = {0xF1,0xF2,0xF4,0xF8};
    void setup ()
    {
    /* Set DIO pins to outputs */
    pinMode(LATCH_DIO,OUTPUT);
    pinMode(CLK_DIO,OUTPUT);
    pinMode(DATA_DIO,OUTPUT);
    }
    /* Main program */
    void loop()
    {
    /* Update the display with the current counter value */
    WriteNumberToSegment(0 , 0);
    WriteNumberToSegment(1 , 1);
    WriteNumberToSegment(2 , 2);
    WriteNumberToSegment(3 , 3);
    }
    /* Write a decimal number between 0 and 9 to one of the 4 digits of the display */
    void WriteNumberToSegment(byte Segment, byte Value)
    {
    digitalWrite(LATCH_DIO,LOW);
    shiftOut(DATA_DIO, CLK_DIO, MSBFIRST, SEGMENT_MAP[Value]);
    shiftOut(DATA_DIO, CLK_DIO, MSBFIRST, SEGMENT_SELECT[Segment] );
    digitalWrite(LATCH_DIO,HIGH);
    }

    Read pot and display value on display

    ?
    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
    /* Define shift register pins used for seven segment display */
    #define LATCH_DIO 4
    #define CLK_DIO 7
    #define DATA_DIO 8
    #define Pot1 0
    /* Segment byte maps for numbers 0 to 9 */
    const byte SEGMENT_MAP[] = {0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0X80,0X90};
    /* Byte maps to select digit 1 to 4 */
    const byte SEGMENT_SELECT[] = {0xF1,0xF2,0xF4,0xF8};
    void setup ()
    {
    Serial.begin(9600);
    /* Set DIO pins to outputs */
    pinMode(LATCH_DIO,OUTPUT);
    pinMode(CLK_DIO,OUTPUT);
    pinMode(DATA_DIO,OUTPUT);
    }
    /* Main program */
    void loop()
    {
    int PotValue;
    PotValue = analogRead(Pot1);
    Serial.print(“Potentiometer: “);
    Serial.println(PotValue);
    /* Update the display with the current counter value */
    WriteNumberToSegment(0 , PotValue / 1000);
    WriteNumberToSegment(1 , (PotValue / 100) % 10);
    WriteNumberToSegment(2 , (PotValue / 10) % 10);
    WriteNumberToSegment(3 , PotValue % 10);
    }
    /* Write a decimal number between 0 and 9 to one of the 4 digits of the display */
    void WriteNumberToSegment(byte Segment, byte Value)
    {
    digitalWrite(LATCH_DIO,LOW);
    shiftOut(DATA_DIO, CLK_DIO, MSBFIRST, SEGMENT_MAP[Value]);
    shiftOut(DATA_DIO, CLK_DIO, MSBFIRST, SEGMENT_SELECT[Segment] );
    digitalWrite(LATCH_DIO,HIGH);
    }
    When i tried this program i noticed that the most significant digit looks more bright than others !

    Schematic diagram

    On http://www.baaqii.com/promanage/manual/A1010.zip i found a zip file with a schematic diagram and about 28 lessons / experiments (in Chinese!).
    In the schematic diagram

    you can see the jumpers:

    J1 is used for a 10 k pull up resistor to pin 2 of U5  (to connect a DS1820 temperature sensor [not included with the shield]) (Arduino Pin A4 ?)  {Location C4 in the picture} 

    J2 is needed if you want to use the switches S1 S2 and S3 (connected to A1 A2 and A3 of the Arduino. {Location C1 in picture}

    A SFH506-38 IR receiver (Pin D2) {Location C3 in picture} is also not included with this shield and can be connected to U4

    I expect the 7 pin header {Location B/C1 in picture} with the Chinese characters is the header 7 pin header marked on the shield with "APC220 Bluetooth Voice Recognition Module". (Pin D0 and D1 ?)

    Pin D5 D6 D9 and A5 are accessible by 4 3 pin header connectors next to +5V and GND

    D3 is connected to the Buzzer using a transistor! {Location D3 in picture}

     The 4 * 7segement displays are connected using two MC74HC595AD shift registers
    D4 7segment Latch
    D7 7segment CLK
    D8 7segment Data

    D10 Led4 {Location A2 in picture}
    D11 Led3
    D12 Led2
    D13 Led1

    A0 Pot1 (potentiometer) {Location B/C1 in picture}

    A1 Button1 {Location C/D1 in picture}
    A2 Button2
    A3 Button3

    IMPORTANT ADDITIONAL INFO (Oct 2019)

    October 2019 i was contacted by Kashif Baig. The link to his document was changed
     to https://files.cohesivecomputing.co.uk/Hackatronics-Arduino-Multi-function-Shield.pdf

    Other references

    Some other info on the internet about this shield:

    https://www.mpja.com/download/hackatronics-arduino-multi-function-shield.pdf
    Document with several examples using a nice library

    http://www.cohesivecomputing.co.uk/hackatronics/arduino-multi-function-shield/
    Tutorial with  real world examples (Metronome bonus can be found on Youtube)
    (I tried the Metronome, it worked. The sound was not as loud as i expected from the Youtube movie.)