fotografeer.nl

fotografeer.nl

  • Overzicht
  • Fotografeer tips
  • Blog
  • Albums
  • Categorieën
  • Sets
  • Aanvraag
Home / Categories / Blog / Essays

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 one 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
2018/12/26

WordPress in Docker on ReadyNAS OS VM

Abstract

This blog post describes how to setup a virtualized ReadyNAS OS. Docker is then installed and configured to run Wordpress and MySQL in this environment.

Disclaimers

THIS HOWTO 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 THE USE OR OTHER DEALINGS IN THIS HOWTO.

Netgear states: "Access by SSH is not discouraged, but is recommended for advanced users only. As such, using SSH is at the user's own risk."

This is how it worked in the situation of the baseline described below. Use it at your own risk.

Prerequisites

  • PC with Windows 7 SP1 with VirtualBox installed
  • Terminal emulation software
Prior Knowledge
  • ReadyNAS OS 6
  • WordPress installation procedure
  • Debian Linux command line syntax

Baseline

Even-though several combinations of items with other versions may be able to utilize this setup, this has only been tested on the baseline mentioned here:

  • Windows 7 SP1
  • VirtualBox 5.2.22 r126460 (Qt5.6.2)
  • VMDK disk image ReadyNASOS-6.6.0-x86_64.vmdk
  • WordPress 5.0.2
  • Putty 0.63

Please note that VirtualBox 6.0 is recently released.

References

This how-to builds on great work by others. Many thanks! See the links to their respective pages.

https://en.wikipedia.org/wiki/PuTTY
https://www.virtualbox.org/
https://www.virtualbox.org/wiki/Downloads
https://www.virtualbox.org/manual/ch03.html#installation_windows
https://gilsmethod.com/how-to-edit-the-default-virtual-machine-directories-in-virtualbox
https://github.com/ReadyNAS/sdk/wiki/Setup-ReadyNAS-OS-on-VirtualBox
https://www.docker.com/why-docker
https://hub.docker.com/_/wordpress/
https://docs.docker.com/compose/wordpress/
http://powareverb.github.io/Docker-on-ReadyNAS-OS6/

Background

After spending a lot of time of setting up 2 physical ReadyNAS machines to run this website, I'm reluctant to make changes to any settings, as it can potential break current functionality. Having a VM of the ReadyNAS OS is a great alternative to be able to experiment with new settings.

Since Koken CMS seems no longer being developed further, an alternative CMS is needed. Wordpress seems to be the obvious choice here.

With some hacking, Wordpress can be installed on the native ReadyNAS OS. While doing that, some issues popped up. E.g. getting the Wordpress .htaccess (mod_rewrite) to work proved difficult. And the versions of MySQL and PHP used in ReadyNAS OS are never the latest versions, since Netgear needs to deliver a stable OS for all it's customers, I guess. Latest versions of WordPress plugins may have requirements on MySQL that cannot be met.

WordPress runs on 3 main components:

  • Server-side scripting language: PHP
  • Web server: Apache (NGINX)
  • Database: MySQL (MariaDB)

Using Docker containers allows for a free choice of make and version for these 3 components without having to make changes to the ReadyNAS OS.

Below you can find the steps to come to a setup of Wordpress in Docker on ReadyNAS OS VM. Three product are used to enable this setup:

  • VMM: Virtual Box (to run ReadyNAS OS in a virtual machine on Windows)
  • Containerization: Docker (to run WordPress inside containers on the virtualized ReadyNAS OS)
  • CMS: WordPress (to create and manage your website)

VirtualBox

A Hypervisor (VMM) is needed to run the ReadyNAS OS Virtual Machine. First download VirtualBox. Then follow the installation instructions.

Set your default location to a disk with ample available space, so the VM for ReadyNAS OS that we are about to create can grow in size.

Now setup the ReadyNAS OS on VirtualBox.

There are several ways to setup the network connections for the virtual machine. Here we use NAT. Make sure to configure some NAT port translation to be able to connect to the VM from your Windows applications. In the VirtualBox Manager, select Network -> Adapter 1 -> Port forwarding.
Use the + button on the right to add rules for:

  • SSH 22 -> 22
  • HTTP 80 -> 80
  • HTTPS 433 -> 433
  • MySQL 3306 -> 3306
  • WordPress (on Docker) 8000 -> 8000
  • ReadyNAS OS configuration

    Browse to http://localhost/ to access the ReadyNAS Admin Page.

    Authenticate with default ReadyNAS Admin username and password:
    admin
    password

    Follow the instructions on screen as if you were setting up a physical ReadyNAS. Note the provided Hostname nas-XX-XX-XX. You might need it later on. Part of the procedure is to change your default admin password.

    Authenticate again with the admin username and (new) password.

    A pop-up window will alert you of the availability of new firmware. Upgrade to the new firmware version. When the progress bar almost reaches the far right, normally it would auto-refresh once the installation is complete. I needed to refresh the browser to see the admin page again.

    Go to "Settings" and enable "SSH".

    Docker

    Got to "Apps" -> "Available Apps".

    Click the Install button below the Docker CLI logo. Wait for the installation to finish.The Docker CLI will show up in the "Installed Apps" with the switch set to on.

    Now switch to your terminal emulator on Windows and login as root to localhost:22. In the terminal window, find the docker version and run the hello-world container to verify correct installation.You should see the text "Hello from Docker!" as part of the output.

    # docker -v
    Docker version 18.06.1-ce, build e68fc7a
    # docker run hello-world
    Unable to find image 'hello-world:latest' locally
    latest: Pulling from library/hello-world
    d1725b59e92d: Pull complete
    Digest: sha256:b3a26e22bf55e4a5232b391281fc1673f18462b75cdc76aa103e6d3a2bce5e77
    Status: Downloaded newer image for hello-world:latest
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    Share images, automate workflows, and more with a free Docker ID:
     https://hub.docker.com/
    For more examples and ideas, visit:
     https://docs.docker.com/get-started/
    

    Wordpress

    First create a location where your Docker project for Wordpress can live. In the ReadyNAS Admin page, go to the Shares tab.

    Click the "New share" button in the top right corner to create a new share called e.g. "Projects". In the terminal emulator, create the project.

    # cd /data/Projects/
    # mkdir my_wordpress_project

    The latest version of Compose can be found on https://github.com/docker/compose/releases. E.g. 1.23.2. Use this version number in the URL of the curl command. Install and test the Docker Composer.

    # curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
    # chmod +x /usr/local/bin/docker-compose
    # docker-compose --version
    docker-compose version 1.23.1, build b02f1306

    Next, go to the new project folder in the "Projects" share and follow the instructions below (based on the "Quickstart: Compose and WordPress" page) to create a YAML file that can be use by Docker Compose to retrieve and start the needed containers.

    # cd my_wordpress_project/
    # vi docker-compose.yml
    version: '3.3'
    services:
       db:
         image: mysql:5.7
         volumes:
           - db_data:/var/lib/mysql
         restart: always
         environment:
           MYSQL_ROOT_PASSWORD: somewordpress
           MYSQL_DATABASE: wordpress
           MYSQL_USER: wordpress
           MYSQL_PASSWORD: wordpress
       wordpress:
         depends_on:
           - db
         image: wordpress:latest
         ports:
           - "8000:80"
         restart: always
         environment:
           WORDPRESS_DB_HOST: db:3306
           WORDPRESS_DB_USER: wordpress
           WORDPRESS_DB_PASSWORD: wordpress
    volumes:
        db_data: {}
    # docker-compose up -d
    Creating network "my_first_project_default" with the default driver
    Creating volume "my_first_project_db_data" with default driver
    Pulling db (mysql:5.7)...
    5.7: Pulling from library/mysql
    a5a6f2f73cd8: Pull complete
    936836019e67: Pull complete
    283fa4c95fb4: Pull complete
    1f212fb371f9: Pull complete
    e2ae0d063e89: Pull complete
    5ed0ae805b65: Pull complete
    0283dc49ef4e: Pull complete
    a7905d9fbbea: Pull complete
    cd2a65837235: Pull complete
    5f906b8da5fe: Pull complete
    e81e51815567: Pull complete
    Pulling wordpress (wordpress:latest)...
    latest: Pulling from library/wordpress
    a5a6f2f73cd8: Already exists
    633e0d1cd2a3: Pull complete
    fcdfdf7118ba: Pull complete
    4e7dc76b1769: Pull complete
    c425447c8835: Pull complete
    75780b7b9977: Pull complete
    33ed51bc30e8: Pull complete
    7c4215700bc4: Pull complete
    d4f613c1e621: Pull complete
    de5465a3fde0: Pull complete
    6d373ffaf200: Pull complete
    991bff14f001: Pull complete
    d0a8c1ecf326: Pull complete
    aa3627a535bb: Pull complete
    a36be75bb622: Pull complete
    98ebddb8e6ca: Pull complete
    ed6e19b74de1: Pull complete
    18b9cc4a2286: Pull complete
    dfe625c958ac: Pull complete
    Creating my_first_project_db_1_d278ded39132 ... done
    Creating my_first_project_wordpress_1_e65d5f77183a ... done
    
    # docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
    993c01433ea9        wordpress:latest    "docker-entrypoint.s…"   5 minutes ago       Up 5 minutes        0.0.0.0:8000->80/tcp   my_first_project_wordpress_1_2762b868a024
    f9ba1041050d        mysql:5.7           "docker-entrypoint.s…"   5 minutes ago       Up 5 minutes        3306/tcp, 33060/tcp    my_first_project_db_1_923ac948ded6
    


    Browse to http://localhost:8000 to see the WordPress setup pages. Follow the instructions on screen.

    On the "Success!" page, select the "Log In" button. This will take you to the Wordpress Dashboard.

    Browse to http://localhost:8000/ to see the "My First Project" pages.

    Your setup is now ready and you are running WordPress in Docker on ReadyNAS OS VM!

Read more in Blog

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

1 of 2
  1. 1 2
  2. >
Tweet
  • Overzicht
  • Fotografeer tips
  • Blog
  • Essays
  • Albums
  • Inhoud
  • Twitter
  • Facebook
© 1979-2025 Peter van Loon - fotografeer.nl - since 2003 | Built with Koken