fotografeer.nl

fotografeer.nl

  • Overzicht
  • Fotografeer tips
  • Blog
  • Albums
  • Categorieën
  • Sets
  • Aanvraag
Share
2022/12/31

Programming ATtiny85 from Arduino Nano - The Test

Now that the adapted Blink.ino is on the ATtiny85, we need to verify if it works in a target environment. Power down your programmer and remove the ATtiny85. As an emulated target environment, you can use either of the test designs. Place the ATtiny85 in your target environment and provide power to the setup.

The video shows both test setups, each with a ATtiny85.

Assuming you followed along with this series of blog posts and reached this point. Congratulations! You now have a working programmer based on a Nano, burned the bootloader, ported a sketch, successfully installed the sketch and tested it on an ATtiny85.

Read more in Blog

arduino attiny85 nano

Share
2022/12/31

Programming ATtiny85 from Arduino Nano - The Upload

In the previous post in this series, we went through the porting process and adapted Blink.ino to be able to run on ATtiny85. In this post, the apdated Blink.ino is uploaded to the ATtiny85.

DISCLAIMER

THIS BLOG POST IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THIS HOWTO OR SOFTWARE OR THE USE OR OTHER DEALINGS IN THIS BLOG POST.

Upload

Now we have prepared the Blink.ino sketch for ATtiny85, it is time to upload it to the ATtiny85 chip.

Open Arduino GUI

If you don't have the Arduino GUI open any more, start it first.

Open New Sketch

Open a new sketch. Select:

File -> New Sketch

Use Adapted Blink.ino

Copy/Paste the adapted Blink.ino that uses pin 3 in the new sketch. There is no need to save it.

#define LED_PIN 3
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_PIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_PIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_PIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

Verify Settings

Make sure you have the same settings that you used for burning the bootloader.

Upload Using Programmer

Instead of using the normal Upload button, you now have to select:

Sketch -> Upload Using Programmer

The output window of the Arduino IDE will show you details of the compilation and upload process and if all goes well, ends with:

avrdude: erasing chip
avrdude: reading input file "C:\Users\xxxxxxxx\AppData\Local\Temp\arduino-sketch-50B9D151E34A20A45A3B89D655F813D5/sketch_dec31a.ino.hex"
avrdude: writing flash (682 bytes):
Writing | ################################################## | 100% 1.02s
avrdude: 682 bytes of flash written
avrdude done.  Thank you.

The adapted Blink.ino is now uploaded onto the ATtiny85. In the next post it is put to the test.

Read more in Blog

arduino attiny85 nano

Share
2022/12/29

Programming ATtiny85 from Arduino Nano - The Porting Process

In the previous post in this series, we prepared the ATtiny85 by installing the bootloader. Existing sketches require some work to adjust them for use on ATtiny85. In ICT it is common practice to adapt applications written for a certain platform, so they can run on another platform. Often you will see an application with versions for Linux, Microsoft Windows and Apple macOS. The process of making an application suitable for a different platform is called porting. On a smaller level, Arduino sketches, created on e.g. Uno might not automatically run on an ATtiny85. You also need to apply a porting process and create a sketch version suitable for the ATtiny platform.

DISCLAIMER

THIS BLOG POST IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THIS HOWTO OR SOFTWARE OR THE USE OR OTHER DEALINGS IN THIS BLOG POST.

Differences

Size

There are some obvious differences between the commonly used Arduino boards and the ATtiny85. The first thing to notice is the size difference. This affects many features, e.g.:

  • Memory
  • Pins
  • UART
  • Libraries

Memory

The memory of the ATtiny85 is smaller compared to other boards. This means that large sketches might not fit. Compilation will halt if you exceed the available space. Minimize the amount of source code used to achieve your goal.

Pins

With 8 pins, the ATtiny85 has a lot less connection points. This limits the amount of pins you can address in your sketch.

UART

Arduino boards have at least one serial port and often use pin 0 and 1 for serial communication. UART is not available on ATtiny chips. Instead of Serial you have to use SoftwareSerial, which comes with its own limitations. This makes it difficult to monitor what is going on inside the program at runtime. You could print debug messages with SoftwareSerial to dedicated RX/TX pins. And then use a separte Uno board, connected to these pins to read the messages and display them via Arduino GUI's serial monitor. But that means having to sacrifice 2 pins of ATtiny for monitoring.

Libraries

For connected sensors on output devices, you may need a dedicated ATtiny version of the library. E.g. for LCD screens, you can use LiquidCrystal_I2C on Arduino boards. This won't run on ATtiny chips. You need an alternative. e.g. the TinyLiquidCrystal_I2C library.

Examples

Pin Example

Commonly you need to assign different pin numbers for the ATtiny platform.

The LED_BULLETIN pin (13) used in Blink.ino is not available on ATtiny85. Obviously it only has 8 physical pins, so pin 13 doesn't exist. And there are no on-board LEDs either. If you want to use Blink.ino on an ATtiny85, you need to adapt the pin numbers to address an external LED on an existing pin. To make it more complicated, the pin numbers you address in your sketch are mapped pin numbers that are different from the physical pin numbers. In the ATtiny85 datasheet you can find the pinout and the mapped numbers.

You can address pins from group PB in your sketch. In this example, the mapped pin 3 (PB3) is used in the sketch. An updated Blink.ino might look like this:

#define LED_PIN 3
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 3 as an output.
  pinMode(LED_PIN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_PIN, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_PIN, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}
We will use this code in the next post and upload it to the ATtiny85.
The wire to the LED needs to be connected to the physical pin 2.

LCD and Sensor Example

If you want to connect a DHT11 temperature and humidity sensor and a LCD screen to an ATtiny85, you need to use libraries suited for the ATtiny platform. Instead of using the libraries LiquidCrystal_I2C and DHT, you now need to include ATtiny versions:

#include <TinyLiquidCrystal_I2C.h>
#include "TinyDHT.h"
DHT dht(DHTPIN, DHTTYPE);
TinyLiquidCrystal_I2C lcd = TinyLiquidCrystal_I2C(0x27,16,2);

Not all functions may be available in the tiny versions of the libraries. E.g. TinyDHT doesn´t have the computeHeatIndex function.

Read more in Blog

arduino attiny85 nano

Share
2022/12/29

Programming ATtiny85 from Arduino Nano - The Bootloader

In the previous blog post in this series, we installed the programmer software on the Nano and placed the last components to be able to program an ATtiny85 chip. New ATtiny85 chips need to be prepared to take Arduino sketches by burning a bootloader. In this post, we go through the steps of configuring the Arduino IDE for programming ATtiny85 and burning the bootloader to ATtiny85.

DISCLAIMER

THIS BLOG POST IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THIS HOWTO OR SOFTWARE OR THE USE OR OTHER DEALINGS IN THIS BLOG POST.

Step-by-step Guide

Verify ATtiny85 Placement

Verify the ATtiny85 is installed, according to the design, with pin 1 top right. Check for the notch and the dot at pin 1.

TODO Put macro image here

Connect Nano and Start Arduino GUI

Connect the Nano via USB to your computer for the Arduino GUI to be able to find its COM port. Note the slowly pulsing green LED to indicate the programmer software ArduinoISP.ino is running.

Configure for ATtiny85

We need to set the appropriate settings in the Arduino GUI for programming the ATtiny85. For the purpose of these blog posts, we will leave most settings on their default value.

Select the ATtiny85 Board

Tools -> Board -> ATtiny Microcontrollers -> ATtiny25/45/85

Note that the Tools menu now has additional items, related to the ATtiny:

  • Clock
  • Processor

Port

First select the correct COM port.

Tools -> Port -> COM<x>

Verify Board Selection

Make sure you have the correct board selected. It should show ATtiny25/45/85.

Tools -> Get Board Info

BN: ATtiny25/45/85
VID: N/A
PID: N/A

Select OK to close the popup window.

Clock

Tools -> Clock -> Internal 8 MHz

Processor

Tools -> Processor -> ATtiny85

Programmer

Select the programmer for ISP you want to use. You may still have this selected from when it was set in the last blog post.

Tools - Programmer -> Arduino as ISP

Burn the Bootloader

Note that you only have to burn the bootloader once on a newly arrived chip. You have prepared the configuration and can now burn the bootloader.

Tools -> Burn Bootloader

The output window shows the technical details of erasing the chip, installing the bootloader and the verification.

avrdude: Version 6.3-20201216
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch
... detailed info  ...
avrdude: Device signature = 0x1e930b (probably t85)
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
avrdude done.  Thank you.

ATtiny85 Prepared

The ATtiny85 is now prepared with the bootloader and is ready to receive sketches. Sketches that work on e.g. Uno, will not automatically work on ATtiny85. They need to be adapted in a process called porting. More on that in the next blog post.

Read more in Blog

arduino attiny85 nano

Share
2022/12/26

Programming ATtiny85 from Arduino Nano - The Programmer

In the previous blog post in this series, we created the prototype from the design, up to the point were the programmer can be installed. In this post, we go through the process of installing the programmer on Nano.

DISCLAIMER

THIS BLOG POST IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THIS HOWTO OR SOFTWARE OR THE USE OR OTHER DEALINGS IN THIS BLOG POST.

Step-by-step Guide

Connect Nano

Connect the Nano via USB to your computer. Expect the power LED on the Nano to switch on. This LED can be identified by looking for POW or PWR next to the LED.

Here the Nano has Blink.ino loaded. Note the permanently burning POW LED and blinking bulletin LED.

Open IDE

Open the Arduino IDE. This version was used to create this step-by-step guide:

Version: 2.0.3
Date: 2022-12-05T09:30:25.331Z
CLI Version: 0.29.0 [76251df9]

Open Example ArduinoISP.ino

The programmer that comes as part of the Arduino IDE examples. We will upload it to Nano in a later step. To open it, select
File -> Examples -> 11. ArduinoISP -> ArduinoISP

Set Verbose Output

If you want to get a better understanding of the compile and upload processes, make sure you have enabled verbose output during compile and upload.

File -> Preferences -> Show verbose output during compile upload

Check the boxes for both compile and upload. Then select OK.

Set Nano Details

Before we can upload the programmer to the Nano, make sure you have selected the correct port, board and processor. Select

Tools -> Board "<current board>" -> Arduino AVR boards -> Arduino Nano

Tools- > Port "<current port>" -> COM<x>

The Nano used here requires the processor "ATmega328P (Old Bootloader)".

Select the appropriate processor for your Nano. E.g.:

Tools -> Processor -> ATmega328P (Old Bootloader)

Use the "Arduino as ISP" for the programmer option. Although it doesn't affect the programmer upload to Nano in this stage, we will need that later when programming the ATtiny85.

Tools -> Programmer: "<current programmer>" -> Arduino as ISP

Wrong Processor Error Messages

When the processor was on the wrong setting ("ATmega328P") for the Nano that was used, the upload failed after several attempts with these kind of messages:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xa1
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xa1
Failed uploading: uploading error: exit status 1

Upload Programmer to Nano

Now that you prepared all the settings, you can go ahead and compile and upload the ArduinoISP.ino to the Nano.

Select the upload button button and wait for the upload process to finish.

You have now loaded the programmer software onto the Nano. You should see the green LED slowly pulsing as the "heartbeat", indicating ArduinoISP.ino is running.

Disconnect Nano

Disconnect Nano from USB and make sure it is powered down.

Place ATtiny85 and Capacitors

With Nano powered down, install the last components to finish the design.

Place the 10 kF capacitor over RST and GND of the Nano. Place the positive pin of the capacitor in A14 (just below Nano's RST pin) and the negative pin in A15 (just below Nano's GND pin). I guess this will allow the Nano to be recognized as the programmer by the IDE when uploading to the ATtiny85.

To reduce interference, place a 104 capacitor (100,000 pF = 100 nF = 0,1 µF) over ATtiny85's pin 8 VCC (E24, via the red jumper wire) and pin 4 GND (G27). The red wire is used to have the 104 capacitor far enough out of the way to be able to let it sit in the breadboard while inserting and removing the ATtiny85 chips.

Place the ATtiny85 chip. Look for pin 1. Follow the design where pin 1 is placed top right in F30.

Ready to Upload to ATtiny85

Your programmer should now be ready for use and can be reconnected. Verify that all three LEDs blink shortly at startup. Then look for the green LED slowly pulsing as the "heartbeat", indicating ArduinoISP.ino is running.

In the next blog post we see how to burn the bootloader to the ATtiny85.

Read more in Blog

arduino attiny85 nano

Share
2022/12/22

Programming ATtiny85 from Arduino Nano - The Prototype

In the previous post in this series, the design was created based on prerequisites and requirements. Now we want to turn the design into a prototype on your breadboard that you can really use. To recreate the design follow the step-by-step guide. Each step depicts the added item in the design.

DISCLAIMER

THIS BLOG POST IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THIS HOWTO OR SOFTWARE OR THE USE OR OTHER DEALINGS IN THIS BLOG POST.

Detailed steps

Follow this step-by-step guide to setup your programmer on the Arduino Nano in line with the design.

Components

1x Arduino Nano (compatible)
1x ATtiny85 chip
1x 400 points Breadboard (half+)
1x Green LED
1x Yellow LED
1x Red LED
3x 1 kΩ resistor
1x 10 µF 25V condensator
1x 100 nF ceramic condensator (104) (= 0,1 µF)
Breadboard wires: orange, yellow, red, green
Mini jump wires, created from solid core wire: red, black
Dupont male-female wires: red, black, brown, white, blue

Breadboard

Take the breadboard and orientate it with A1 tie-point in the lower left corner.

Install Nano

Place the Nano on the breadboard, with pin D13 in breadboard tie-point B2. This allows the complete footprint of the Nano to stay inside the breadboard edges and leaves room above to place the wires, LEDs and resitors.

LEDs

Place the green LED positive pin in I19 and negative pin in I18.

Place the yellow LED positive pin in I22 and negative pin in I21.

Place the red LED positive pin in I25 and negative pin in I24.

Resitors

Place a 1 kΩ resistor with one end in j18 and the other in the negative strip of the power lane.

Place a 1 kΩ resistor with one end in j21 and the other in the negative strip of the power lane.

Place a 1 kΩ resistor with one end in j24 and the other in the negative strip of the power lane.

Breadboard Wires

Note: positions slightly differ from tie-points on the design, but are still in the same vertical strip.
In the design wires would be on top of each other, making the design hard to understand

Place the orange wire in H4 (just above Nano pin D10) and in J30.
(in same vertical strip as pin 1 of ATtiny85 on F30)

Place the green wire in H5 (just above Nano pin D9) and in H19.

Place the red wire in H6 (just above Nano pin D8) and in H25.

Place the yellow wire in H7 (just above Nano pin D7) and in H22.

Dupont Wires

Remember the ICSP header orientation from previous posts and the location of the pins:

      6 5
 GND  . .  RST
MOSI  . .  SCK
 VTG  . .  MISO
      2 1

Place red wire on VTG of ICSP header and connect to A30.
(A30 is in the same vertical strip as pin 8 of ATtiny85 on E30)

Place white wire on SCK of ICSP header and connect to A29.
(A29 is in the same vertical strip as pin 7 of ATtiny85 on E29)

Place blue wire on MISO of the ICSP header and connect to A28.

Place brown wire on MOSI of the ICSP header and connect to A27.

Place black wire on GND of the ICSP header and connect to the negative strip of the power lane.

Small Jumper Wires

Place a small red jumper wire from B30 to D24.
(Needed later on to place a capacitor over 5V and GND of the ATtiny85)

Place a small black jumper wire from J27 to the negative strip of the power lane.
(J27 is in the same vertical strip as pin 4 GND of ATtiny85 on F27)

After Installing Programmer

At this point, the prototype is ready for installing the programmer ArduinoISP.ino on Nano.

More on that in the next post. Note that the last three steps, placing the ATtiny85 and 2 capcitors, to complete the design, can only be done after the programmer is installed.

Read more in Blog

arduino attiny85 nano

Share
2022/12/20

Programming ATtiny85 from Arduino Nano - The Design

In the previous blog post, we did the research on all the prerequistes and requirements for uploading sketches via the programmer Arduino Nano to the target ATtiny85. Now it is time to apply the findings and turn them into a breadboard design.

Note that my electronics knowledge is limited. Please post any doubts, concerns or remarks on our social media page.

DISCLAIMER

THIS BLOG POST IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THIS HOWTO OR SOFTWARE OR THE USE OR OTHER DEALINGS IN THIS BLOG POST.

Design

All the research led to this design for the programmer.

Image created with Fritzing
Image created with Fritzing

This design features the use of the ICSP header and LED indicators as described in ArduinoISP.ino.

// Put an LED (with resistor) on the following pins:
// 9: Heartbeat   - shows the programmer is running
// 8: Error       - Lights up if something goes wrong (use red if that makes sense)
// 7: Programming - In communication with the target

Schema

Image created with Fritzing

Test boards

The design leaves little room for blink test leds on the programmer breadboard. And we are trying to implement the separation of concerns principles and want to keep the programmer and the test setup separate.
To be able to verify the correct upload of Blink.ino onto the ATtiny85, one of these test boards must be prepared, according to this design.

In the next blog post in this series, we will turn the design into a prototype.

Sidenote

You might argue, why not also use the RST of the ICSP header? At least, I did. Then all connections towards the ATtiny85 would be on the ICSP header.

This is most likely by design and set in ArduinoISP.ino, where it states: "Pin 10 is used to reset the target microcontroller." It is clearly the intention that this should be used. The pin number for RESET is specifically set:
#define RESET 10  // Use pin 10 to reset the target rather than SS

I actually tried to use the RST on the ICSP header, but then burning the bootloader fails with these messages:

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.
Failed chip erase: uploading error: exit status 1

Cleary not the way to go. This is probably also what you see when any of the other connections are not setup properly.

I'm assuming the RST on the ICSP header is connected through with the other RST pins. At least that is what Fritzing shows me when I click and hold the RST pin on the ICSP header. All RST pins turn yellow, indicating that they are somehow connected. I'm guessing these can't be used, because there is a capacitor over RST and GND, to allow the Nano to act as the programmer.

Image created with Fritzing

With pin 10 of Nano connected to pin 1 (RESET) on ATtiny85, the bootloader burn ends with this success message:

avrdude: verifying ...
avrdude: 2 bytes of flash verified
avrdude done.  Thank you.

More on the bootloader and upload process later in this series.

Read more in Blog

arduino attiny85 nano

Share
2022/12/19

Programming ATtiny85 from Arduino Nano - The Challenge

Introduction

In December 2022, this blog's author was given a challenge to implement a way to upload sketches to ATtiny85. There are many examples that use the Uno to program the ATtiny85.

As a self-imposed challenge an Arduino Nano would need to be used as the programmer. Being relatively new to the Arduino world at that time, research was started to find out the prerequisites to achieve this. This blog post is the first of a series, describing the process.

DISCLAIMER

THIS BLOG POST IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THIS HOWTO OR SOFTWARE OR THE USE OR OTHER DEALINGS IN THIS BLOG POST.

Research

Searching the Internet several videos and pages were found regarding this topic. Here are some that might peek your interest.

References

  1. Arduino as ISP and Arduino Bootloaders
  2. How-To: Shrinkify Your Arduino Projects
  3. Matching Article: How-To: Shrinkify Your Arduino Projects
  4. How to Program an Attiny85 From an Arduino Uno
  5. Program ATtiny85 with Arduino Nano
  6. Programming ATtiny85/84 with Arduino Uno (ATTinyCore)
  7. Program the ATTINY85 with Arduino 1.8.18 (2022)

ICSP

In on of the references, the ICSP header is used, rather than the pins D11, D12 and D13 as seen in most examples. Because of the header name, this also seems to have been the intented use for an Arduino board as a programmer. Looking at the ISP example 'ArduinoISP.ino' in the Arduino IDE below File -> Examples -> 11. ArduinoISP -> ArduinoISP, the comment reads:

// By default, the hardware SPI pins MISO, MOSI and SCK are used to communicate
// with the target. On all Arduinos, these pins can be found
// on the ICSP/SPI header:
//
//               MISO °. . 5V (!) Avoid this pin on Due, Zero...
//               SCK   . . MOSI
//                     . . GND

This is confirmed on e.g. https://arduino.stackexchange.com/a/30027, where it states: "The standard connection for the ISP is a 100 mil 6-pin header (2x3)." The image from this answer shows the pin assignment for the ICSP header of the Uno:

      1 2
MISO  . .  VTG
 SCK  . .  MOSI
 RST  . .  GND
      5 6
ICSP headers on Arduino UnoImage created with Fritzing

With both Uno and Nano rotated with the USB port pointing to the left you may notice that pin 1 is at the botom for the Nano, not at the top as with the Uno. If you look at it from that orientation, this is the pin assignment for the ICSP header of the Nano:

      6 5
 GND  . .  RST
MOSI  . .  SCK
 VTG  . .  MISO
      2 1
ICSP headers on Arduino NanoImage created with Fritzing

This confused me a bit at first, but it's the exact same header. It just depends on the board's orientation where to find the correct pin numbers.

Lesson learned: Make sure to locate pin 1, before connecting cables.
Look for a small dot or a small 1.

TODO add macro photo's from Uno and Nano pin 1 indication

The key pins for ICSP seem to be MISO, MOSI and SCK. After locating them on the Nano ICSP header, the matching pins on the ATtiny85 also need to be located. As suggested in the references, look for the chip's datasheet and find the section that describes the pins.

Now the needed data to connect the wires is available for both the programmer (Nano) and the peripheral (ATtiny85). From that we can deduct what to connect where and assign some colors for the wires.

Nano ICSP Header      ATtiny85               wire color
Pin 1 MISO            Pin 6 PB1 (MISO)       Blue
Pin 2 +5V             Pin 8 VCC              Red
Pin 3 SCK             Pin 7 PB1 (SCK)        White
Pin 4 MOSI            Pin 6 PB0 (MOSI)       Brown
Pin 6 GND             Pin 4 GND              Black
Nano standard pin                          
Pin D10               Pin 1 PB5 (RESET)      Orange

Indicator LEDs

In ref 1 and in the ArduinoISP example, there is a comment on using LEDs (with resistor), to indicate the status of the programmer.

// Put an LED (with resistor) on the following pins:
// 9: Heartbeat   - Shows the programmer is running
// 8: Error       - Lights up if something goes wrong (use red if that makes sense)
// 7: Programming - In communication with the slave

This was added to the challenge aswell. This led to a design for Arduino Nano to be used as a programmer for ATtiny85 via the ICSP header with indicator LEDs.

The next blog post will feature the design.

Read more in Blog

arduino attiny85 nano

Share
2022/12/09

Compile and Upload .ino file to Aruduino board via arduino-cli

This blog post describes how you can use a Windows 10 batch file to compile and upload Arduino .ino files to an Arduino board. And it provides background on why it was created in the first place.

Update 2022-12-19: Many of the concerns mentioned in this blog are no longer valid for version 2.0.3 of the Arduino GUI. Just downloaded and installed this version:

Version: 2.0.3
Date: 2022-12-05T09:30:25.331Z
CLI Version: 0.29.0 [76251df9]
Copyright © 2022 Arduino SA
The editor now features line numbers and you can now set font size and dark theme. The need to match directory name and sketch name seems to no longer exist. Need to investigate if the need for this batch file still exists.

The .ino files are compiled and uploaded to Arduino boards, like the Uno. There it can read input from sensors and push buttons and control output devices, like the LED show here.

Example of an electronic prototype with an Uno and breadboard. Image created with Fritzing.

Disclaimer

THIS HOWTO AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THIS HOWTO OR SOFTWARE OR THE USE OR OTHER DEALINGS IN THIS HOWTO OR SOFTWARE.

Features

This section describes the features that the batch file brings.

CMD and PowerShell

Works in both CMD and PowerShell. See the examples section below.

Creating temporary directory

The file location for the .ino file is provided as input on the command line.
D:\Arduino\PROJECTS\0001 My First Project>CompileAndUpload.bat Button.ino
From the file name, it will extract the sketch name and create a temporary directory with this sketch name.

Copying

The original .ino file is copied to the temporary directory.

Locating communication ports

The communication port that the Arduino board is connected to is automatically detected.
With multiple boards, you can choose where to upload.

Compiling

The .ino file in the temporary directory is compiled.

Uploading

If compiling succeeds, the created byte code is uploaded to the Arduino board.

Removing

The temporary directory and all its content is removed.

Limitations and Known Issues

ANSI Color code not handled correctly

After compiling with the arduino-cli, the ANSI color codes are not displayed correctly. Instead of enabling and disabling the color for the terminal text, it shows ←[96m and ←[0m. Example:
This seems to be caused by the arduino-cli, because if I comment that out, the colors are shown correctly. Have not found a real cause or workaround for it.

Only Tested on Arduino Uno and Nano

So far, this batch file has only been tested with Arduino Uno and Nano boards. The Nano upload phase has the 'cpu=atmega328old' option set. Nothing is known on how it behaves with other boards.

Serial Terminals block access to COM ports

If you opened a serial terminal in the Arduino IDE or Fritzing IDE, upload will fail. The serial terminals deny the batch file access to the COM ports. (Toegang geweigerd = Access denied)

COM port entry in command line history

If you used multiple ports and manual enter a choice, the COM port name will be in the command line history and will show up if you use arrow up to go to previous commands.

Examples

File not found

Compile Errors

Successful Compile and Upload

Multiple COM port detection

Prerequisites

Windows 10
Arduino IDE
Arduino CLI
Fritzing IDE

Windows 10

The target system for the batch file is Windows 10 on which it has been tested.

Arduino IDE

An IDE helps you to develop software source code in an organized way in a user-friendly GUI. You need to download and install the Arduino IDE, before you can use the Arduino CLI.

Arduino CLI

The Arduino CLI allows users to type commands to compile and upload the software.

Fritzing IDE

Optionally, you can download and install the Fritzing IDE.

Installation

Before you can use the batch file, you need to prepare the following.

Install Arduino GUI

The newer version 2 of the GUI can be downloaded and installed from the Arduino Software page. Look for the DOWNLOAD OPTION section on the right and select "Win 10 and newer, 64 bits". Follow the download instructions and install the GUI.

Install Arduino CLI

The Arduino CLI 64 bits MSI installation file can be downloaded and executed to install the CLI through a setup wizard.
Follow the instructions to install the CLI.

Download the Batch File

Here is the code for the Windows batch file. Copy/Paste the text into a file called CompileAndUpload.bat on your local computer. Put it in a suitable location. E.g:
Add the location to your enviroment path.
To run it, open a cmd or PowerShell window. After the prompt, type:
CompileAndUpload.bat [ino filename]
Provide the path to the .ino file. E.g.:
CompileAndUpload.bat Button.ino
You can use mapped drives, files and directories with spaces. E.g.:
CompileAndUpload.bat "\\NAS\Arduino\PROJECTS\0001 LED and Button\MultiFunctionButton.ino"

Background Story

A while ago a good friend, who is a model-train enthusiast, asked me to create some software to control LEDs for emulating a running light, a welding light and randomly switching on/off lights in the model houses. The software needed to run on an Arduino Uno board to which these LEDs are connected. This introduced me to Arduino ecosystem.

To start developing the code for the requested functionality, I downloaded the Arduino IDE. It works great and has a Verify and Upload button. And easy to learn how to use. The only quirky thing is that a .ino file must always be in a sketch directory with the same name. E.g.
.\Button\Button.ino
I'd like to use multiple .ino files, without having any restrictions on the directory name. E.g.
\Arduino\PROJECTS\0001 LED and Button\Button.ino
\Arduino\PROJECTS\0001 LED and Button\MultiFunctionButton.ino
\Arduino\PROJECTS\0001 LED and Button\Other Code Here.ino
An alternative might be the Fritzing IDE. This supports multiple .ino files per project. It has an upload button, but there doesn't seem to be a Verify button to only compile the .ino files, like the Arduino GUI has. Therefore Fritzing doesn't seem to have a way to show the compile error messages if you make a mistake in your source code. If you have invalid code, the upload will fail without any error message to indicate what is going wrong.
The only way to work around these issues was to create a batch file that can compile, show the compile error messages and upload when compile succeeds, as described above.

Read more in Blog

arduino

Share
2021/05/24

Diafragma

Het diafragma in een objectief regelt de opening en daarmee de hoeveelheid licht die een camera binnenkomt.

Het lichtgevoelige oppervlak, zoals een lichtgevoelige sensor of film, werkt optimaal wanneer het een afgemeten hoeveelheid licht ontvangt. Lichtmeters in camera's zijn meestal gekalibreerd op 18% middengrijs. Het diafgrama, de sluitertijd en de gevoeligheid bepalen samen de hoeveelheid licht die nodig is voor een optimale belichting.

In het menselijk oog wordt de hoeveelheid licht, die op het netvlies valt, beïnvloedt door de iris die de grootte van de pupil regelt.

Zie: https://commons.wikimedia.org/wiki/File:My_eye.jpg

Vergelijkbaar wordt, in fotografie, de hoeveelheid licht die op het lichtgevoelige oppervlak valt beïnvloedt door de diafragma lamellen die over elkaar heen schuiven en daarmee de grootte van de opening regelen.

De diafragma lamellen worden in oudere objectieven bediend met behulp van de diafragma ring.

In moderne objectieven wordt de apertuur vanaf de camera automatisch of met instelwielen aangepast.

Het diafragmagetal is de openingsverhouding die wordt bepaald uit de brandpuntsafstand ( f ) en de apertuur ( D ):

diafragmagetal = f D

Gebruikelijke diafragmagetallen
Notatie f /1 f /1,4 f /2 f /2,8 f /4 f /5,6
Diafragmagetal 1 1,4 2 2,8 4 5,6
Voorbeeld
f/2
f/2,8
f/4
f/5,6
Notatie f /8 f /11 f /16 f /22 f /32 f /64
Diafragmagetal 8 11 16 22 32 64
Voorbeeld
f/8
f/11
f/16

Het diafragmagetal vind je terug op de diafragma-ring of op het LCD scherm van je camera. Hoe groter het getal, hoe kleiner de opening.

Een objectief's laagst mogelijke diafragmagetal van de grootst mogelijke opening wordt aangeduidt als de lichtsterkte van het objectief. Bovenstaand objectief heeft een lichtsterkte van 2,8.

Aangezien het diafragmagetal is gerelateerd aan de brandpuntsafstand vindt je op zoomobjectieven vaak 2 lichtsterkte aanduidingen. B.v. op een 35-105 mm zoomobjectief staat 1:3.5-4.5. Dit houdt in dat de lichtsterkte 3,5 is bij 35 mm zoomstand en afneemt naar 4,5 bij 105 mm zoomstand.

Zoomobjectieven in een hogere prijscategorie hebben mogelijk over het gehele zoombereik een vaste maximale lichtsterkte van b.v.. 2,8.

Read more in Fotografeer tips

View all essays by month
View all essays by category
  1. 14

    Blog

  2. 13

    Fotografeer tips

  3. 6

    Portret

  4. 6

    Elfia

View all essays by tag
  1. 9

    arduino

  2. 8

    attiny85

  3. 8

    nano

  4. 6

    elfia

  5. 2

    coolscan

Links
  • Fotografeer tips
  • Tips - Introductie
  • Tips - Beelduitsnede
  • Tips - Scherpstellen
  • Tips - Compositie
  • Tips - Perspectief
  • Tips - Objectief categoriën
  • Tips - Objectief eigenschappen
  • Tips - Objectief beeldhoeken
  • Blog
  • Twitter
  • Facebook
1 of 4
  1. 1 2 3 4
  2. >
Tweet
  • Overzicht
  • Fotografeer tips
  • Blog
  • Essays
  • Albums
  • Inhoud
  • Twitter
  • Facebook
© 1979-2023 Peter van Loon - fotografeer.nl | Built with Koken