Author Topic: Tutorial: Convert a Digispark in to a LittleWire AVR/PIC programmer and IO multitool, or ttl serial  (Read 24215 times)

Bluebie

  • Sr. Member
  • ****
  • Posts: 487
I've created a quick little screencast explaining how to upload the LittleWire firmware to a digispark, turning it in to an AVR/PIC programmer, as well as allowing access to all of LittleWire's other features. It's a handy tool for experimenting as it lets you talk to SPI, i2c, and 1wire devices from languages including c, c++, c#, python, ruby, and processing. Ihsan - the creator of LittleWire also helped create some of the software used by the DigiSpark - the micronucleus program we'll be using to upload our program.

An AVR programmer is particularly handy because you can buy the same ATtiny85 chips used by the Digispark in their raw form for about $3 each, and by hooking them up with a programmer you can upload Digispark programs directly on to them. They're a little bit smaller, but they don't have the USB port or power regulator, so they need to be powered by a five 4.0-5.5 volt power supply - a USB phone charger works great! A couple of dollars cheaper might not seem like much, but it's been very important for me when doing art installations which used ten or more chips to drive large collections of lights.

Using the LittleWire libraries (including the ruby version I made) you can quickly experiment with talking to accelerometers, temperature sensors, iButtons, RFID readers, analog sensors, servos, and all sorts of other gadgets in a more concise language than the C-based code used in the Arduino software. I especially like using Ruby because the Interactive Ruby program lets you type in and run code line by line, seeing the return values of functions immediately. It really is a much nicer way to experiment than trying to print out debugging stuff through DigiUSB or serial ports or whatever else. If you're going to leave your device plugged in to a computer anyway it often makes more sense to write all the code on the computer and just puppet it with a firmware like LittleWire too.

Digispark LittleWire tutorial from Jenna Fox on Vimeo.



LittleWire homepage: http://littlewire.cc
LittleWire Github Download: https://github.com/kehribar/Little-Wire

The process should be very similar on other operating systems - you'll just need to find the micronucleus binary in the digispark arduino installation in another way, and I'm not sure if the dragging files on to a terminal will work on every operating system.
« Last Edit: January 10, 2013, 06:14:34 pm by Bluebie »

dmcinnes

  • Newbie
  • *
  • Posts: 21
Very cool. I've been using my arduino duemilanove to program attiny85s, it would be nice to wire up a digispark proto board with a socket for compactness  :)


How would you wire this up?

dmcinnes

  • Newbie
  • *
  • Posts: 21
Helps if I look at the documentation:
http://littlewire.cc/documentation.html



I was able to get the bootloader running and got avrdude connecting. I couldn't get it to see any chips I wired in using the pinout in those docs.


Looking at the LittleWire board pinouts it looks like it's using pins 2 and 3 for USB and the digispark uses pins 3 and 4.
http://solderpad.com/ihsan_kehribar/minimal-avr-programmer-and-more/


Digging further into the source for main.hex it looks like it's actually using different pins for MISO, SCK, RESET and MOSI:
https://github.com/littlewire/Little-Wire/blob/master/v1.1/firmware/source/main.c#L113-L116


That works! I have the blink sketch running right now.


For the curious the pins are basically 1 to 1:



DigiSpark => ATtiny85
pin 0        pin 0 (MOSI)
pin 1        pin 1 (MISO)
pin 2        pin 2 (SCK)
pin 5        pin 5 (RESET)

Don't forget you need to wire up 5V and Ground for the ATtiny85!

Bluebie

  • Sr. Member
  • ****
  • Posts: 487
I don't understand how you came to those conclusions. The LittleWire uses exactly the same wiring as a digispark - it just lacks the external voltage regulator, and has slightly different resistor values. The USB D- and D+ lines are clearly connected to PB3 and PB4 in the schematic just as with the digispark.


Glad you got it working though ^_^

dmcinnes

  • Newbie
  • *
  • Posts: 21
Heh I'm new to all this programmer business. I didn't realize the documentation was referring about the ISP header (though I didn't have any idea what that was until recently). I thought it meant the pins on the chip.
I saw the numbers on the lines of the schematic and thought that meant the pins instead of the PB numbers:
http://solderpad.com/ihsan_kehribar/minimal-avr-programmer-and-more/
Those are the physical pins, huh.


In any case, source code does not lie!  :P

dmcinnes

  • Newbie
  • *
  • Posts: 21

Finished the ATtiny85 programmer using a chip socket and the Digispark proto board.
Loosened up the socket by sticking some headers in there. Now the chip goes in and comes out without having to force it.
Added an LED on P4 to show when it's being written to:




Ugly underside but it works  :P



kehribar

  • Newbie
  • *
  • Posts: 18
@dmcinnes

I'm glad that you found the LittleWire app useful. Have fun!

Also you are right, the pin numbers i refer on the website aren't the actual Attiny85 pin numbers. I gave the numbers in the order they appear in the 6 pin AVR-ISP connector. You found solution in the end anyway but i just wanted to clarify again :)

@Jenna

Thanks again for great tutorial :)

ihsan.

psergiu

  • Newbie
  • *
  • Posts: 3
Once you have successfully uploaded the LittleWire firmware on a DigiSpark, is there any way to upload the original DigiSpark firmware back using the USB port ?


Thanks.

Bluebie

  • Sr. Member
  • ****
  • Posts: 487
The LittleWire firmware does not replace the digispark software - it is a program uploaded in the same way as an arduino sketch. You can replace it with an arduino sketch using the normal upload process.

ej.cardinal

  • Newbie
  • *
  • Posts: 6
Thanks for the video! I just followed the video and successfully installed the .hex to a digispark. I haven't had a chance to play with it yet, but I will soon.

HobbyGuy

  • Newbie
  • *
  • Posts: 2
Thanks for the video. I followed it and all went well. I am in the process of installing ruby on my MAC so i can try your Ruby Libraries.  That will be great to try some stuff, but longterm how can I use the Digispark as a standalone interface to a onewire device - particularlyI am trying this temperature sensor which I have:  http://dx.com/p/ds18b20-digital-temperature-sensor-module-for-arduino-55-125-c-135047

I may just be tired, or losing it, but I am missing something :)
Long-term my goal would be to read from that sensor and incorporate the RadioBlocks to send the data back to my network of distumps to consume. Or in the interim just display on a lcd.


Bluebie

  • Sr. Member
  • ****
  • Posts: 487
I havent played with onewire stuff and didn't get around to implementing it in the ruby library, but @kehribar does have support for it in his c/c++ library so it wouldn't be too difficult to figure it out.  Probably best to defer to @kehribar on this one.

kehribar

  • Newbie
  • *
  • Posts: 18
Hi,

You can easily use 1-wire sensors with the littlewire firmware. Currently, the C library is the most error-free way of using that feature. You can check it here: https://github.com/kehribar/Little-Wire/tree/master/v1.1/computer_interface/C  Onewire applications is under the examples folder. Also you can find an example project involving onewire sensor + littlewire here: http://jjmz.free.fr/?p=124

By the way, if you find it hard to use the C library , don't worry; I'm going to create an easier documentation for the littlewire soon. You can sneak peek the v1.2 release and psuedo-documentation here: https://github.com/kehribar/Little-Wire/tree/danger/v1.2 Also the C library in the v1.2 has doxygen support :)

Jenna,

I might as well try to add onewire support to your Ruby library myself :) I haven't done any Ruby programming before but i'll give it a shot :)

ihsan.

Bluebie

  • Sr. Member
  • ****
  • Posts: 487
Sure if you like! A friend gave me a onewire temperature sensor I have somewhere, could dig it out I'm sure. Maybe if you write some onewire code for ruby, when it's done you can tell me how you actually wire up such a sensor so I can test it on my end before pushing the update to rubygems?

kehribar

  • Newbie
  • *
  • Posts: 18
Hi All,

Webpage for the Little Wire project is updated with the v1.2 relaese of the firmware/software: http://littlewire.cc

By the way,

I'm planning to release 'single click' application that can converts your digisparks to littlewire soon. Actually I wrote the application but haven't released any binaries for Mac/Windows/Linux. GitHub page for this project is this: https://github.com/kehribar/customMicronucleusLoader Repo is updated with the latest littlewire_v12.hex firmware.

Comments and issue reports are welcomed! I'm still tinkering with the webpage ...

Best,
ihsan.