Piccolino Design Background
When we designed the Piccolino, we had a specific set of goals in mind. We wanted a product that could be used by young inspired minds, as well as professional engineers. From classrooms to commercial products. Our focus was more on the functionality and affordability and less on the esthetics (although we think we did pretty well on that too).
We could have easily added specialized hardware, or an injection molded case, but all of those options would have driven the price-point up, and in the end, that would have defeated our primary goal. Affordability.
Here are the key guidelines that we used when designing Piccolino:
- It had to be a self-contained unit without the need to stack a “shield” to use it.
- It had to have a SCREEN, SD STORAGE and WIFI capability (at least).
- It had to be easy to use and leverage existing frameworks and tools known and supported by the community.
- It had to have acceptable performance to be used in real world applications.
- It had to be expandable via I2C and SPI channels and retain as many original I/O as possible.
- It had to be an Open Source and Open Hardware product. Something that anyone could understand not only by learning the software function names, but from seeing how it is all linked together, peripherals and all.
With the above guidelines, after many months of testing and a few thousand dollars of failed designs later, Piccolino was born.
Piccolino is the perfect harmony of compromises. Its current specifications as of April 2015 are as follows:
- CPU: MEGA328p-AU
- Frequency: 16 MHz
- RAM: 2Kb (some used by the bootloader)
- ROM: 32Kb (some used by the bootloader)
- VCC: 3.3v direct, or 3.3-12v (14vmax) via the VIN input
- Total digital I/O: 15 (shared, see below)
- Analog I/O: 3
- Other: I2C & SPI bus
- 128×64 OLED low power display
- 8266 WIFI 802.11 b/g/n with nodeMCU loaded
- 32KB SPI SRAM
- uSD CARD SLOT
- 2 channel passive TOUCH interface
Enclosure: 3D Printed enclosure (open source)
The Piccolino micro controller is a derived open source design from the Arduino Pro Mini “concept” therefore you program it as if it was a standard Arduino Pro Mini.
To do this, launch your IDE (ERW preferred) and select “Arduino Pro Mini 16Mhz/5v” under ‘Tools’->’Boards’.
The Piccolino FTDI programmer, takes care of voltage regulation down to 3.3v so don’t worry about the ‘5V’ part in the device selection list in your IDE.
NOTE: If you’re using another (not Piccolino specific) FTDI programmer, you must ensure that it’s set to 3.3v and not 5v. Powering the Piccolino directly to 5v may damage its peripherals (permanently).
Upon startup, the WIFI peripheral is disabled. You can program the Piccolino as you would a normal Arduino Pro Mini, using all available ports (refer the diagram above). The WIFI peripheral is turned on automatically upon including the Piccolino_WIFI library and executing its begin function. You can also enable or disable the WIFI module by toggling Piccolinos A3 (not exported analog port 3) pin. The communication between the Piccolino’s main CPU and the WIFI module is done using the SoftwareSerial library using pin 7 (PD6) and 8 (PD8). During WIFI operation these pins should not be used by your circuit.
Please NOTE: You must provide 5-14V and 300mA (at least) to the carrier board (or to the Piccolino VIN pin) in order for the WIFI module to work – WIFI comms can draw up to 250mA and the FTDI programmer alone does not provide enough current.
The I2C OLED display is enabled by including the Piccolino_OLED or the Piccolino_OLED_SRAM library. The OLED module requires a 1K buffer to store its video memory. While the Piccolino_OLED library is faster and suitable for animations it also uses 1KB or the Piccolino’s precious memory. For most application, you should use the Piccolino_OLED_SRAM which uses 1K of the 32K expansion SRAM and only 128 bytes of actual local memory. Once you include the appropriate library, you initialize it by calling the “begin” function (see included examples). The OLED uses pin 1 (A4) and 2 (A5) as these are dedicated for I2C communication on the Mega 328p CPU.
32K SRAM Expansion
Another useful feature of Piccolino is the inclusion of an additional 32KB of memory as an SPI Static RAM (SRAM). You can use it to store temporary data, images, serial buffers or video buffers and more. The 32KB SPI RAM has its Chip Select (CS) connected to pin 9 (PD8) of the Piccolino, therefore when creating projects which uses the 32KB SRAM, you should avoid using this pin. If your project does not access the 32KB SRAM, you are free to use this pin for whatever other purpose as normal.
The two channel passive touch interfaces located on the front panel uses the internal pin 2 as well as pin 3 and 4 of the Piccolino’s I/O. Both pin 4 (PD3) and pin 5 (PD4) have two 4.5 MOhm resistors connected to the internal (not exported) pin PD2 to create the passive touch feedback. To use this feature, you will need to include the CapacitiveSensor library. Try the examples to familiarize yourself with it. If you do not required TOUCH in your projects, you can simply use pin 2 and 3 as normal. While the 4.5MOhm resistors should not interfere in most situations you may want to set the internal digital pin PD2 as an INPUT to avoid possible interference.
The integrated SPI SD card peripheral supports uSD cards of various sizes (note that the standard SD library only supports up to 4GB cards and you will need to use the SdFat library to take advantage of larger uSD cards). The SD card chip select is connected to pin 6 (PD5) of the Piccolino I/O therefore if your project uses the SD card (loggers etc) you should not use this pin for any other purpose.
Included Lua scripts
Piccolino WIFI module comes pre-loaded with nodeMCU version 0.9.5 (nodemcu_20150213). It contains three basic scripts to get your started with your WIFI application programming.
STpicoWIFI.lua – This script allows you to write sketches and connect to an existing access point (like your home WIFI).
APpicoWIFI.lua – Use this script to transform Piccolino into an access point and connect to it using a computer or mobile device.
chipid.lua – This one line script simply prints out the serial number of your WIFI module. It is used when accessing the piccolino.io gateway later in 2015.
Creating WIFI applications
The best way to learn about the two main WIFI modes (STATION & ACCESS POINT) is to execute the include examples within the WIFI library (on GitHub). The examples piccolino_access_point and piccolino_station demonstrate how to incorporate WIFI commands within your sketches. Feel free to modify the examples and the Lua scripts to suit your needs.
If you change and add improvements the libraries (any of the Piccolino libraries) we would like to ask you to submit a zipped copy to us by emailing it to: firstname.lastname@example.org. Upon review, we will include any improvements to future library releases so that that the whole community can benefits from a shared effort.
Piccolino header pin-out description
|1||A4||Shared with I2C SDA|
|2||A5||Shared with I2C SCL|
|3||GP0||WIFI module (ESP8266) GP0 port|
|4||PD3||Shared with left channel touch interface|
|5||PD4||Shared with right channel touch interface|
|6||PD5||Shared with integrated SD card slot|
|7||PD6||Shared with WIFI RX serial comms|
|8||PD7||Shared with WIFI TX serial comms|
|9||PD8||Shared withg integrated 32KB SPI RAM|
|12||PD11||Shared with SPI bus|
|13||PD12||Shared with SPI bus|
|14||PD13||Shared with SPI bus|
|15||A0||Not shared – Digital or Analog port 0|
|16||A1||Not shared – Digital or Analog port 1|
|17||A2||Not shared – Digital or Analog port 2|
|20||VIN||Voltage In (3.3-13.5v)|
Maps & Diagrams
WIFI application writing techniques
While we know that there are many ways to write applications on micro-controllers, here are some recommendation to get the most out of your Piccolino’s hardware when writing WIFI applications.
Your Piccolino has two main processors. The MEGA328p which manages your I/Os and the ESP8266 which manages your WIFI communication/connection and related functions.
Your main WIFI processing is handled by the Lua scripts in the ESP8266. You can use the sample scripts included in the distribution to handle most of day-to-day operations such as turning on and off switches or sending data to a server using the digital or analog I/Os but you may want to expand on their functions.
The communication between the WIFI module and the MEGA328p happens over a software serial channel therefore the messaging between the two devices should be kept as short as possible to avoid overrun errors.
It is not a good practice to process WIFI data (like string manipulation) on the MEGA328p as this will yield overhead and less efficient results.
Parsing and manipulating incoming WIFI data should be done on the WIFI module with the Lua scripts, freeing the MEGA328p in the Piccolino to manage the I/Os OLED screen etc…
A typical application may connect to a website and wait for input from it (like a button-press). In this instance the Lua script on the WIFI module will parse the incoming request with its powerful built-in functions and send a simple message to the MEGA328p over the serial channel as (a=1, b=0 etc). The MEGA328p in turn would interpret the commands and acts on its peripherals accordingly.
Likewise, if you need to send messages to a server, you would write the function on the WIFI module using the Lua IDE (ESPlorer) and call that function from the MEGA328p letting the WIFI module do all the heavy work and freeing the MEGA328p for other processing.
Using this technique, will yield a better performing device taking advantage of both processors at the same time.
Please see the include examples in the Piccolino_WIFI library on how to process signals. More resources are available at the nodeMCU official site including the API with scripts examples and command lists.
Check our forums for more examples and other expert advice.