Showing posts with label Raspberry Pi. Show all posts
Showing posts with label Raspberry Pi. Show all posts

Interface MQ gas sensor modules to 3.3V development boards

 Posted by:   Posted on:    No comments

Sensors from MQ family are tin dioxide smoke and gas detectors with analog output. Tin dioxide changes its resistance when exposed to gases, but it has to be heated. This is why these sensors have a heater resistor made of nichrome wire. MQ sensors are not suitable for battery powered devices since the heater requires a lot of current. In a previous post I took an MQ-2 module, changed some resistors on its PCB and interfaced it to Arduino.

Let's explore the possibilities of interfacing such modules to 3.3 V development boards. There are advantages like possibility of IoT integration, higher ADC resolution and more computing power on 32-bit architecture. There is however an... analog issue. When exposed to high concentrations of gas, the voltage across load resistor (RL) will go higher than 3.3 V. This could damage the ADC. We'll see in this post methods of scaling down the output voltage on load resistor.

MQ-2 readings with Raspberry Pi Pico

Volume and media control buttons with Raspberry Pi Pico

 Posted by:   Posted on:    7 comments

A while ago I used STM32 bluepill board to emulate a consumer control device that would allow me to control volume and media playing on PC, over USB. Implementation wasn't very easy, since I had to modify an existing library to add support for consumer control HID class. Nevertheless, I succeeded and the details and my library can be found in this post.

Meanwhile, a new cheap development board appeared. It is the Raspberry Pi Pico which has native USB port. I thought this could be used as well to emulate a keyboard, mouse or consumer control HID. This board can be programmed in C/C++ or MicroPython. Since I wasn't willing to install the C/C++ development kit, I attempted to use MicroPython. Unfortunately, it lacks required modules for USB HID and rotary encoder. Then I found about CircuitPython, which is based on MicroPython and is supported by Adafruit. At its current version, it is bundled with rotary encoder module and, for USB HID, you can use Adafruit HID library.

Volume and media control buttons with Raspberry Pi Pico

Media control device built on breadboard

Generate square wave signal with Raspberry Pi Pico PIO

 Posted by:   Posted on:    10 comments

I recently bought a couple of Raspberry Pi Pico microcontroller boards. Although I read about the PIO peripheral, I didn't pay too much attention to it. However, it seems to be an interesting peripheral that I haven't seen before on other microcontrollers. It is supposed to be a versatile I/O interface which will allow you to implement custom serial or parallel protocols in a better way than bitbanging a GPIO pin.

Actually, the PIO is made of two blocks, each containing four state machines. These are individual processing units optimized for I/O, with "a focus on determinism, precise timing, and close integration with fixed-function hardware" as the datasheet claims. Sounds good, doesn't it? This is until you get to program these "machines" in... assembly language. I'm totally new to this, so in this post I will generate a square wave signal using the PIO.

Generate square wave signal with Raspberry Pi Pico PIO

Set up Raspberry Pi Pico for MicroPython

 Posted by:   Posted on:    2 comments

Raspberry Pi Pico is a newly released microcontroller board from Raspberry Pi Foundation. Since it is quite powerful and versatile, it may prove an excellent alternative to Arduino Nano or STM32 Blue Pill. Having a similar form factor to those two development boards, the Raspberry Pi Pico can be bought for about 4 EUR (5 USD). Keep in mind that this is the price of the original product, from most approved resellers, much lower than an official Arduino Nano or the retired Maple Mini from Leaflabs (the “blue pill” is based on it).

But there is more to it than the lower cost. The microcontroller has a dual core CPU running at a frequency up to 133 MHz with 264 kB of SRAM and 2 MB of flash. With 26 GPIO pins and native USB device and host support, Raspberry Pi Pico seems better than Arduino Nano and STM32 Blue Pill. It is definitely missing the kind of connectivity you get with ESP chips (WiFi and/or bluetooth), that’s why I’m not comparing it to the ESP8266 or ESP32. Even though, it is a good choice for projects that do not require such connectivity. Nevertheless, a LAN or Bluetooth connectivity module may be interfaced to Raspberry Pi Pico when needed.

Set up Raspberry Pi Pico for MicroPython