The ARTIK 5 development board is built around the Samsung ARTIK 5 module using their next generation package-on-package (ePOP) technology. The module leverages and integrates a dual core ARM Cortex-A7 processor with DRAM and Flash, a Secure Element (SE) and Samsung’s Trusted Execution Environment, analog and digital IO, USB, I2S, I2C, MIPI, b/g/n WiFi, Bluetooth 4.1 and LE, and ZigBee communication components all into a single module.
This article is a primer and how-to that will walk you through getting terminal access to the board, establishing WIFI communication, sharing files from the board to make development easier, and then writing and running Python scripts to access digital and analog input pins.
Used in the demonstration are 2 modules present in the LinkIt-One Grove Starter Kit; specifically a push-button to connect to digital I/O, and a linear rotary potentiometer to connect and demonstrate analog I/O.
Earlier, I had the opportunity to test-drive an alpha version of the Artik-10 board (that experience is written up here:
Setting up and connecting to the ARTIK 5 Linux boardAt the time of this writing the current firmware release is based on Fedora 22. If the ‘/etc/os-release’ file indicates that the board is Fedora 20, you will want to do a firmware update. Mostly correct instructions are given here:
https://developer.artik.io/documentation/updating-artik-image.html
The small deviations that I encountered had to do with the screen shots not actually saying that the “Upgrade completed !”. Anyway, after using a SSD card written with the latest firmware to update the board, make sure you set the little tiny jumper switches both to off and power the board back on.
With that, the ‘/etc/os-release’ file indicates that the linux distribution is based on Fedora 22, ‘uname –a’ indicates that the linux core is 3.10, and the package manager to download additional software is ‘dnf’.
To setup the board, refer to picture 1.
- First ensure that the 2 jumpers, J20 & J22, are placed in the ‘low’ position.
- Connect the wi-fi antenna to J21, the WIFI antenna mount on the top of the board.
- Connect a mini USB cable from the PC to the USB port at the bottom left of the board (labeled USB CON4).
- Connect the barrel power connector on the right side (J9).
- Power on the board by first ensuring that the adjacent rocker switch is on, followed by doing a momentary press on the push button switch on the upper left (labeled ‘power’).
Once powered up, initial access to the board can be done using a serial terminal configured to talk to a serial port at 119200 baud. At this stage in the game, my preferred serial terminal program is PuTTy. The specific serial port to use can be determined by opening the Windows device manager. In the example below, the specific serial port is COM4. If there are multiple ports present, you can determine the correct port by unplugging and then plugging in the USB cable while watching device manager.
At the end of the board’s power-up sequence, the serial terminal console window will provide you with a login prompt. The credentials for the board I was using were as follows:
login: root
password: root
Wired network access:With the board updated to Fedora 22, wired Ethernet is configured with DHCP out of the box. If you have a convenient network drop, plug it in. To get the address of the board, enter the command:
ifconfig
Picking through the resulting dump of information, you can determine the board’s current IP address. In my case, the IP address is 192.168.100.163
eth0:flags=4163 mtu 1500
inet 192.168.100.163 netmask 255.255.255.0 broadcast 192.168.100.255
inet6 fe80::64f8:d4ff:fe63:34ed prefixlen 64 scopeid 0x20
ether 66:f8:d4:63:34:ed txqueuelen 1000 (Ethernet)
RX packets 3870 bytes 788454 (769.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 303 bytes 20226 (19.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 32
Configure wi-fi network access:If there isn’t a convenient network drop to use, the board can also be configured to use WiFi. The ARTIK on-line documentation has a good ‘how-to’ on configuring the board for wi-fi network access. Follow these instructions:
https://developer.artik.io/documentation/developer-guide/configuring-wifi-on-artik-10.html
In the case that the wi-fi goes off line (it did a couple times on me), the usb serial terminal window can be used to restart the driver:
ifconfig wlan0 down
ifconfig wlan0 up
Updating to the latest packages:With the network up, an optional step is to update the board using the package manager ‘dnf’ (used to be ‘yum’, but that is on the way out and not present on this board). To find out if there are any later packages available:
dnf list updates
To actually update to the latest packages:
dnf update
And to clean up and reclaim space:
dnf clean all
Consistent with best practices, it is usually best to work on a system with your identity, as opposed to relying on the default ‘root’ user. This is particularly important when setting up the board for file sharing access in a later follow-on step. Then, as a normal user, when you need root privileges, you simply invoke the ‘sudo’ command.
Unfortunately, the ‘sudo’ module is not included by default in their firmware. To install this module:
dnf install sudo
Now use the following commands to create a new user (for the purpose of this example, the new user is named ‘steph’ [feel free to substitute your own name]). In Fedora, your new user will get ‘sudo’ access if it is added to the group ‘wheel’. Lastly, set the password.
adduser steph
usermod –a –G wheel steph
passwd steph
Moving beyond a single limited terminal window with SSHOnce the new user is set up above, and either wired or wi-fi network access is configured, it is time to put the serial window in the background and access the board via the network using one or more SSH terminal sessions. Though PuTTy can be used for this, my preference is to use the Cygwin linux subsystem to open a Bash shell and SSH to the board (the IP address of the board can be determined by calling ‘ifconfig’ from the serial terminal).
ssh steph@192.168.100.163
Unlike the console serial terminal window, multiple ‘ssh’ sessions (e.g. windows) can be brought up from the PC, providing significant flexibility in navigating around. In my case, ‘ssh’ was already enabled on the ARTIK 5 board; if this is not the case on your board, you may have to edit the ‘/etc/ssh/sshd_config’ file to give the new user privileges (quick google will provide clues).
Sharing the new users directory using SAMBAFor writing scripts and editing files in general, I find it convenient to use my windows based editors. This is easy to do once the ARTIK 5 board is configured to share out a directory file structure using SAMBA. First, load the package:
sudo dnf install samba
The default configuration seems to share out user’s home directories, so you probably won’t have to edit the /etc/samba/smb.conf file to get specific access. So, with the SAMBA package loaded, you need to start the service:
sudo systemctl start smb.service
And then, provide your user a password to allow clients to connect:
sudo pdbedit –a steph
Should you need to configure SAMBA, you edit the /etc/samba/smb.conf file:
sudo vi /etc/samba/smb.conf
Continuing with my example using the new user name ‘steph’, share the user’s home directory by adding the following lines to the bottom of the configuration files:
[HOME]
path = /home/steph
valid users = @steph
force group = steph
create mask = 0775
directory mask = 0775
read only = no
Once the file has been edited, restart the SAMBA service:
sudo systemctl restart smb.service
Using the file explorer, you should be able to get access to the shared directory by typing the IP address in the navigation bar:
After double-clicking on the ‘home’ icon, windows should challenge you for the user name and password.
With access established, you can easily copy files back and forth, or create and edit files directly on the ARTIK board. One note of caution: make sure you keep a copy of all your important files on the PC. As an embedded system, is doesn’t have to write files to non-volatile storage immediately (it can cache them instead). Using an embedded linux board in a similar unfortunate situation, the board crashed once and wiped out the directory that I was working in.
To keep consistent with the linux end-of-line convention, I use the freeware program Notepad++ and set the line endings accordingly. If line-endings are not set properly in your windows editor, when you go to execute the script you may get an error such as “bad interpreter: No such file or directory.
For this demonstration, I used a pushbutton and a linear potentiometer from the Grove Starter Kit for the LinkIt-One board.
The pushbutton is wired to the digital I/O pin 2 on the connector J26 which the linux system knows it as ‘GPIO 121’ (very important to know for the script below). Image 2 provides a close up perspective of a white wire going into the 3rd pin from the left. On J27, the pushbutton is wired to ground (black wire). When the switch is left ‘open’, the system will read the input pin as a ‘1’. When pushed closed, the button will close the circuit to ground pulling the voltage down and registering the input pin as a ‘0’.
The linear potentiometer is wired to the analog input 0, available on J24-A0 (the right-most pin on J24). To power the potentiometer, +5V power and ground are taken from J25 (3rd and 4th pins from the left). When reading the analog pin, a 12-bit value between 0 and 4095 will be available (linear mapping, 0 being 0-volts and 4095 being 5-volts).
With the brief linux intro and board configuration completed, we can now start programming on the board directly using Python scripting.
In the user’s home directory, I created a subdirectory to work from and keeps things organized.
To verify that Python is installed and working correctly, create a file ‘hello.txt’ on the ARTIK that reads as follows:
#!/usr/bin/python
print "Hello Samsung ARTIK!"
The first line in the file indicates which interpreter/processor that the text file will be executed with, and the second line is our first program. With the file created and saved, use one of your SSH shells to set executable permissions on the file.
chmod +x hello.txt
With that, type in the filename as if it were a program you are trying to execute, and see if it works as expected.
./hello.txt
Note that you have place the ‘./’ in front of the file to ensure the bash shell will look for your command in the current directory. Otherwise, it only looks for commands in the directories present in the ‘PATH’ environment variable.
A very minimal program below demonstrates how to access and read the input pins using Python. Note that this time, though, you will need elevated privileges to execute it (because it accesses the hardware directly).
sudo ./hello.txt
Modify the ‘hello.txt’ file to look as follows:
#!/usr/bin/python
import time
print "Hackster.io demo of Artik digital and analog inputs"
# export pin 121 by opening file and writing the pin number to it
pinctl = open("/sys/class/gpio/export","wb",0);
pinnum = 121
try:
pinctl.write( str(pinnum) )
print "exported pin",str(pinnum)
except:
print "assumingpin",str(pinnum),"is already exported"
pinctl.close()
# set pin 121to be a digital input
pinctldir = open("/sys/class/gpio/gpio121/direction","wb",0)
try:
pinctldir.write( "in" )
print "pin set to read"
except:
print "failed to set pin direction"
pinctldir.close()
# loop once every second checking the sensors
while True:
# read the digital pin
pin = open("/sys/class/gpio/gpio121/value","rb",0)
print "digital value read is:",pin.read(2)
pin.close()
# read then analog pin
pin = open("/sys/devices/126c0000.adc/iio:device0/in_voltage0_raw","rb",0)
print "analog value read is:",pin.read(8)
pin.close()
# go to sleep for a second
time.sleep(1)
One caveat in the script above is determining the file pathname to the analog pin. If the above pathname does not work as is, you can discover the correct path by navigating to it. From the SSH shell, you would continue to find your way using ‘cd’ (change directory) and ‘ls’ (list directory).
cd /
ls
cd sys
ls
cd devices
ls
cd [etc...]
The clue is to look for similar names like in the script; ones with things in it like ‘adc’.
Have fun using this tutorial and as always I will check your chats and reply to questions.
Comments
Please log in or sign up to comment.