Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts

Thursday, 5 April 2018

Using USBTinyISP

Try to just use avrdude so that things can be automated with Python scripts.

- Flash Bootloader

  1. Put a fresh AVR chip (such as an Atmega328) into the Arduino in the correct orientation
  2. Remove the jumper from the USBtinyISP
  3. Plug in the USBtiny to USB
  4. Plug the Arduino into DC or USB so it is powered
  5. Plug the 6 pin cable from the USBtinyISP into the Arduino so that pin 1 mark is lined up with the red wire on the cable
  6. Start up Arduino IDE
  7. Select the chip/Arduino you are using in the Tools->Board menu
  8. Do not select a COM/Serial port
  9. Select Tools->Burn Bootloader->w/USBtinyISP
  10. The USBtinyISP red LED should light up. It will take a minute or two to program the chip
  11. When it is done, the IDE will tell you it has completed and the red LED will be off.

########################

The above method needs to be updated with pure avrdude so the process could be automated. Or, maybe no bootloader is needed if we are using USBTinyISP.

More tests coming...



- Flash arduino sketch

(1) Put the jumper back on the USBTinyISP, unplug power supply (USB cable) connected to Arduino.

(2) Plug the 6 pin cable from the USBtinyISP into the Arduino so that pin 1 mark is lined up with the red wire on the cable


Arduino should now be powered from USBTinyISP.

(3) avrdude -c usbtiny -p atmega328p -U flash:w:blink.hex

Probably need sudo
OR, install the udev rule. Check:
https://learn.adafruit.com/usbtinyisp/avrdude


###################################################################

ref:
https://learn.sparkfun.com/tutorials/pocket-avr-programmer-hookup-guide/using-avrdude
https://learn.adafruit.com/usbtinyisp/user-manual
https://learn.adafruit.com/usbtinyisp/avrdude
https://www.arduino.cc/en/Hacking/Programmer

Tuesday, 26 December 2017

Arduino Command Line Usage


arduino is simply a program from your installation directory. Without any parameters, it would just start the Arduino IDE.

open ~/.bashrc and add the following line at the bottom:
              PATH=$PATH:/home/aaa/xxx/yyy/arduinoIDE/arduino-1.8.2
Now we can use cmd "arduino" everywhere.

Use cases:
For arduino nano:
arduino --board arduino:avr:nano:cpu=atmega328 --port /dev/ttyUSB0 --upload beep.ino

Serial Monitor:
picocom /dev/ttyUSB0 -b 9600

ref:
https://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path
https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc

Monday, 20 November 2017

UART Communication Between NodeMCU and Arduino

First, I'm using MicroPython on the NodeMCU side.

Test 1:
Connections:
VIN     -    VIN
GND   -    GND
3          -    D3
2          -    D2

Arduino side code:
#include <SoftwareSerial.h>
SoftwareSerial ArduinoSerial(3, 2); // RX, TX
void setup() 
{
  Serial.begin(115200);
  ArduinoSerial.begin(4800);
}

void loop() 
{
  ArduinoSerial.write('abc');
  delay(100);
}

NudeMCU side:
from machine import 
UART uart = UART(1, 4800) 
uart.init(4800, bits=8, parity=None, stop=1) 
uart.read()

And...it didn't work.





There is UART 0 that is connected to the usb-serial converter and runs the repl.
There is UART 1 that only has a TX pin so I cannot receive data.
OSError: UART(1) can't read
There is UART 2 that doesn't seem to exist in micropython.
ValueError: UART(2) does not exist

So be it...Then we have two choices:
(1) use UART 1 but only sending data from NodeMCU to Arduino -- Test 2
(2) use UART 0 but not use the USB. -- Test 3

Both of the above tests are done using Arduino after flashing program to NodeMCU.

Test 2:




Test 3:





ref:
https://www.arduinoall.com/article/59/nodemcu-esp8266-esp8285-arduino-30-esp8266-nodemcu-%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B9%88%E0%B8%AD-arduino-%E0%B9%81%E0%B8%9A%E0%B8%9A-serial
https://www.arduino.cc/en/Reference/SoftwareSerial
https://www.arduino.cc/en/Tutorial/SoftwareSerialExample
https://docs.micropython.org/en/latest/esp8266/library/machine.UART.html?highlight=uart
https://github.com/micropython/micropython/issues/2391
https://github.com/esp8266/Arduino/issues/482

Tuesday, 28 February 2017

Arduino IDE error - avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied


If you run Arduino IDE on Ubuntu (Arduino 1.5.7 and Ubuntu 14.04 in my case), most possibly you cannot upload to Arduino board, caused by the error of:

avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
ioctl("TIOCMGET"): Inappropriate ioctl for device

To fix it, enter the command:
sudo usermod -a -G dialout <username>
sudo chmod a+rw /dev/ttyACM0


Where <username> is your user name in Ubuntu, /dev/ttyACM0 is the detected device of your Arduino board.


ref:
http://arduino-er.blogspot.ca/2014/08/arduino-ide-error-avrdude-seropen-cant.html

Friday, 11 November 2016

Arduino Uploading Problem: stk500_recv(): programmer is not responding


This actually works for me:
switch on verbose output during upload (in the arduino IDE preferences pane).


ref:
http://stackoverflow.com/questions/19765037/arduino-sketch-upload-issue-avrdude-stk500-recv-programmer-is-not-respondi