Jay, trying to remember...

Ubiquiti AP Setup Debugging

While trying out a Ubiquiti wifi solution, I ran into one AP not getting installed correctly. It was showing as either disconnected or pending authorization - the latter I think means that it was trying to connect to a wifi netowork rather than the ethernet network it was plugged into.

Through various Google searches, I found that might mean that the controller and the AP were running different versions. I tried a few times upgrading via the web interface to no avail. Finally I got the upgrade bin file by getting it from the controller:

http://10.0.2.22:8080/dl/firmware/BZ2/3.2.12.2920/firmware.bin

and then scp-ing it to the non working AP - the default user / pass for a factory reset AP is ubnt / ubnt:

scp firmware.bin ubnt@10.0.2.25:/tmp/fwupdate.bin

It then said “Managed by Other” - I adopted via the advanced setting and used ubnt / ubnt for user / pass.

There were some other things that went on, and now the AP is showing as Connected (100 FDX) which means it’s not connected to as a gigabit port (even though it is) — so there’s still some work to do.

Using Platformio with ESP8266 Arduino 2.1.0-rc2 release candidate

In order to get Platformio to build a project based on ESP8266 release candidate, I had to do the following - basically these instructions:

I think I can get back to norm by doing a- though the ldscripts folder will still be messed up…

platformio platforms uninstall espressif
platformio platforms install espressif

Wondering if I could use the following to set these as seen in the repo :

[env:specific_ld_script]
build_flags = -Wl,-Tname_of_script.ld

Adafruit Feather ESP8266 module - Arduino IDE settings

These are the settings that got me up and going- before this I was getting warning: espcomm_sync failed error: espcomm_open failed error

Arduino IDE settings

PlatformIO Investigation

While looking around for a good library to parse JSON on an Arduino, I bumped into PlatformIO. This seems to address a problem I’ve been struggling with – library / board management.

I had to update my OS X Homebrew install of Python to get this working (I really needed to do that anyway) and I needed to install this using sudo - sudo pip install -U platformio. Because of virtualenv, I also had to gpip install -U pip setuptools - which is using a ‘global’ version of the Python pip command. Modifications to my .bashrc file were required…

With all that, I was able to build and deploy the ‘blink’ code on a Arduino Uno (actually an Adafruit Metro) using the command:

 mkdir platformio_blink
 cd platformio_blink
 platformio init --board=uno

and then added a main.cpp file to the platformio_blink/src folder

Here’s what that looks like:

#ifdef ENERGIA
	#include "Energia.h"
#else
	#include "Arduino.h"
#endif

#ifndef LED_PIN
	// Most Arduino boards already have a LED attached to pin 13 on the board itself
	#define LED_PIN 13
#endif

void setup() {
  pinMode(LED_PIN, OUTPUT);     // set pin as output
}

void loop() {
  digitalWrite(LED_PIN, HIGH);  // set the LED on
  delay(1000);                  // wait for a second
  digitalWrite(LED_PIN, LOW);   // set the LED off
  delay(1000);                  // wait for a second
}

Then by executing platformio run, the code was uploaded to the Uno / Metro board. And voila, blinking pin 13!

ES8266 / DHT22 - Wi-Fi / Temperature & Humidity server (example mashup)

Here’s a quick (couple hours with my sloppy mistakes) mashup of two Arduino examples - the ES8266 (HUZZAH from Adafruit) WiFi controller and a DHT22 temperature and humidity sensor. This is the start of a bigger project which tells outdoor and indoor temperature along with accurate time (more on that to come), and probably wind speed, etc…

Here’s (sort of) what the circuit looks like: ES8266 / DHT22 Circuit

Here’s a photo of the protoboard: circuit on protoboard

and here’s the quick mashup code of the two example:

Update to using an ATtiny85 in a Similar Way To An Adafruit Trinket - specifically to run the Adafruit Neopixel library

I’m continuing to try and ‘cheap-ify’ my per effect cost for my Halloween decorations. I ran into some issues last night trying to get an Arduino sketch that used the Adafruit Neopixel library and ran on a Trinket to run on a straight ATtiny85. The solution was to select the chip in the Arduino IDE and using an AVR programmer, burn the ‘bootloader’.

If you’re following along (which of course you’re not) - I added the ATtiny85 ‘board’ to the ~/Documents/Arduino/hardware/tiny/avr/boards.txt file (in my OS X case). The ‘board’ is actually a description of the ATtiny chip and looks something like this (16Mhz):

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

attiny85at16p.name=ATtiny85 @ 16 MHz  (internal PLL; 4.3 V BOD)

attiny85at16p.upload.tool=arduino:arduinoisp

attiny85at16p.upload.maximum_size=8192
attiny85at16p.upload.maximum_data_size=512

# PLL Clock; Start-up time PWRDWN/RESET: 1K CK/14 CK + 4 ms; [CKSEL=0001 SUT=00]
# Brown-out detection level at VCC=4.3 V; [BODLEVEL=100]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]
# Serial program downloading (SPI) enabled; [SPIEN=0]

attiny85at16p.bootloader.low_fuses=0xC1
attiny85at16p.bootloader.high_fuses=0xD4
attiny85at16p.bootloader.extended_fuses=0xFF

attiny85at16p.bootloader.path=empty
attiny85at16p.bootloader.file=empty85at16.hex
attiny85at16p.bootloader.tool=arduino:avrdude

attiny85at16p.build.mcu=attiny85
attiny85at16p.build.f_cpu=16000000L
attiny85at16p.build.core=tiny

Basically, all I believe that did was set the fuses correctly, but without too much digging, it didn’t seem to be working when I manually set the fuses for the chip using avrdude. I’m not going to complain or dig much more now that it’s working.

Incidentally, the setup (code) for the Neopixel library looks like this:

Revisiting ATtiny85 Software-Based PWM to Drive RGB LED

I’m digging up some old code that I did a long time ago - It’s a software-based pulse width modulator (PWM) for AVR microprocessors. The basics came from this technote, and the code was based on this sample project from AVR.

I originally wanted to have this run 2 RGB LEDs from an ATtiny85 but I steered away from that because I was going to have to use the reset pin as an output and then I ran across this in the ATtiny datasheet - Table 21-1, page 162:

6. The RESET pin must tolerate high voltages when entering and operating in programming modes and, as a consequence,
has a weak drive strength as compared to regular I/O pins. See Figure 22-23, Figure 22-24, Figure 22-25, and Figure 22-26
(starting on page 184).

Looks like I can’t drive an LED with the reset as an output directly. Bummer. No big deal using a bigger (more pins) AVR chip, but I thought it was cool to get two PWM-ed RGB LEDs out of an 8-pin chip.

Setting My ATtiny85 Fuses To Mimic The Adafruit Trinket

To get a Adafruit Trinket Arduino sketch running on a straight-up ATtiny85, I did the following:

I set the fuses of the ATtiny85 to what I believe the Trinket uses - or at least what the boards.txt has in it. I did this using my AVR Dragon - I believe that this has to be done with high-voltage programing, but I’m not sure, so don’t quote me.

avrdude -c dragon_hvsp -p attiny85 -U lfuse:w:0xc1:m -U hfuse:w:0xd4:m -U efuse:w:0xff:m -P usb

Downloaded the arduino-tiny library from their expiring Google Code site. If this gets shutdown, there may or may not be a self-hosted mirror link in the HTML comments of this page. Follow the instructions on arduino-tiny site, but essentially it required creating a boards.txt file.

To this boards.txt file, (in my case it was at ~/Documents/Arduino/hardware/tiny/avr/boards.txt) I added the following:

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

attiny85at16p.name=ATtiny85 @ 16 MHz  (internal PLL; 4.3 V BOD)

attiny85at16p.upload.tool=arduino:arduinoisp

attiny85at16p.upload.maximum_size=8192
attiny85at16p.upload.maximum_data_size=512

# PLL Clock; Start-up time PWRDWN/RESET: 1K CK/14 CK + 4 ms; [CKSEL=0001 SUT=00]
# Brown-out detection level at VCC=4.3 V; [BODLEVEL=100]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]
# Serial program downloading (SPI) enabled; [SPIEN=0]

attiny85at16p.bootloader.low_fuses=0xC1
attiny85at16p.bootloader.high_fuses=0xD4
attiny85at16p.bootloader.extended_fuses=0xFF

attiny85at16p.bootloader.path=empty
attiny85at16p.bootloader.file=empty85at16.hex
attiny85at16p.bootloader.tool=arduino:avrdude

attiny85at16p.build.mcu=attiny85
attiny85at16p.build.f_cpu=16000000L
attiny85at16p.build.core=tiny

Now, obviously, select this board when building the sketch.

Getting my AVR Dragon to talk to the Arduino IDE on OSX

I added the following to /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/programmers.txt and restarted the Arduino IDE and magically, this seemed to work for me.

  dragon.name=Atmel AVR Dragon in HVSP mode
  dragon.communication=usb
  dragon.protocol=dragon_hvsp
  dragon.program.tool=avrdude
  dragon.program.extra_params=-P usb

I pieced this together from these two sites.

AVR Dragon and OSX (trying it out again)

I’ve been inspired by my 4yo son to get back into some electronics for a spooky Halloween display we’re planning on setting up this year. Who am I kidding, my son has nothing to do with it. Anyway, I want to make a few cheap, but hopefully terrifying, effects for the yard and inside.

Some blinking eyes seem like a good thing to hang in the bushes and trees outside, so I’m looking at using an ATtiny85 and a couple of LEDs for them. Here’s my proof of concept - running the ATtiny @ 6V (on fresh batteries) which is slightly higher than specs say is cool. Also running the LEDs stright from pins without current limiting resistors.

ATtiny85 blinker

It’s been a long time since I did any AVR stuff, so I’m going to try and document what I’m doing here - with the hope that someday I can find it again…

Some of what was difficult before doing AVR on OSX looks to be simplified by others now. For instance, to get the tool chain up and running you can use Homebrew - these instructions are from https://github.com/osx-cross/homebrew-avr/

  $ brew tap osx-cross/avr
  $ brew install avr-libc
  $ brew install avrdude --with-usb

Be patient, there’s a lot going in that second command.

I’m using the AVR Dragon development platform for programming the ATtiny - It’s a little complicated, and there may be easier / more straight forward ways of doing this now, but this is what I have and it did work at one time. I purchased 2 DracoDapters quite some time ago from www.allgaiershops.com - these made the config of the Dragon a lot easier but I’m not very confident you can still buy them. I also soldered on a ZIF socket.

I’m really not sure what follows was needed or not, but in an attempt to find out why make install didn’t work because of error avrdude: usbdev_open(): did not find any USB device "usb", I ran into this: OSX USB solution

This was specific to an error with the Atmel ICE development platform, so I modified it for my AVR Dragon. Here is a zip of the USB config for OSX. I found the AVR Dragon values here - (which needed to be converted to hex). Then I copied and changed the permissions as follows - I also rebooted, just to be safe:

$ sudo cp -R AvrDragon.kext /System/Library/Extensions
$ chown -R root:wheel /System/Library/Extensions/AvrDragon.kext
$ chmod -R 755 /System/Library/Extensions/AvrDragon.kext
$ sudo kextcache -system-caches

make install still doesn’t work, but a make flash and make fuse when run seperatly does.