Many SPI tutorials use common notation of bus design where each device is directly in parallel connected to SCK, MISO, MOSI and CS lines. This normally works without problem, but in general, there can be problems when more than one SPI device is on the bus. DorkbotPDX rises several issues that can occur on poor design. Here are three suggestions for better SPI improvements:
- Use pullup resistors on all chip select signals.
- Verify tri-state behavior on MISO: use a tri-state buffer chip if necessary.
- Protect bus access with SPI.beginTransaction(settings) and SPI.endTransaction().
Pull up resistor helps to prevent response from multiple devices at once. This might come from poor software design when CS pins aren’t initialized properly. Second problem is with MISO pin. In fact some SPI devices doesn’t enter tri-state even when CS is pulled high. So when talking to other SPI device this will cause failures. Be sure to check if SPI device supports tri-state when inactive, otherwise add external tri-state buffer like 74AHC1G125. And last thing is SPI transactions. In systems where multiple SPI devices are used there is a risk to use different settings that were selected on different device and most importantly transactions can ensure exclusive use of SPI bus when needed.
Indeed, with Arduino declared simplicity most of us are getting lazy to dig deeper in to dangers that might await in obvious places. So always do your homework before building another schematic and don’t assume that things will work out of box every time. And this does not only apply to SPI.
When deploying remote electronic device there is always a dilemma how to power it. You normally want to provide long therm power source and if it can recharge during operation, then things are even better. If you are thinking on building embedded project outside, then you should consider using renewable power sources like sun and wind. SwitchDoc Labs has been working on handy platform that helps achieve a bit of power independence. Their main focus is to provide solar tracking for small solar panel which can charge batteries, power embedded boards like Raspberry Pi or Arduino, and report parameters to apps.
So called “SunAir” have everything you need to deploy independent system which takes care of tracking sun with two photo-resistors, servo motor and limit switches. Solar charge controller ensures that proper backup battery recharge. Level booster provides 5V to power Raspberry Pi or Arduino that can monitor “SunAir” parameters and send them through network to remote app. The rest is up to you how much reliability you want. If your project is energy hungry, then add more backup battery and larger solar cells until it will be capable of sustaining itself.
In many microcontroller projects you might want to add an USB interface which is based on USB to serial converter. There are many chips available that does this job well. Most popular is FT232R or similar which is quite expensive and in some projects it can be too pricy. If you look around, you will find that there are tons of alternatives that cost cents. Ian suggests to take a look at CH340G chip which costs as little as 40 cents. Of course it comes from China market.
He purchases several of these and built eagle part so everyone could easily include in project. Since datasheet of this chip is scarce, he’s done the hard work by finding pin-outs and drawing typical schematics for 5V and 3.3V circuits.
Microphone is another analog signal sensor which converts sound wave energy into electrical signal. Some microphones does this directly (dynamic microphones), some need additional electrical source like electret. Electret microphone is simply a capacitor which one moving diaphragm which by moving changes capacitance. It can be captured with simple RC circuit. But the signal is very low and barely detectable with microcontroller ADC. This is why normally there are microphone preamp used that gains microphone signal, filters it and gives a DC offset so it would fir perfectly to full rail of ADC input.
David actually have made two iterations of microphone preamp circuits. Previous was NPN transistor based which performed pretty good, but this time he wanted to bet even better signal and so he used operational amplifier. He selected TLC272 opamp which can work from single rail and down to 3V which makes it ideal choice for 5V and 3.3V microcontroller circuits. He found that this circuit performs pretty good even on low sound and produces lower noise than NPN version. Bellow you can see how he tested the circuit. Continue reading