Page 1
Instructions ONTROLLER ARNING This product is for switching low voltage DC and AC only. Do NOT connect to domestic 110 or 220V AC. Note: Raspberry Pi Pico not included Instructions version 1a.
ABLE OF ONTENTS Warning........................2 Using the Pico Controller..................3 Downloading the Examples..................4 Getting Started......................5 Using the Solid State Relays..................10 Warning: Low Volatge ONLY................10 Example 1. Buzzer Test...................12 Example 2. Relay Menu..................13 Example 3. Egg Timer.....................15 Example 4. Thermostat....................18 The picocontroller Module..................21 The picocontroller.gui Module................23...
Access to other GPIO (General Purpose Input Output) pins • Extensive MicroPython modules and example code • Mounting holes The Pico Controller also has a small OLED display and four push switches that can provide a simple user interface for your project. Page 3...
Page 4
Pico GPIO (General Purpose Input Outputs) that are not used by the display, switches, relays or built-in buzzer can also be accessed using the header pins on the board, allowing sensors and other devices to be attached. A Raspberry Pi Pico (not included) fits into a socket on the board, allowing different variants of the Pico to swapped in and out.
$ git clone https://github.com/monkmakes/picocontroller.git With the extracted archive, you will find folders called: • examples – MicroPython examples for the Pico Controller • src – modules in MicroPython to use in projects Page 5...
Although you can program Raspberry Pi Picos in a variety of programming languages, in these instructions we have settled on the most popular of these (MicroPython). To simplify access to the PicoController board, MonkMakes have developed some code modules in MicroPython. Plugging and unplugging a Pico If your Pico was supplied without header pins attached, you will need to solder these on yourself (see Appendix A).
Page 7
Pico's file system before the program will work. To install the modules for the Pico Controller (that you downloaded from Github earlier) onto your Pico, you need to use Thonny.
Page 8
Select the result picocontroller (for the MonkMakes Pico Controller) Click on Install. Don't worry if there is a later version that 0.4. Just install the latest version. Now, when the installation has finished, when you return to the main Thonny window, you should see that there is a lib folder in the files area.
Page 9
The package installation should now be complete and we are ready to experiment with the PicoController board. The Python Shell We can now try out the PicoController from the Python Shell area at the bottom of the Thonny window. Type in these commands (remember >>> is a prompt from MicroPython, you don't have type type it).
Page 10
Notice how I have used short jumper wires and alligator clip leads to connect the relay screw terminals to the DMM. If your DMM has thin probe leads, you may be able to fit them directly into the screw terminal holes. Now try running the following commands to turn Relay A on and off.
Electro-mechanical relays are cheap, but switch slowly and require quite a high current through the coil to activate them. The Pico Controller uses a type of relay called a solid state relay (SSR). Instead of a coil of wire and contacts, the SSRs used in the Pico Controller use an LED and phototransistors all contained within a small package.
Page 12
The output of each relay goes to a 2-way screw terminal, so the relay can be treated just like a switch that happens to be controlled by the Pico Controller. Here's an example of how you might want to wire up some 12V LED strip-lighting, to be switched by the Pico Controller.
The Pico Controller comes with a selection of example programs designed to illustrate the use of the MicroPython modules and the Pico Controller, and to serve as a basis for your own projects. The first if these is called Buzzer Test and can be found in the code download from Github in the examples folder.
2. R XAMPLE ELAY This example (which you will find in the download as examples/relay_menu.py) illustrates the picocontroller.gui package's menu system to control the relays. The menu system uses the display and the four push buttons (we'll refer to them as A to D – left to right).
Page 15
menu = relay_b_submenu menu.draw_menu() if selection == 'back': menu = main_menu menu.draw_menu() if selection == 'relay_A_on': Relay_A.on() if selection == 'relay_A_off': Relay_A.off() if selection == 'relay_B_on': Relay_B.on() if selection == 'relay_B_off': Relay_B.off() sleep(0.1) The menu and submenu are both defined as Python lists, each list item being a dictionary representing one menu option, for example: {'id' : 'relay_B_on', 'label' : 'On'}, The menu has an id that is used to identify the menu option and a label which is...
3. E XAMPLE IMER This example illustrates the use of the picocontroller.gui package's SevenSegDisplay class. The display shows a time in minutes and seconds which can be increased or decreased by pressing buttons B and A respectively. When button C is pressed the countdown starts and when 0 is reached, the buzzer sounds.
Page 17
t.init(mode=Timer.PERIODIC, period=1000, callback=lambda t:update_time()) def update_time(): global mins, secs if not is_running: return if secs == 0: if mins == 0: stop_running() buzzer.on() else: secs = 59 mins -= 1 else: secs -= 1 update_display() def start_running(): global is_running is_running = True def stop_running(): global is_running is_running = False...
Page 18
update_display() There is quite a lot of code here, so you might like to follow along in Thonny. The 3 digit, 7-segment display is defined by the line: time_display = SevenSegDisplay(0, 0, digit_w=20, digit_h=40, num_digits=3) The first two parameters are the x and y coordinates of the top left of the 7-segment display.
To try out this example, you will need to buy and attach one of the popular DS18B20 temperature sensors and connect it to the Pico Controller's GPIO pins. This project illustrates the use of the OLED display to show text and graphics, as well as using the readings for the sensor.
Page 21
The DS18B20 uses the Onewire bus interface which, along with the protocol of the sensor itself, is provided with interfaces with the onewire and ds18x20 modules included with MicroPython. So, no special installation of modules is needed. The Onewire interface is initialised using the line: ow = onewire.OneWire(Pin(ONE_WIRE_PIN, pull=Pin.PULL_UP)) This takes a Pin as it's parameter, and it is here that the pin is defined with it's internal pull-up resistor enabled so that the Onewire bus will work.
HE PICOCONTROLLER ODULE The picocontroller module provides a convenient way of interacting with the physical hardware of the Pico Controller. It provides some variables as well as two classes, Button and Relay. Variables Instances of the class Button for each of the four...
Page 23
milliseconds in the parameter. (Non- blocking) Turn the relay off for off_for(duration) Relay_A.off_for(10000) the number of milliseconds in the parameter. (Non- blocking) Turn the relay on oscillate(period) Relay_A.oscillate(1000) and off with a delay of the number of milliseconds in the parameter.
HE PICOCONTROLLER ODULE The gui module contains a number of classes, for building user interfaces using the OLED display and four navigation buttons. SevenSegDisplay Class This class allows you to simulate 7-segment displays on the display. The position, size and number of digits of the display can all be set.
Page 25
Menu Class The Menu class is pretty well illustrated by the relay_menu.py example. It provides a data-driven way of expressing menus and sub-menus using the OLED display. All the examples in the table below assume the menu_data below: menu_data = [ {'id' : 'relay_A_on', 'label' : 'Relay A on'}, {'id' : 'relay_A_off', 'label' : 'Relay A off'}, {'id' : 'relay_B_submenu', 'label' : 'Relay B >'}...
ULSE IDTH ODULATION The SSRs used in the PicoController are capable of more than just on/off control. They can also be used say to control the brightness of an LED (such as the LED strip-light we mentioned earlier) or the speed of a motor using a process called Pulse Width Modulation or PWM.
Page 27
= int(input('duty (0..65535):')) pwm_Relay_A.freq(f) pwm_Relay_A.duty_u16(d) You will need to attach a load to your Pico Controller, such as the LED lamp of Page 11. When you run the program, you will be prompted for first for the PWM frequency (I suggest 100.
– its not so hard. To keep the pins straight, it is a good idea to push them into the Pico Controller long ends first. This has the added advantage that, once soldered, the Pico will be in the right place, and won't need to be relocated.
B. T PPENDIX ROUBLESHOOTING Problem: The orange power LED in the MonkMakes logo on the Pico Controller does not light. Solution: Check the USB connection, and try a different USB port on your computer. Problem: I can't upload anything onto my Pico, even through the Pico Controller has power indicated by the orange LED being lit.
Page 30
MicroPython. Set the options as shown below, in the variant drop-down, choose your particular type of Pico and then click Install. Problem: I can't tell if the Relay is working. Solution: Attach a DMM in continuity mode as described on Page 9. Page 30...
UPPORT You can find the Product's information page here: https://monkmakes.com/picocontroller including a datasheet for the product. If you need further support, please email support@monkmakes.com. Page 31...
AKES As well as this kit, MonkMakes makes all sorts of kits and gadgets to help with your electronics projects. Find out more, as well as where to buy, here: https://monkmakes.com you can also follow MonkMakes on X as @monkmakes...
OOK BY IMON If you like this product and want to learn more about programming in MicroPython, then you might like Simon Monk's book on the subject. Page 33...
Need help?
Do you have a question about the Pico Controller and is the answer not in the manual?
Questions and answers