Posts | Comments

Planet Arduino

Archive for the ‘Hackaday Columns’ Category

In August of 2014, something new started showing up in the markets of Shenzen, the hi-tech area of China where the majority of the world’s electronics components are made. This is the ESP8266, a WiFi SoC (System on a Chip) that can connect to 802.11b/g/n networks on the 2.4GHz band. It can be addressed with SPI or a serial connection, and has an AT command set that makes it behave rather like an old-style modem. Basically, it has everything you would need to connect a device to a WiFi network, with the ESP8266 chip itself handling the complicated business of finding, joining and transmitting/receiving over a WiFi network.

That’s nothing particularly new in itself: WiFi connection devices like the TI CC3000 have been around for longer, and do much the same thing. The difference was the price. While the TI solution costs about $10 if you buy several thousand of them, the ESP8266 costs less than $7 for an individual board that can plug straight into an Arduino or similar. Buy the chip in bulk, and you can get it for less than $2.

The ESP8266 is more than just a WiFi dongle, though: it is a fully fledged computer in itself, with a megabyte of flash memory and a 32-bit processor that uses a RISC architecture. This can run applications, turning the ESP8266 into a standalone module that can collect and send data over the Internet. And it can do this while drawing a reasonably low amount of power: while receiving data, it typically uses just 60mA, and sending data over an 802.11n connection uses just 145mA. That means you can drive it from a small battery or other small power source, and it will keep running for a long time.

It wasn’t an easy ship to write applications for in the early days, though: it was poorly documented and required a dedicated toolchain to work with. This made it more of a challenge than many hackers were comfortable with.  That changed earlier this year, though, when the Arduino IDE (Integrated Development Environment) was ported to the chip. This meant that you could use the much easier to write Arduino functions and libraries to write code for the chip, bringing it within reach of even the most casual hacker.

ESP8266 Decapped
A decapped ESP8266, with area of interest marked by Reddit user swimmerdude. The big area on the right is memory

Why Is the ESP8266 Important?

The ESP8266 almost achieves the holy trifecta of electronics: cheap, powerful and easy to work with. Before this, if you wanted to add a wireless connection to a project, you had to use more power-hungry devices like USB WiFi dongles, or squish everything into a serial connection and use a wireless serial link. Either way added to the complexity of the project: you either needed a system that supported USB and had WiFI OS support, or you had to put up with the limitations of wireless serial links, which typically offer very limited bandwidth. The advent of WiFi SoCs removed these limitations because the SoC did the heavy lifting, and WiFi offered much more bandwidth. And the ESP8266 did this all at a very low cost: do some digging on eBay and you can get an ESP8266 board for less than $2. So, it is no surprise that we are starting to see the ESP8266 showing up in commercial products

How Can I Use the ESP8266?

With the popularity of the ESP8266 for adding WiFi to projects, it is no surprise that there are a lot of options for trying it out. On the hardware side, ESP8266 development boards are available from a number of places, including Seeedstudio, Sparkfun and Olimex. Adafruit also has a nice ESP8266 board that breaks out all of the signals for easy breadboard use, and adds a 3.3V output, so it can drive an external device. It is also FCC approved, which is important if you are looking to sell or use the devices you build commercially. Some users have also been building their own development boards, which add features such as LCD displays and buttons.

The Adafruit Huzzah ESP8266 dev board
The Adafruit Huzzah ESP8266 dev board

On the software side, the easiest way to get into the ESP8266 is to use the Arduino compatible mode. This involves loading custom firmware that turns the chip into a mid-range Arduino board, which makes for much easier programming. The people behind this project have produced a list of supported ESP8266 boards: buying one of these will make the installation process easier, as they have noted which data lines in the Arduino SDK correspond to the physical pins on the board. These boards also provide easy access to the reset lines that you have to use to install the Arduino compatible firmware.

This does include some limitations, though: it is rather complicated to upload new sketches over WiFi, and you can’t produce multiple PWM signals, which would make controlling multiple devices difficult. To get access to the full capabilities of the ESP8266, you’ll need to go to the source, and use the SDK that the manufacturers offer. [cnlohr] published an in-depth guide here on Hackaday for bare-metal programming the ESP8266 whih was mentioned earlier. Espressif also offer a pretty good getting started guide that covers creating a virtual Linux machine and connecting this to their chips.

The third option is to flash NodeMCU to the ESP8266 module. This turns it into a Lua interpreter. Scripting can be done in real-time to prototype your program, then flashed to the EEPROM to make your program persistent and remove the need for a serial connection.

Beginners will be comfortable with both the Arduino and NodeMCU approaches, but experienced users should be able to wade straight in and start writing code for this cheap, powerful and fairly easy to use chip.


Filed under: Arduino Hacks, Hackaday Columns, wireless hacks

Speak with those who consider themselves hardcore engineers and you might hear “Arduinos are for noobs” or some other similar nonsense. These naysayers see the platform as a simplified, overpriced, and over-hyped tool that lets you blink a few LEDs or maybe even read a sensor or two. They might say that Arduino is great for high school projects and EE wannabes tinkering in their garage, but REAL engineering is done with ARM, x86 or PICs. Guess what? There are Arduino compatible boards built around all three of those architectures. Below you can see but three examples in the DUE, Galileo, and Fubarino SD boards.

Arduino DUE uses Atmel ARM Arduino Galileo uses Intel x86 Fubarino SD uses PIC32

This attitude towards Arduino exists mainly out of ignorance. So let’s break down a few myths and preconceived biases that might still be lurking amongst some EEs and then talk about Arduino’s ability to move past the makers.

Arduino is NOT the Uno

When some hear “Arduino”, they think of that little blue board that you can plug a 9v battery into and start making stuff. While this is technically true, there’s a lot more to it than that.

  1. An Arduino Uno is justanAVR development board.AVRs are similar to PICs. When someones says “I used a PIC as the main processor”, does that mean they stuck the entire PIC development board into their project? Of course not. It’s the same with Arduino (in most cases), and design is done the same way as with any other microcontroller –
    • Use the development board to make, create and debug.
    • When ready, move the processor to your dedicated board.
  2. What makes an Arduino an “Arduino” and not justan AVR but the bootloader. Thus:
    • An Atmega328P is an AVR processor.
    • An Atmega328P with the Arduino bootloader is an Arduino.
  3. The bootloader allows you to program the AVR with the Arduino IDE. If you remove the bootloader from the AVR, you now have an AVR development board that can be programmed with AVR Studio using your preferred language.

There Is No Special Arduino Language

Arduino "blink" sketch should run on any Arduino compatible board.
Arduino “blink” sketch should run on any Arduino compatible board.

Yes, I know they call them sketches, which is silly. But the fact is it’s just c++. The same c++ you’d use to program your PIC. The bootloader allows the IDE to call functions, making it easy to code and giving Arduino its reputation of being easy to work with. But don’t let the “easy” fool you. They’re real c/c++ functions that get passed to a real c/c++ compiler. In fact, any c/c++ construct will work in the Arduino IDE. With that said – if there is any negative attribute to Arduino, it is the IDE. It’s simple and there is no debugger.

The strength comes in the standardization of the platform. You can adapt the Arduino standard to a board you have made and that adaptation should allow the myriad of libraries for Arduino to work with your new piece of hardware. This is a powerful benefit of the ecosystem. At the same time, this easy of getting things up and running has resulted in a lot of the negative associations discussed previously.

So there you have it. Arduino is no different from any other microcontroller, and is fully capable of being used in consumer products along side PICs, ARMs etc. To say otherwise is foolish.

What is the Virtue of Arduino in Consumer Products?

This is Ask Hackaday so you know there’s a question in the works. What is the virtue of Arduino in consumer products? Most electronics these days have a Device Firmware Upgrade (DFU) mode that allows the end user to upgrade the code, so Arduino doesn’t have a leg up there. One might argue that using Arduino means the code is Open Source and therefore ripe for community improvements but closed-source binaries can still be distributed for the platform. Yet there are many products out there that have managed to unlock the “community multiplier” that comes from releasing the code and inviting improvements.

What do you think the benefits of building consumer goods around Arduino are, what will the future look like, and how will we get there? Leave your thoughts below!


Filed under: Arduino Hacks, Ask Hackaday, Hackaday Columns, rants
May
01

A little board that adds WiFi to any project for a few hundreds of pennies has been all the rage for at least half a year. I am referring to the ESP8266 and this product is a marrige of one of those WiFi modules with the support hardware required to get it running. This week I’m reviewing the HUZZAH ESP8266 Breakout by Adafruit Industries.

If you saw the article [cnlohr] woite for us about direct programming this board you will know that a good chunk of that post covered what you need to do just to get the module into programming mode. This required adding a regulated 3.3V source, and a way to pull one of the pins to ground when resetting the power rail. Not only does the HUZZAH take care of that for you, it turns the non-breadboard friendly module into a DIP form factor while breaking out way more pins than the most common module offers. All of this and the price tag is just $9.95. Join me after the break for the complete run-down.

The Hardware

huzzah-esp8266-breadboardThis board is about 1.5 inches by 1 inch… like two postage stamps side-by-side. It hosts the FCC and CE approved module which we first heard about in December. These modules need a 3.3v supply and there is a regultor on board which can supply up to 500mA (the module can consume as much as 250mA) and can be fed by a battery, USB power, or any other 5V supply. As I mentioned earlier you need to pull a pin low during reset to put the module in programming mode. There are two switches on the board that facilitate this, hold the user button down and press reset and you’re ready to flash.

On a breadboard you’ll have two rows not covered by the board on one side, and one row on the other. The board doesn’t have a USB-to-UART bridge but we’re fine with that. On one end of the board you’ll find the common pinout for a USB-to-serial programming cable. Above you can see the programming cable Adafruit sent me with these samples. huzzah-esp8266-ftdi-cableTo the right I tried out my 5V Sparkfun FTDI board and as advertised, the HUZZAH can be programmed with either 3.3v or 5V logic levels.

The one thing I noticed is that the two buttons are a bit tricky to get at with the programmers connected, especially the FTDI board. For the second module I may supply my own right-angle header to get around that. Of course doing so would cover part of the breadboard so this is probably six of one, half dozen of the other.

I love it that they supply the pin headers but don’t solder them. Sometimes I prefer pin sockets or unpopulated pads, and this makes it easy for me to make that choice like the right-angle one I mentioned above. It’s something small but I also appreciate that the pinheaders in the package were not the minimum number necessary for this board — there were a few extra pins. You need to break them off and sometimes they can break one pin over from where you expected. If it were the minimum number you would either start over or solder a single pin at the end of the row (not ideal). If you screw up snapping these you could conceivably use a set of three pins and the rest as one unit to fix your mistake. Maybe I’m weird but it’s the small things in life!

Programming Options: NodeMCU and Lua

The board ships with this firmware on it. I was up and running with the Lua interpreter within three minutes of the package arriving at my door. Seriously, it took me longer to figure out if the USB-to-serial was green or white for TX/RX than it did to connect to my local WiFi Access point. Adafuit’s ‘Hello World’ walkthrough gets you going if you haven’t given this a try before.

Programming Options: Arduino IDE

adafruit-board-managerAdafruit has a Board Manager for Arduino IDE. Perhaps this is common knowledge but I don’t often work with this IDE and it’s the first time I’ve run into it. What can I say, it kicks ass!

I hate setting up tool chains for new chips. With this you add a web address and port number, restart the IDE, and use the board manager to add support for this board. Sweet!

That turns this into an Arduino compatible board which solves something that has long bothered me. I’ve seen a ton of really simple Arduino projects that use the ESP8266 externally. Last month’s porting of the Arduino framework for these chips, coupled with this ready-to-go hardware does away with that nonsense. Seriously, the vast majority of those projects need little to no computing power and will work like a dream when directly programmed onto this chip.

huzzah-plenty-of-IOTo prove my point, I knocked out this quick binary counter that uses five LEDs as outputs. I’m not leveraging any of the WiFi features on this, but the compiled binary is 174,358 bytes and the Arduino IDE reports this board has a max capacity of 524,288 bytes. It five I/O used for LEDs there are still four more digital pins, the two UART pins, and an ADC input.

Programming Options: esptool

Arduino will overwrite NodeMCU but that’s easy to reflash. I followed [cnlohr’s] direct programming guide to write the binary using esptool. Both this method and the Arduino method are directly programming the EEPROM on the module. This is exactly the same method you’d use if you wanted to develop natively using the Espressif or the Open Source SDKs. Here’s the commands I used to reflash the NodeMCU firmware:

sudo python esptool.py --port /dev/ttyUSB0 write_flash 0x0000 /home/mike/Downloads/nodemcu_latest.bin

Get the NodeMCU binary from their “latest” folder of github repo.

Conclusion

“Buy as many of these as [Phil] will make for us.” That’s what I’ve asked [Julian], the Hackaday Store manager to do. You should be able to get the Hackaday black version of this in a few weeks. Adafruit is currently sold out but I’m sure they’re racing to remedy this.

These are amazing little boards. The price of $9.95 is crazy considering what you get for it. I’m talking about the entire ecosystem which gives you multiple flavors of programming environments. Adafruit has done a lot to contribute to the code and knowledge base here, but a mammoth portion of this is community developed and I think coming in low on the price is one more way Adafruit has chosen to be a good guy in this ecosystem. The board has a ton of I/O for what it is, and if that’s not enough just, implement I2C, SPI, or UART to couple a beefy uC to the connectivity this one brings to the party. I see zero downside on this board. It’s as close to perfect as you can get.


Filed under: Arduino Hacks, Hackaday Columns, reviews

Arduino is one of those boards that has become synonymous with hacking and making. Since its introduction in 2005, over 700,000 official Arduino boards have been sold, along with untold millions of compatible and clone boards. Hackers and makers around the world have found the Arduino platform a cheap and simple way to get their projects off the ground. This weeks Hacket focuses on some of the best Arduino based projects we’ve found on Hackday.io!

drawingbot[Niazangels] gets the ball – or ballpoint pen – rolling with Roboartist, a robot which creates line drawings. Roboartist is more than just a plotter though. [Niazangels] created a custom PC program which creates line drawings from images captured by a webcam. The line drawings are converted to coordinates, and sent to an Arduino, which controls all the motors that move the pen. [Niazangels] went with Dynamixel closed loop servo motors rather than the stepper motors we often see in 3D printers.

tape[Peter Edwards] is preserving the past with Tapuino, the $20 C64 Tape Emulator. Plenty of programs for the Commodore 64, 128, and compatibles were only distributed on tape. Those tapes are slowly degrading, though the classic Commodore herdware is still going strong. Tapuino preserves those tapes by using an Arduino nano to play the files from an SD card into the original Datasette interface. [Peter] also plans to add recording functionality to the Tapuino, which will make it the total package for preserving  your data. All that’s missing is that satisfying clunk when pressing the mechanical Play button!

infinity

[Dushyant Ahuja] knows what time it is, thanks to his Infinity Mirror Clock. This clock tells time with the help of some WS2812B RGB LED. [Dushyant] debugged the clock with a regular Arduino, but when it came time to finish the project, he used an ATmega328 to create an Arduino compatible board from scratch. Programming is easy with an on-board Bluetooth module. [Dushyant] plans to add a TFT lcd which will show weather and other information when those power-hungry LEDs are switched off.

alarm2[IngGaro] built an entire home alarm system with his project Arduino anti-theft alarm shield. [IngGaro] needed an alarm system for his home. That’s a lot to ask of a standard ATmega328p powered Arduino Uno. However, the extra I/O lines available on an Arduino Mega2560 were just what the doctor ordered. [IngGaro] performed some amazing point-to-point perfboard wiring to produce a custom shield that looks and works great! The alarm can interface with just about any sensor, and can be controlled via the internet. You can even disarm the system through an RFID keycard.

Want MORE Arduino in your life? Check out our curated Arduino List!

That’s about all the millis()  we have for this weeks Hacklet. As always, see you next week. Same hack time, same hack channel, bringing you the best of Hackaday.io!


Filed under: Arduino Hacks, Hackaday Columns


  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook