Raspberry Pi Pico – Vertical innovation

via Raspberry Pi

Our Chief Operating Officer and Hardware Lead James Adams talked to The MagPi Magazine about building Raspberry Pi’s first microcontroller platform.

On 21 January we launched the $4 Raspberry Pi Pico. As I write, we’ve taken orders for nearly a million units, and are working hard to ramp production of both the Pico board itself and the chip that powers it, the Raspberry Pi RP2040.

Close up of R P 20 40 chip embedded in a Pico board
RP2040 at the heart of Raspberry Pi Pico

Microcontrollers are a huge yet largely unseen part of our modern lives. They are the hidden computers running most home appliances, gadgets, and toys. Pico and RP2040 were born of our desire to do for microcontrollers what we had done for computing with the larger Raspberry Pi boards. We wanted to create an innovative yet radically low-cost platform that was easy to use, powerful, yet flexible.

It became obvious that to stand out from the crowd of existing products in this space and to hit our cost and performance goals, we would need to build our own chip.

I and many of the Raspberry Pi engineering team have been involved in chip design in past lives, yet it took a long time to build a functional chip team from scratch. As well as requiring specialist skills, you need a lot of expensive tools and IP; and before you can buy these things, there is a lot of work required to evaluate and decide exactly which expensive goodies you’ll need. After a slow start, for the past couple of years we’ve had a small team working on it full-time, with many others pulled in to help as needed.

Low-cost and flexible

The Pico board was designed alongside RP2040 – in fact we designed the RP2040 pinout to work well on Pico, so we could use an inexpensive two-layer PCB, without compromising on the layout. A lot of thought has gone into making it as low-cost and flexible as possible – from the power circuitry to packaging the units on to Tape and Reel (which is cost-effective and has good packing density, reducing shipping costs).

“This ‘full stack’ design approach has allowed optimisation across the different parts”

With Pico we’ve hit the ‘pocket money’ price point, yet in RP2040 we’ve managed to pack in enough CPU performance and RAM to run more heavyweight applications such as MicroPython, and AI workloads like TinyML. We’ve also added genuinely new and innovative features such as the Programmable I/O (PIO), which can be programmed to ‘bit-bang’ almost any digital interface without using valuable CPU cycles. Finally, we have released a polished C/C++ SDK, comprehensive documentation and some very cool demos!

A reel of Raspberry Pi Pico boards

For me, this project has been particularly special as I began my career at a small chip-design startup. This was a chance to start from a clean sheet and design silicon the way we wanted to, and to talk about how and why we’ve done it, and how it works.

Pico is also our most vertically integrated product; meaning we control everything from the chip through to finished boards. This ‘full stack’ design approach has allowed optimisation across the different parts, creating a more cost-effective and coherent whole (it’s no wonder we’re not the only fruit company doing this).

And of course, it is designed here in Cambridge, birthplace of so many chip companies and computing pioneers. We’re very pleased to be continuing the Silicon Fen tradition.

A banner with the words "Be a Pi Day donor today"

Get The MagPi 103 now

You can grab the brand-new issue right now online from the Raspberry Pi Press store, or via our app on Android or iOS. You can also pick it up from supermarkets and newsagents, but make sure you do so safely while following all your local guidelines.

magpi magazine cover issue 103

Finally, there’s also a free PDF you can download. Good luck during the #MonthOfMaking, folks! I’ll see y’all online.

The post Raspberry Pi Pico – Vertical innovation appeared first on Raspberry Pi.

Blink RGB LEDs Remotely with MicroMod

via SparkFun: Commerce Blog

The MicroMod ESP32 Blinky Server in action.

The MicroMod ESP32 Blinky Server in action

Do you want to get started with IOT projects? The MicroMod system makes it easy to get connected and coding, no wires necessary! Just pop the MicroMod ESP32 processor into any of our carrier boards, and you’re ready to go! This example demonstrates how to create a simple server on your local WiFi network with endpoints that toggle the six RGB LEDs onboard the MicroMod Input and Display Carrier board, while also logging the LED activity (and other endpoint requests) to the TFT display.

If you haven’t already, you’ll want to follow the hardware setup instructions for both the MicroMod Input and Display board and the ESP32 processor. Additionally, this sketch utilizes the FastLED library to control the onboard RGB LEDs.

APA102 Addressable LED Hookup Guide

Connect, power, and control your APA102 addressable LED strip!

MicroMod ESP32 Processor Board Hookup Guide

A short hookup guide to get started with the SparkFun MicroMod ESP32 Processor Board.

SparkFun MicroMod Input and Display Carrier Board Hookup Guide

A short Hookup Guide to get started with the SparkFun MicroMod Input and Display Carrier Board

Once you’ve got everything set up, enter your WiFi SSID and password into the MMIDesp32BlinkyServer.ino sketch below, and upload it to your MicroMod system. It may take a second, but a confirmation message should pop up on the TFT display once your device is successfully connected. If you don’t see that, try tapping the reset button on the underside of the carrier board. Once you see the message confirming that the server is running, you can toggle the RGB LEDs simply by sending requests to the corresponding endpoint from another device on your network.

/* MMIDesp32BlinkyServer.ino
* Marcus Stevenson @ SparkFun Electronics
 * 
 * This example utilizes the Sparkfun MicroMod Iput and Display carrier board
 * along with the MicroMod ESP32 Processor to create a server on your local
 * wifi network. The endpoints of this sever correspond to the onboard RGB 
 * LEDs, allowing you to toggle them on and off by sending requests to the
 * endpoints from other devices on the same network. The onboard buzzer 
 * will also beep when the server handles requests to each endpoint.
 * 
 * --------------IMPORTANT!---------------------- 
 * make sure to include the ssid and password of your network before uploading!
 * 
 * When your device is successfully connected to your WiFi, a message will
 * be displayed on the TFT display indicating the server is running
 * 
 * LED activity will be logged on the screen
 * call /clearDisplay to empty the screen
 * 
*/
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include <ESPmDNS.h>

#include <HyperDisplay_4DLCD-320240_4WSPI.h>

#include <FastLED.h>

#define PWM_PIN PWM0             // Display pin definitions
#define CS_PIN D0
#define DC_PIN D1
#define SPI_PORT SPI
#define SPI_SPEED 32000000 

#define NUM_LEDS 6              //RGB LED pin definitions
#define DATA_PIN 25
#define CLOCK_PIN 15
CRGB leds[NUM_LEDS];

LCD320240_4WSPI myTFT;          //TFT display declaration

ILI9341_color_18_t defaultColor; //Color for display

const char* ssid = "YOURWIFIHERE";//<----------your wifi here
const char* password = "YOURPASSHERE";//<-------your password here

WebServer server(80);           //server setup on localhost port 80

//led status: 
bool ledStates[] = {false, false, false, false, false, false};

//endpoint handler functions
//ROOT
void handleRoot() {
  beep(250);
  myTFT.println("MicroMod esp32 blinkyServer");
  newLine();
  myTFT.print("Endpoints:");
  newLine();
  myTFT.print("/led0, /led1, /led2, /led3, /led4, /led5");
  newLine();
  myTFT.print("/clearDisplay");
  newLine();
  server.send(200, "text/plain", "micromod esp32 root");
}
//not found
void handleNotFound() {
  beep(250);
  myTFT.print("Endpoint not found.");
  newLine();
  String message = "File Not Found\n\n";
  message += "URI: ";
  message += server.uri();
  message += "\nMethod: ";
  message += (server.method() == HTTP_GET) ? "GET" : "POST";
  message += "\nArguments: ";
  message += server.args();
  message += "\n";
  for (uint8_t i = 0; i < server.args(); i++) {
    message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
  }
  server.send(404, "text/plain", message);
}
//LED endpoint handler functions
void handleLED0(){
  toggleLED(0);
  beep(250);
}
void handleLED1(){
  toggleLED(1);
  beep(250);
}
void handleLED2(){
  toggleLED(2);
  beep(250);
}
void handleLED3(){
  toggleLED(3);
  beep(250);
}
void handleLED4(){
  toggleLED(4);
  beep(250);
}
void handleLED5(){
  toggleLED(5);
  beep(250);
}
//clear display endpoint handler
void handleClearDisplay(){
  for (int i=0; i<6; i++){//turns LEDs off just in case
    offLED(i);
  }
  myTFT.clearDisplay();
  setLine(1);
  myTFT.println("Connected to ");
  myTFT.print(ssid);
  newLine();
  myTFT.println("IP address: ");
  myTFT.print(WiFi.localIP());
  newLine();
  myTFT.print("MicroMod Esp32 Blinky Server Running!");
  newLine();
  server.send(200, "text/plain", "Display Cleared");
  beep(250);
}
//LED 
void toggleLED(int ledNum){
  if (ledStates[ledNum] == false){
    String sendStr = "LED ";
    sendStr += ledNum;
    sendStr += " ON";
    myTFT.print(sendStr);
    newLine();
    server.send(200, "text/plain", sendStr);
    onLED(ledNum);
  }else{
    String sendStr = "LED ";
    sendStr += ledNum;
    sendStr += " OFF";
    myTFT.print(sendStr);
    newLine();
    server.send(200, "text/plain", sendStr);
    offLED(ledNum);
  }
}
void onLED(int ledNum){
  leds[ledNum] = CRGB::Red;
  ledStates[ledNum] = true;
  FastLED.show();
}
void offLED(int ledNum){
  leds[ledNum] = CRGB::Black;
  ledStates[ledNum] = false;
  FastLED.show();
}
//Text Cursor helper functions
int currentLine = 1;
void newLine(){
  int yVal = currentLine*8;
  myTFT.setTextCursor(0, yVal);
  currentLine ++;
}
void setLine(int lineNum){
  lineNum --;
  int yVal = lineNum*8;
  myTFT.setTextCursor(0, yVal);
  currentLine = lineNum+1;
}
//buzzer beep
void beep(int btimeMS){
  ledcWriteTone(0, 500);
  delay(btimeMS);
  ledcWriteTone(0,0);
}

void setup(void) {
  ledcAttachPin(12,0); //ESP32 Buzzer setup

  //FastLED setup for RGB LEDs
  FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, BGR>(leds, NUM_LEDS);// BGR ordering is typical
  FastLED.setBrightness(25);
  for (int i=0; i<6; i++){//turns LEDs off just in case
    offLED(i);
  }
  //TFT display initialization 
  myTFT.begin(DC_PIN, CS_PIN, PWM_PIN, SPI_PORT, SPI_SPEED);
  myTFT.setInterfacePixelFormat(ILI9341_PXLFMT_18);
  myTFT.clearDisplay();
  //set window color to white
  defaultColor = myTFT.rgbTo18b( 255, 255, 255 );
  myTFT.setCurrentWindowColorSequence((color_t)&defaultColor);

  //WiFi connection
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);

  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
  myTFT.println("Connected to ");
  myTFT.print(ssid);
  newLine();
  myTFT.println("IP address: ");
  myTFT.print(WiFi.localIP());
  newLine();

  //server endpoints
  server.on("/", handleRoot);

  server.on("/led0", handleLED0);
  server.on("/led1", handleLED1);
  server.on("/led2", handleLED2);
  server.on("/led3", handleLED3);
  server.on("/led4", handleLED4);
  server.on("/led5", handleLED5);
  server.on("/clearDisplay", handleClearDisplay);

  server.onNotFound(handleNotFound);

  server.begin();
  myTFT.print("MicroMod Esp32 Blinky Server Running!");
  newLine();
}

void loop(void) {
  server.handleClient();
}

To send a request, open a tab in a browser (the devices must be connected to the same network) and type the IP address listed on your TFT display, followed by your desired endpoint path, into the address bar. Your IP will be different from mine, but for example:

10.0.0.241/led0

If everything is set up properly, the bottommost LED on the carrier board should light up red when you hit enter in your browser. Your browser, and the MicroMod TFT display, should read “LED 0 ON.” To see a list of all available endpoints, simply call the root directory:

YOUR.IP.ADD.HERE/

And to clear the display once it fills up, try:

YOUR.IP.ADD.HERE/clearDisplay.

This simple example can easily be adapted to remotely interact with your projects over your local WiFi network. The provided code can be modified to blink the RGB LEDs different colors, and additional endpoints could be added to return data from Qwiic sensor breakouts or whatever your IOT project requires!

comments | comment feed

Make an animated sign with Raspberry Pi Pico

via Raspberry Pi

Light up your living room like Piccadilly Circus with this Raspberry Pi Pico project from the latest issue of HackSpace magazine. Don’t forget, it’s not too late to get your hands on our new microcontroller for FREE if you subscribe to HackSpace magazine.

HUB75 LED panels provide an affordable way to add graphical output to your projects. They were originally designed for large advertising displays (such as the ones made famous by Piccadilly Circus in London, and Times Square in New York). However, we can use a little chunk of these bright lights in our projects. They’re often given a ‘P’ value, such as P3 or P5 for the number of millimetres between the different RGB LEDs. These don’t affect the working or wiring in any way.

We used a 32×32 Adafruit screen. Other screens of this size may work, or may be wired differently. It should be possible to get screens of different sizes working, but you’ll have to dig through the code a little more to get it running properly.

The most cost- effective way to add 1024 RGB LEDs to your project

The most cost- effective way to add 1024 RGB LEDs to your project

The protocol for running these displays involves throwing large amounts of data down six different data lines. This lets you light up one portion of the display. You then switch to a different portion of the display and throw the data down the data lines again. When you’re not actively writing to a particular segment of the display, those LEDs are off.

There’s no in-built control over the brightness levels – each LED is either on or off. You can add some control over brightness by flicking pixels on and off for different amounts of time, but you have to manage this yourself. We won’t get into that in this tutorial, but if you’d like to investigate this, take a look at the box on ‘Going Further’.

The code for this is on GitHub (hsmag.cc/Hub75). If you spot a way of improving it, send us a pull request

The code for this is on GitHub. If you spot a way of improving it, send us a pull request

The first thing you need to do is wire up the screen. There are 16 connectors, and there are three different types of data sent – colour values, address values, and control values. You can wire this up in different ways, but we just used header wires to connect between a cable and a breadboard. See here for details of the connections.

These screens can draw a lot of power, so it’s best not to power them from your Pico’s 5V output. Instead, use a separate 5V supply which can output enough current. A 1A supply should be more than enough for this example. If you’re changing it, start with a small number of pixels lit up and use a multimeter to read the current.

With it wired up, the first thing to do is grab the code and run it. If everything’s working correctly, you should see the word Pico bounce up and down on the screen. It is a little sensitive to the wiring, so if you see some flickering, make sure that the wires are properly seated. You may want to just display the word ‘Pico’. If so, congratulations, you’re finished!

However, let’s take a look at how to customise the display. The first things you’ll need to adapt if you want to display different data are the text functions – there’s one of these for each letter in Pico. For example, the following draws a lower-case ‘i’:

def i_draw(init_x, init_y, r, g, b):
    for i in range(4):
        light_xy(init_x, init_y+i+2, r, g, b)
    light_xy(init_x, init_y, r, g, b)

As you can see, this uses the light_xy method to set a particular pixel a particular colour (r, g, and b can all be 0 or 1). You’ll also need your own draw method. The current one is as follows:

def draw_text():
    global text_y
    global direction
    global writing
    global current_rows
    global rows

    writing = True
    text_y = text_y + direction
    if text_y > 20: direction = -1
    if text_y < 5: direction = 1
    rows = [0]*num_rows
    #fill with black
    for j in range(num_rows):
    rows[j] = [0]*blocks_per_row

    p_draw(3, text_y-4, 1, 1, 1)
    i_draw(9, text_y, 1, 1, 0)
    c_draw(11, text_y, 0, 1, 1)
    o_draw(16, text_y, 1, 0, 1)
    writing = False

This sets the writing global variable to stop it drawing this frame if it’s still being updated, and then just scrolls the text_y variable between 5 and 20 to bounce the text up and down in the middle of the screen.

This method runs on the second core of Pico, so it can still throw out data constantly from the main processing core without it slowing down to draw images.

Get HackSpace magazine – Issue 40

Each month, HackSpace magazine brings you the best projects, tips, tricks and tutorials from the makersphere. You can get it from the Raspberry Pi Press online store, The Raspberry Pi store in Cambridge, or your local newsagents.

Each issue is free to download from the HackSpace magazine website.

When you subscribe, we’ll send you a Raspberry Pi Pico for FREE.

A banner with the words "Be a Pi Day donor today"

The post Make an animated sign with Raspberry Pi Pico appeared first on Raspberry Pi.

Ultra low power LED flasher using the Padauk PFS154

via Dangerous Prototypes

Low power LED flasher on PFS154:

Flashing a LED is certainly among the first set of problems any burgeoning electronics specialist is tackling, may it be by using an ancient NE555 or, more recently, a microcontroller to control the LED. As it turns out, we can turn any trivial problem into a harder one by changing its constraints.

More details on Tim’s blog.

esp32s2Stick

via Dangerous Prototypes

Luca Dentella designed and built a USB stick powered by esp32-s2 chip, the esp32s2Stick:

esp32s2Stick is a USB device based on the esp32-s2 chip by Espressif. Thanks to the presence of an USB OTG interface, it is possible to program the chip to act as a USB peripheral (mass storage device, CDC…) and to upgrade the firmware through USB (DFU, Device Firmware Upgrade).
In addition to the basic circuit needed to run the WROVER module, esp32s2Stick offers an RGB LED and a socket for MicroSD cards.

See the full post at lucadentella.it. Project files are available on GitHub.

Announcing the Arduino IDE 2.0 (beta)

via Arduino Blog

The Arduino IDE is the well-known software we all use to program our boards. Its development started in 2005 based on the graphical interface of the Processing project and has never stopped since. During these years, countless hours of development by the Arduino team with the help of a vibrant community made the Arduino IDE the de facto standard for electronics prototyping. Thanks to an extensible framework based on modular board support packages, the IDE supports more than 1,000 official and non-official boards; it’s translated in 66 languages, mentioned by more than 3,000 books, and is still growing: during the last year, it was downloaded more than 39 millions of times. More than ever.

First off, a big thank you to the Arduino community that makes development possible with donations and — even more important — by buying original Arduino boards: we use your money to pay the developers that work daily on the Arduino open source software for the benefit of everyone. Keep supporting our work!

The path from a simple IDE to an advanced IDE

While the Arduino IDE provides a simple and clear interface that is ideal for the novice users, the more advanced users often report that the editing capabilities are a bit limited compared to modern editors. This includes features like code indentation, block folding, auto-closing brackets, regular expression search and replace, comment toggling. In addition to this, many users have been asking for live debugging, i.e. the ability to run code on an attached board and stop it at a given line to check the contents of variables, memory and registers.

The IDE 1.x is developed in Java, and its monolithic codebase makes it difficult to implement such features. Java is also becoming an obsolete technology for desktop applications and is being phased out by newer operating systems and app stores, which forces us to spend time on working around compatibility issues.

In 2018 we started to refactor the toolchain by announcing a big game changer: arduino-cli, the Arduino command line tool written in Golang that exposes all the core functionalities of the IDE, providing advanced users with a flexible tool they can integrate into their professional IDE of choice. Since then, we maintain and improve arduino-cli on a daily basis (try it now if you haven’t!).

In 2019 we announced the alpha release of a new IDE built on top of arduino-cli and based on a modern software stack (Theia and Electron) under the code name of “Arduino Pro IDE” and we got a lot of positive feedback about it. 2020 has been a busy development year, and a dedicated team of developers has been working behind the scenes to bring the new IDE from a proof-of-concept to a fully functional tool.

The time has come: please welcome the Arduino IDE 2.0 (beta)

We’re pleased to announce that as of today the Arduino IDE 2.0 beta is available for download and its code repositories become open source. It carries a modern editor and provides a better overall user experience thanks to a responsive interface and faster compilation time. Don’t be afraid of trying it today: the upgrade will be frictionless as the interface will look very familiar. But let’s see some of the goodies you’ll find.

While typing, the editor suggests the autocompletion of variables and functions according to the libraries you included:

When right-clicking on a variable or a function, a contextual menu will provide navigation shortcuts to jump to the line (and file) where they are declared:

See this page to learn more about the new editing tools.

But there’s another big feature in the new IDE: a live debugger that allows you to run your code interactively on a board and inspect its execution without writing tens of “Serial.println()” statements. Just fire the debug panel, set breakpoints where you want to pause the execution and inspect the content of variables. Oh, you can even change the content of variables on the fly and resume execution!

As of today, the debugger supports all the Arduino boards based on the SAMD and Mbed platforms (MKR family, Nano 33 IoT, Nano 33 BLE, Portenta, Zero). Maintainers of Arduino cores for third-party boards can add support for debugging by adding the relevant configuration parameters; a technical guide for this is coming. You’ll need to connect a debugging probe such as the Segger J-link to the JTAG pins on the board and you’ll be ready to go.

The new IDE is based on the Eclipse Theia framework, which is an open source project based on the same architecture as VS Code (language server protocol, extensions, debugger). The front-end is written in TypeScript, while most of the backend is written in Golang.

Try it now!

We need your help to test the new IDE. We want to make it perfect and bug-free, so do not hesitate to download it now and join the discussion in the forum! Ready to get started? Follow along with our tutorials here.