element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Andy Clark's Blog Picon Zero on the Pi with NodeJS
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Workshopshed
  • Date Created: 18 Jul 2017 8:13 AM Date Created
  • Views 981 views
  • Likes 9 likes
  • Comments 6 comments
  • raspberry pi zero
  • nodejs
Related
Recommended

Picon Zero on the Pi with NodeJS

Workshopshed
Workshopshed
18 Jul 2017

I've used the Picon Zero board from 4Tronix before when I was working on the Dragon Detector project. It is the same size as the Pi Zero and can drive 6 outputs, 4 inputs and 2 motors via H-Bridges. So it seemed a good option for driving my latest car project.

image

Prepare the Pi

The Picon Zero runs via I2C so you need to run raspi-config and enable I2C in the settings.

 

It's also worth updating the apt-get cache as we'll be installing some software.

sudo apt-get update

 

Install tools

This step is optional but it's good to have some tools for diagnosing what's going on.

 

sudo apt-get install i2ctools

 

This then allows you to see what I2C adapters are available. This will be different on early pi but most modern Pi are have the I2C bus numbered as "1"

sudo i2cdetect -l

 

That will return something like:

i2c-1   i2c             bcm2835 I2C adapter                     I2C adapter

 

Then the scan command will detect if the board is plugged in and can be detected.

sudo i2cdetect -r 1

 

It will return something like the following:

 

WARNING! This program can confuse your I2C bus, cause data loss and worse!

I will probe file /dev/i2c-1 using read byte commands.

I will probe address range 0x03-0x77.

Continue? [Y/n] Y

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: -- -- 22 -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- --

 

Install software

First I removed any existing versions of node and npm (the node package manager)

sudo apt-get remove --purge npm node nodejs

 

Then I used an excellent script from Steven de Salas to install the latest version of node.

wget -O - https://raw.githubusercontent.com/sdesalas/node-pi-zero/master/install-node-v.last.sh | bash

 

After checking the versions I installed an I2c libraries so that Node could communicate with the I2C bus

node -v
npm -v
npm install i2c

 

Porting the Picon Zero code to Node

I tried out the "jiphy" tool to see if I could automate some of the code migration. That seemed to work ok with the smaller samples but it choked on the main library. So I ended up porting the code by hand. So far I've just done the version funtion as that allows me to see that communication is happening. I've also tried to mimic the Python version so that people can easily work with either. Here's the two versions side by side.

 

PythonNodeJS

#! /usr/bin/env python

# GNU GPL V3
# Test code for 4tronix Picon Zero

import piconzero as pz

pz.init()
vsn = pz.getRevision()
if (vsn[1] == 2):
    print("Board Type:", "Picon Zero")
else:
    print("Board Type:", vsn[1])
print("Firmware version:", vsn[0])
print()
pz.cleanup()

#!/usr/bin/env node

// GNU GPL V3
// Test code for 4tronix Picon Zero

var pz = require('./piconzero');

pz.init();
var vsn = pz.getRevision();
if  (vsn[1] == 2) {
    console.log("Board Type:", "Picon Zero")
}
else { 
    console.log("Board Type:", vsn[1])
}
console.log("Firmware version:", vsn[0])
console.log();
pz.cleanup();

 

So far it's a proof of concept but it seems to be working reliably so I can't see any problems with porting the rest.

 

Watch this space https://github.com/Workshopshed/PiconZero/tree/master/NodeJS

 

Reference

https://blog.miniarray.com/installing-node-js-on-a-raspberry-pi-zero-21a1522db2bb

https://github.com/sdesalas/node-pi-zero

https://github.com/timothycrosley/jiphy/blob/develop/README.md

Using the I2C Interface – Raspberry Pi Projects

https://www.npmjs.com/package/i2c

  • Sign in to reply

Top Comments

  • Workshopshed
    Workshopshed over 8 years ago +3
    I tested the Digital I/O using an RGB LED, that seems to be working fine. players.brightcove.net/.../index.html
  • mconners
    mconners over 8 years ago +1
    Nice Workshopshed . Neat stuff. Mike
  • Workshopshed
    Workshopshed over 8 years ago +1
    For the motor test, I swapped the power to come from the external USB. Even with that configured I could not get motion from my old motor. I swapped to a motor that I'd created by modifying a micro-servo…
Parents
  • DAB
    DAB over 8 years ago

    Nice post Andy,

     

    The board looks interesting and it looks like the control over I2C well supported.

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Workshopshed
    Workshopshed over 8 years ago in reply to DAB

    Yes, I2C means that you could control it from most systems. I've already done it with 2 now and it would not be hard to drive it from an arduino. I discovered today that the "brain" of the board can also be reprogrammed via a seria to usb connection and the Arduino IDE so if you needed 10 inputs or outputs you could probably do that too.

     

    An example of running the board from the Microbit

     

    micro:bit and the Picon Zero

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • Workshopshed
    Workshopshed over 8 years ago in reply to DAB

    Yes, I2C means that you could control it from most systems. I've already done it with 2 now and it would not be hard to drive it from an arduino. I discovered today that the "brain" of the board can also be reprogrammed via a seria to usb connection and the Arduino IDE so if you needed 10 inputs or outputs you could probably do that too.

     

    An example of running the board from the Microbit

     

    micro:bit and the Picon Zero

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube