Adventures with KiCAD

I have been threatening to learn KiCAD over the past months. I finally sat down for a week and went through the Contextual Concepts tutorials. They are very well done. I also referenced these other web sites. 

Getting to Blinky 4 from Contextual Electronics. This one really goes through all of the KiCAD processes. They also have a newer, down and dirty, how to create a PCB with KiCAD. This one is called Shine On You Crazy KiCAD

KiCAD Like A Pro from Tech Explorations was also a great reference when I needed to find a quick command or how to do something. 

Wayne and Layne – It is for older versions, but the basics for PCB building are there. 

 

I have a couple of projects coming up using the ATTiny series of micro controllers. Having tired of fussing with wires and a breadboard, I decided to dedicate an UNO for programming. And at the same time design and have fabricated a programming shield. 

Atty shield 3d

The schematic is simple for the first version. I have all of the programming pins in place, an LED for testing, and all of the pins broken out so something more complex than a LED can be tested, such as a sensor. 

Att sheild schematic

During the process of running the traces on in PCB I ran into an issue with the Mac trackpad where the cursor would go off with a mind of its own. I tried with just a mouse and had the same issue. I read up on the issue and saw where others have had the same thing. Having worked in tech for 30 years now, I know when to find an easier path to my problem. I already Debian Linux from having Raspberry Pi’s around the house, so I just downloaded version 9.x, and created a VM in Parallels, and loaded up KiCAD 4.x. To date it has been running fine and was able to finish up the project using my KiCAD VM. 

Att shield pcb

 

I completed my first PCB of my own design and effort. I generated the gerber files for production. In my research I also found a good site to use, https://gerblook.com. You can upload your gerber files and they will generate an image of what it will look like. And as in my case, find out if there are any error before you send them off. I forgot to turn on a layer when I generated them, and it barked about it. I went back and fixed the error and tried again with success. Then I sent them off to OSHpark.com already. I received an email that they are off to manufacturing and they should arrive in about a week and a half. I will be sure and update on how they turn out. 

This is just version one of this project. I am already working on some improvements and modifications for it coming up here in the near future. And since practice makes prefect I also have two more Christmas projects. I figure if I start now I should be able to finish them up just about the Christmas season is upon me. LOL.

Divine Muse

I have been dragging around these chunks of cherry for more than I care to remember, but I have been keeping them for a project. I have bee stewing about a case for mi Pi Audio Streamer. 

I had the garage door open a few days ago and pulled these out and started to look at them. Huh, a cherry case would be nice, look classy, and with a custom volume knob and single power light. . . ideas started to flow. How thin to cut the sheets? Joint them? Glue them? 

Fullsizeoutput 99eFullsizeoutput 99f

 

 

 

 

 

I ended up grabbing the skinner of the two. It has some interesting grain to it. 

IMG 9542

I cut three sections from the good end of the chunk. I still have the rest as there is some solid wood hidden in there and it might come in handy yet. Sorry the color is a little off but it was getting to be later in the afternoon. 

Fullsizeoutput 9a0

 

I have my sections of wood and I have the inside of it drawn out. My plan is to hollow out a section for the Pi and knob, I will get the drawing posted up here soon, but until then. . . 

ESP8266 + OLED + graphics = frustration

I have decided to make a clock; a simple one to begin with. I started with an ESP-01, an OLED, and some base code. It was fairly easy but did the job quite well. It would go out and fetch the time from a NTP (Network Time Protocol) server and display it on an OLED screen 128×64. These screens are cheap on the market and serve well for displaying a few lines of text, sensor readings, and/or graphics. One has to enter in a username and password for the wireless and the display text for the time was static on the screen, something these little displays don’t like. After a few days or couple of weeks there is bound to the burn in on the screen. I thought a poor man’s screen saver is in order.

I don’t have a picture of the ESP-01 all wired up and working, my apologies. It was getting to be a pain programming it overtime I made changes. So for development purposes I moved over to an Aamica NodeMCU dev board. This makes debugging and programming changes much easier (IMHO). And when the project is done I am able to move it over to the ESP-01. The ESP8266 is such a wonderful family of chips to work with.

To deal with wireless I downloaded and added WiFiManager to the sketch. This allows me to bring a wireless device, in this case my clock, to any wireless network and set it up for it. For example, if I bring my clock into work it won’t know which or how to access the network. Not a problem, power up the device, connect to its own AP, open a browser and give it the proper credentials. It is a very nice library to use! I thought when/if I give away a clock it will be easy for the recipient to setup and use in their own space without having to dink with changing code and uploading it.

Now the screen saver. This is straight forward (FAMOUS last words) or at least I thought it would be. After a set amount of time, blank the screen, and draw a graphic, blank the screen and bring up the time. In theory I have it working. My problem is with the graphics. I do know that graphics work and display as seen with my known eyes in the demo, but I wanted something different than a WiFi logo. I thought the Hackaday logo would do nicely.

hackaday logo 128×64

The story on the web is to head over and use either LCD Assistant or BMC-LCD to convert an image into the HEX code that is required. I kid you not when I tell you that I have tried over 26 iterations of file types, sizes, bits, etc. and all of them come up bubkiss.

The best I have been able to achieve is with a crossed line, which still shows some defects.

SIGH – I will not be deterred. Tonight I am off to the forums to see if I can scare up and help from there. I will be sure and update the site if I find out what the magic incantation is or what silly mistake I made.

From breadboard to here ya’ go. . .

Early on in my adventures in the Arduino / micro controller world one of my goals has been to usher an idea from paper, to breadboard, to protoboard, to real PCB board. After a long night of soldering, I decided to take a break and start to post my adventure.
I learned early start simple and build on what you know. In that vein I took the idea of making digital dice. To date I am up to the proto-board phase. I am making an actual “digital die” I can give as presents for this Christmas season. By next year I will have time to figure out the CAD software I will need.

I had an idea how to start the project, this will be simple. I grabbed my Arduino Uno, 7 LEDs, and my breadboard. 7 lights, 7 pins, and away I went. After a giggle of joy over seeing it work, I stared at it wondering how I was going to make a box that looked reasonable to fit the Uno. That idea was quickly nixed. In my readings and forum lurkings I had heard of the different chips in the ATmel family of microprocessors. With a little digging I soon found the ATtiny85 which seemed like it would fit the bill I was looking for. Small footprint and just a few pins. Dang, I have 7 LEDs with 7 pins and this little guy sure doesn’t have enough, or does it.

While awaiting my ATtiny order, I used the time to research a little more about this new turn I took (with little foreknowledge save it should work). I also waded through the data sheet for the ATTiny family to find out more of their capabilities. You can find the information here. There is a method to control more than 1 LED pre pin. The method is known as Charliplexing. Here is an example to get you going.
My apologies for a lack of pictures here early on. I was too involved to remember to take any.
With a little more knowledge in hand it is time to draw out how one might control the LEDs. Knowing how a die is made with the numbering scheme as dots we need a total of 5 to replicate what an actual one looks like and how they will light up in turn. With 4 pins I can control the 7 LEDs to make the 6 numbers.


JustNotesv1JPG.jpeg

scheme.jpg
Now that I had my little 85’s in hand I took to the breadboard to see what I could come up with. It took a couple of tries to a) double and triple check my wiring (make sure ground is going to ground!) b) at the same time learning how to program the ATTiny.
So, here is where there is a branch. I am going to take a quick detour on the ATtiny85. The ATT85 is part of the Atmel family of microprocessors. The ATT85 has fewer pins, less memory, and slower than what you find on the Arduino Uno board. None of these are an issue for this project and in all ways a big plus as I want this project to be small in size. There are breakout boards and programming boards one can use to program the ATtiny85 and there is the use-what-you-have-it-works-pretty-darn-well method too. I went with the later of them. Here is one of the sites I researched when planning on how to get my code on the ATTiny85.

The wiring is pretty straight forward, just follow the diagram. If it is your fist time trying this out, the blinking LED exercise if a good one; if for nothing else getting you used to setting up and uploading code to it.

On the right hand side of my breadboard you can see the ATTiny85, wire up and running the die code. In this version I am using a button switch instead of the motion switch.

It works. I have my ATtiny85 programmed with my die code, wired up to the LEDs, and it is working! I have that giddy feeling all over again, but than the sigh. Even if I get a small breadboard it still won’t look quite right. I guess it is time for another plunge and learning experience. That is a good deal of why I started tinkering in this digital world.

I knew what was next, I had to solder it all on some protoboard. You know those green or tan sheets with holes (well some have holes predrilled) that you can solder little parts onto. I made out my list of parts and pulled them all before I began. This hasn’t been your weekend type project. Between family, work, and other of life’s bits it has taken me a few weeks by now. And those boats from China really are slow!). And it has taken me more than one try to get to this point.


This is my first try at a full-on, solder it up type project. I didn’t think I would get it right on the first try, but Oye Vey! It almost worked, but my voltage readings were waaaaaay low by time I measure at the LED pins. Oh well, I will not be deterred and try again.

It is time to move forward, remembering mistakes made, and get it right this time. Before this attempt, I went to a good friend of mine who is an EE and quite the hardware hobbyist. He gave me a couple of quick, and very informative soldering lessons. During my lesson I learned that my lead-free solder was causing me some issues as it takes a higher heat to use and even slightly higher heat to reflow. Before tackling this next part, I was sure to procure some leaded solder and it makes a difference.

The first thing I started to thing about, beyond the predetermined layout for my LEDs, was how to best wire them. My end goal being a manufactured PCB, so why not use this exercise to start to think in that mode. All LEDs have 2 leads, one for ground and one for power. I started by arranging as many LEDs as I could with the ground pin on the outside of the board. This way I can chain them together to create an easy ground path.

The only one I needed to worry about was the inner LED. In its’ case I bent the ground pin over to the main ground path. It reached with some to spare.
Now I started to look at connecting the power for the LEDs. Where I could, for aesthetics, I ran a straight wire on top of the board. This keeps the wire count below down and gives it a nice look (I think).
Working with the back I tried to keep the lines as clean as possible too. The backside is a little more of a challenge.

In a yet another branch, while on my travels, it was noted that the ATtiny13 might work in this case as well. The memory footprint is smaller, but than the sketch for this project isn’t that big to begin with. I ordered a few in one of my bundles. Since I have a socket on the board, it will be easy to test!
I have four pins left to solder and apply power for the big test. That will be tonight. I will be sure and let you know how it goes.
Keep up with my progress over at wrightmac.net I am not done yet. 🙂
BOM (Bill of Materials)
1 Protoboard
1 ATTiny85 (read a little lower for more on this choice)
7 LED, 5mm
1 Motion switch
1 Various 24AWG solid core or stranded wire
1 Soldering iron

The WeatherProject

A simple project has run into that infamous scope-creep but in a good way. To that end, I decided to take the little bits and pieces I have scattered on the web and condenses them into one place, a domain I have had sitting around just looking for a purpose and these does seem to be at great one.

 

Arduino Basic Indoor Weather Station

This project is for a basic, Arduino based, weather monitoring station. While this project is for indoor use only, one could easily find an appropriate weather proof case; and using battiers or solar power with wireless place it outside. This kit is meant as an introduction to the Arduino platform, using sensors, and a door to a fun world.

Parts needed:

1 x Arduino Uno clone
1 x 25cm micro USB data cable
1 x DHT22 sensor
1 x BMP280 sensor
1 x 5110 84×48 LCD screen
xx x Male to Female Jumper Cables
xx xx Female to female Jumper Cables
2 x 10k resistors – for sensors
1 x 470Ohm resistor – for LCD

Software needed:

Arduino IDE 1.6.x Various Libraries, find links in the docs.

Let’s get started!

The order of the parts listed below are the order I wired up and tested each part. It makes trouble shooting easier to take each component, wire it up, install the library, load a test sketch, and make sure it works. Nothing is more frustrating than plugging in 14 wires and nothing happening.

Be sure and check your connections. I will admit to pulling an oops and damaging a component by not paying attention to where those pesky Vcc and ground wires were going. If you have issues, check your wiring first. If you have a multimeter, you can also make sure you have continuity and expected voltages.

The DHT22

DHT22 Pins Arduino Pins
1 – Vcc 5v
2 – Signal + 10k 2
3 – Open Open
4 – Gnd Ground

The DHT22 is a low-cost, but accurate, digital temperature and humidity sensor. It has a captive humidity sensor and a thermistor for reading the ambient temperature. It is 3-6v tolerant for both the Vcc (power in) and digital signal line (pin 2). The pins are 1 -4, left to right, looking at the front (the grill side).

Arduino pin 2 is used in this sketch, but any other pin could be used.

Here is a link to the DHT22 datasheet.

The BMP280

BMP280 Pins Arduino Pins
Vcc 5v
Gnd Ground
SCL A5
SDA A4
CSB Open
SD0 High – 0x76
Low – 0x77

The BMP280 is a barometric pressure and temperature sensor. It is a sensor with great accuracy. In fact with a little work one can obtain an altimeter reading within +/- 1M the sensors are so accurate. (I haven’t tested that claim yet) It communicates with the Arduino via the I2C interface. The address must be set either high or low as if it is left at default it won’t work. To set the address high (0x76) use a 10k resistor and connect it to power. If you connect it to ground in the same fashion it will use the low address (0x77).

A good troubleshooting tool to use when first working with I2C is an I2C Scanner. There is a copy of it in my github. I have started a cheatsheet list of the devices I have and what addresses they have. Each time I get a new one I will run it against i2c to make sure it works and see what address to use. 

Here is a link to the BMP280 datasheet.

And here is the link to the BME280 library used here.

The LCD

LCD Pin Arduino Pin
1 – RST 12
2 – CE 11
3 – DC 10
4 – Dir 9
5 -Clk 8
6 – Vcc 3.3v
7 – BL 7 – with 470Ohm resistor
8 – GND Ground

The LCD is based on the old Nokia 5110 LCD screen used in their past phones. It is a decent sreen and easy to find. Its’ display is 48 rows by 84 columns. It has a PCD8544 controller used for all LCD functions. This model uses SPI for its communication with the Arduino. There are other ones out there that use the I2C protocol which only requires 4 pins. There are some different libraries out there too. I used xxx in this project. The basic functions are well-documented and they also have an additional library with graphical functions.

To Do:
Keeping some historical data and being able to graph them over time is a good additional project. One could store the data on an SD card or rely it via wireless. There is a section of code that shows how to output data in a CVS format for later analysis. 

The library used is located here.

Code it up

As of this writing the lastest version of the sketch is 0.6. Check back for updated versions. I have tried to comment the code to make it easy to follow. I know that good comments make it easier to follow along what is happening. And when one is learning this is a good thing.

Launch the Arduino IDE, open up the sketch Weather0.6.ino found in this github. From the Tools, make sure you are working with the right board, both model and serial port used. A quick verify and compile, then upload. If you have not used the Arduino IDE before there are several great tutorials out there. Here is a good starting point for the first timers, head to this Instructable. Launch the Arduino IDE, open the weather sketch.