pondělí 5. září 2016

Batman Detector


Batman Detector

The article is in the state of a working log for now. There are still TODOs and is incomplete.

The aim of the project is to provide a sensor that indicates an obstacle ahead and plays a sound in that case, indicating the proximity of the obstacle.

First, the wiring of the system, using LED D3 instead of speaker. The schema includes the reset function of the SR04 ultrasound sensor.


Without the Q1 transistor, the problem is that some of the ultrasound detectors do not have timeout.
When the sonic signal does not return to it's receiver, the sensor gets stuck and do not send another
echo until the sensor is reset. This has to be detected by the software and handled, via PD6 pin.

Here goes the code and the schematic and board:
https://github.com/pbures/BatmanDetector

TODOS:

  • Create the board and do all the soldering.
  • Put all stuff into a box.

neděle 7. února 2016

Arduino with ESP8266

Arduino with ESP8266 Basic Setup

Shopping list

  • ESP8266 Serial WIFI Wireless Transceiver Module Send Receive LWIP AP+STA arduino
    (Ebay Store)
  • New IIC I2C Logic Level Converter Bi-Directional Module 5V to 3.3V For Arduino
    (Ebay Store)
  • Arduino Mega
    (Ebay Store)

Setup

The ESP communicates via the serial link with Arduino. Connection is easy:

ESP   -- Arduino

RX    -- TX1 via the I2C level converter.
TX    -- RX1 via the I2C level converter.

GND   -- Ground

VCC   -- 3.3V source
CH_PD -- 3.3V source
GPIO0 -- 3.3V source
GPIO1 -- 3.3V source



Note: For TX and RX I used the I2C level converter which is working without any problem. Only confusing thing is that if you measure the voltage via multimeter on the HVx or LVx you always get the HV or LV value, no matter what goes in on the other side.

Programming

For Arduino Mega the situation is easier since we have the Serial1 right away, otherwise the SoftwareSerial needs to be used (not verified). 

The program is very easy:
void setup()
{
    Serial.begin(9600);
    Serial1.begin(115200);
    delay(500);
    Serial.println("Starting");
}
void loop()
{
   
    while (Serial1.available()) {
        Serial.write(Serial1.read());
    }
    while (Serial.available()) {
        Serial1.write(Serial.read());
    }
}
For sending the commands to the ESP module, configure the Arduino IDE so that CR and LF is sent, you choose that at the bottom right corner of the serial monitor window.

Note: Be aware that the ESP module may have different baudrate on the serial connection that is expected. For the the 115200 baudrate for the ESP serial worked.

External Sources

DC 5V Stepper Motor

DC 5V Stepper Motor

Shopping list

All excited to go for robotics I have purchased the:

"DC 5V Stepper Motor + ULN2003 Driver Test Module Board 28BYJ-48 for Arduino" from ebay store.

Setup

The connection was pretty simple, but be careful to power the motor from different source than via the Arduino 5V output. There is a combination of solenoinds controlled by the IN1, ..., IN4 pins on the driver.

Set the jumber as is on the photo to enable the stepper control.


Then all the magic is to program the set high or low values on the IN1...IN4 pins of the controller. I have written a small program for controlling the motor, source code to be provided.

Experimentally I discovered that the change in the solenoids configuration should not take faster than each milisecond. Using smaller time intervals, the motor stops rotating.

External sources:




neděle 31. ledna 2016

Programming Attiny85 using Arduino Nano

Programming Attiny85 via Arduino Nano


I decided to program Attiny85 using Arduino Nano.

I used the following resources:

http://forum.arduino.cc/index.php?topic=299759.15
http://www.hwkitchen.com/news/a16-nas-prvni-klon-arduina/

The the two things had to be done:

Get the Attiny boards definitons to your Arduino IDE

After some searching there are few Arduino cores available.

Just put the json definition into the 'Additional Boards Manager URLs' when you open Files->Preferences. This adds a menu item into the Boards Manager, where the cores and definitions can be downloaded.


Program the Arduino Nano as ISP programmer and connect to the Attiny85 pins.

To allow some more information you may connect Arduino pins  9,8,7 to a LEDs via 220R resistor so the Arduino ISP can report Heartbeat, Error, and Communication status.

In the Arduino ISP Sketch from examples, I uncomment the  macro USE_OLD_STYLE_WIRING so that the pins for programming are:

PIN_RESET   10  (connect to Attiny Pin 1 (where the small circle is))
PIN_MOSI 11 (connect to Attiny Pin 5 (opposite corner to pin 1))
PIN_MISO 12 (connect to Attiny Pin 6)
PIN_SCK 13 (connect to Attiny 7)

Also connect the 5V of Arduino to Attiny Pin 8 and Arduino GND to Attiny Pin 4.
Basically only pins 2 and 3 or the Attiny are not connected.

Here is a photo with breadboard. There is another project on the board, focus only on the Atiny85 chip.



Upload the ISP Sketch to Arduino Nano

With the Arduino Nano with the IPS programmer sketch open, just select from Boards: Arduino Nano and upload the sketch to Arduino. After the upload you should see the Heartbeat LED slowly blinking.

Upload the Attiny85 Sketch

In other window of Arduino IDE you may upload the Attiny85 program. For testing choose the Blink sketch from the basic examples. Modify the PIN to blink to PIN 3.

Connect the Attiny pin 2 (numbered by hardware layout, this is referred as PIN3 in the program) another LED and 220R resistor to see if the chip is programmed well.

In the IDE select Board: "Attiny", Processor: "Attiny85", Clock: "1Mhz Internal" , and as a programmer select "Arduino as ISP". Upload the sketch.

If all was done right, the LED connected to Attiny85 hw pin 2 should blink with 1s period.


Ebay programmer board

I have all excited also bought so called:
"1PCS Development Programmer Board for ATtiny13A/ATtiny25/ATtiny45/ATtiny85" from ebay store.

It took me some time to realize that this is no programmer at all, it's just a breakout board so you don't need the breadboard and there is the ICSP pin laout. Do not waste time and money on this item.

Next Steps

Low power

Make the Attiny85 run for years on low power mode:
http://www.technoblogy.com/show?KX0

https://learn.sparkfun.com/tutorials/h2ohno/low-power-attiny

This chip will either control the RF433 and Humidity sensors directly, or will control the power to those chips.

RF433 transmission

I want to use the VirtualWire library as this is also on the receiver.