Upload
dongoc
View
218
Download
1
Embed Size (px)
Citation preview
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page i — #3 ii
ii
ii
WirelessBerry PI V 1.0
INDUSTRIALBERRY
www.industrialberry.com
January 2016
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page ii — #4 ii
ii
ii
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page iii — #5 ii
ii
ii
Contents
1 License 11.1 Disclaimer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Introduction 3
3 Hardware implementation 5
4 Software implementation 114.1 Wiberry-Client Application Main . . . . . . . . . . . . . . . . . 114.2 Wiberry-Server Application Main . . . . . . . . . . . . . . . . . 13
4.2.1 Projects Compilation . . . . . . . . . . . . . . . . . . . . 154.3 Real Time Clock . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.3.1 RTC with shell . . . . . . . . . . . . . . . . . . . . . . . 154.4 LED Control . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5 Components list 19
Bibliography 21
iii
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page iv — #6 ii
ii
ii
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page v — #7 ii
ii
ii
List of Figures
2.1 WirelessBerry V 1.0 on Raspberry PI . . . . . . . . . . . . . . 42.2 WirelessBerry V1.0 . . . . . . . . . . . . . . . . . . . . . . . . . 4
3.1 RF modules connections . . . . . . . . . . . . . . . . . . . . . . 63.2 Electric diagram of RTC block . . . . . . . . . . . . . . . . . . 73.3 RF Module with SI4432 . . . . . . . . . . . . . . . . . . . . . . 73.4 WirelessBerry Connector . . . . . . . . . . . . . . . . . . . . . . 83.5 External Antenna . . . . . . . . . . . . . . . . . . . . . . . . . . 83.6 Raspberry HAT Eeprom . . . . . . . . . . . . . . . . . . . . . . 9
v
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page vi — #8 ii
ii
ii
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page vii — #9 ii
ii
ii
List of Tables
5.1 WirelessBerry Pi V 1.0 . . . . . . . . . . . . . . . . . . . . . . . 20
vii
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page viii — #10 ii
ii
ii
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 1 — #11 ii
ii
ii
Chapter 1
License
Open-source hardware shares much of the principles and approach of free andopen-source software. In particular, we believe that people should be ableto study our hardware to understand how it works, make changes to it, andshare those changes. To facilitate this, we release all of the original design files(Eagle CAD) for the IndustrialBerry hardware. These files are licensed undera Creative Commons Attribution Share-Alike license, which allows for bothpersonal and commercial derivative works, as long as they credit Industrial-Berry and release their designs under the same license. The IndustrialBerrysoftware/firmware is also open-source.
1.1 DisclaimerIn no event shall Industrialberry be liable to the buyer or to any third partyfor any indirect, incidental, special, consequential, punitive or exemplary dam-ages (including without limitation lost profits, lost savings, or loss of businessopportunity) arising out of or relating to any product or service provided or tobe provided by Industrialberry, or the use or inability to use the same, even ifIndustrialberry has been advised of the possibility of such damages.
1
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 2 — #12 ii
ii
ii
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 3 — #13 ii
ii
ii
Chapter 2
Introduction
WirelessBerry V 1.0 is an extension board for RaspBerry Pi. It is an OpenHardware Design. It has two functionalities: a RFM module and an on boardReal Time clock powered by a 12 mm battery. In fig 2.1 is shown the Boardon Raspberry PI B2. The RF Module is based on SI4432 [1] a SPI controlledsingle chip wireless ISM transceivers. The Si4432 offers advanced radio fea-tures including continuous frequency coverage from 240–960 MHz in 156 Hzor 312 Hz steps allowing precise tuning control. Additional system featuressuch as an automatic wake-up timer, low battery detector, 64 byte TX/RX FI-FOs, automatic packet handling, and preamble detection reduce overall currentconsumption and allow the use of lower-cost system MCUs. The RF moduleinstalled on WirelessBerry works in the following frequency range 410-440MHZ.All functionalities are full integrated in standard linux kernel, so, they can beavailable on fly, or at last recompiling linux kernel to add canbus functional-ities. The real time clock is based on DS3231 [2] with internal oscillator I2Ccontroller. It is full compatible with linux too. Using I2C Kernel module, andstandard kernel functions, date and hour can be set/get by simple commands.On the bottom side is located an on board battery to guarantee a data auton-omy more than 20 years. In chapter hardware there are all informations onprincipal components, schematics to rebuild and modify RaspBerry PI board.In chapter Software is reported how all hardware can be used: as recompile ker-nel, build simple user space function to set and get I2C data, etc... In chapterapplication is reported a typical example of how to use the board.
3
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 4 — #14 ii
ii
ii
Chapter 2 Introduction
Figure 2.1: WirelessBerry V 1.0 on Raspberry PI
Figure 2.2: WirelessBerry V1.0
4
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 5 — #15 ii
ii
ii
Chapter 3
Hardware implementation
WirelessBerry PI 1.0 is composed by two blocks: a RF Module shown in Fig.3.1 and a Real Time Clock shown in 3.2The SMD Jumper JP2 must be used to connect the RTC Int pin to Raspberry
GPIO17.The SI4432 is a stand alone SPI RF Transceiver.You can see in fig.3.3 the SI4432 module. It is supplied by 3.3V from rasp-
berry connector (fig 3.4 ). The spiral antenna is present, but not welded toreduce the dimensions and cost of shipping. It is possible to connnect an ex-ternal antenna (see fig 3.5) on X1 RF connector in order to increase the radiocoverage.The Raspberry Pi2 B has been designed specifically with add-on boards in
mind and today we are introducing HATs (Hardware Attached on Top). Asignificant feature of HATs is the inclusion of a system that allows the B+ toidentify a connected HAT and automatically configure the GPIOs and driversfor the board, making life for the end user much easier! The automatic con-figuration is achieved using 2 dedicated pins (ID SD and ID SC) on the 40WB GPIO header that are reserved for an I2C EEPROM CAT24C32WI. TheEEPROM (see fig 3.6).
5
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 6 — #16 ii
ii
ii
Chapter 3 Hardware implementation
27/1
1/20
15 1
6:37
:05
C:\U
sers
\p.s
corr
ano\
Goo
gle
Driv
e\E
agle
_File
\Wire
less
Ber
ry V
1.0\
Wire
less
Ber
ry V
1.0.
sch
(She
et: 1
/1)
Figure 3.1: RF modules connections
6
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 7 — #17 ii
ii
ii
27/11/2015 16:37:05 C:\Users\p.scorrano\Google Drive\Eagle_File\WirelessBerry V1.0\WirelessBerry V1.0.sch (Sheet: 1/1)
Figure 3.2: Electric diagram of RTC block
Figure 3.3: RF Module with SI4432
7
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 8 — #18 ii
ii
ii
Chapter 3 Hardware implementation
27/11/2015 16:37:05 C:\Users\p.scorrano\Google Drive\Eagle_File\WirelessBerry V1.0\WirelessBerry V1.0.sch (Sheet: 1/1)
Figure 3.4: WirelessBerry Connector
Figure 3.5: External Antenna
8
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 9 — #19 ii
ii
ii
27/11/2015 16:37:05 C:\Users\p.scorrano\Google Drive\Eagle_File\WirelessBerry V1.0\WirelessBerry V1.0.sch (Sheet: 1/1)
Figure 3.6: Raspberry HAT Eeprom
9
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 10 — #20 ii
ii
ii
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 11 — #21 ii
ii
ii
Chapter 4
Software implementation
Download Wheezy raspbian Prerequist:
1. SPI enabled
2. wiringPi installed
The demo codes are available for download on WirelessBerry web page
4.1 Wiberry-Client Application MainFollowing is reported the main.c of the Wiberry-Client Application:
//Client Example Code by Industrialberry to use with WiBerry Board#include "rfm22.h"#include <wiringPi.h>#include <stdio.h>#include <stdlib.h>#include <time.h>#include <unistd.h>#include <fcntl.h>#include <string.h>#include <pthread.h>#include <errno.h>
char received[63];int rssi;char datalen;char senderId;int ret;// Should be a message for us now
unsigned char buf[RH_RF22_MAX_MESSAGE_LEN];unsigned char len = sizeof(buf);char cmd;
11
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 12 — #22 ii
ii
ii
Chapter 4 Software implementation
int main(int argc, char* argv[])
int i;unsigned char input[MAX_PACKET_LENGTH];unsigned char output[MAX_PACKET_LENGTH];unsigned short syncwords=0x2DD4;
// Initialize SPI device 1if(wiringPiSPISetup(SPI_DEVICE, SPI_SPEED) < 0)
fprintf(stderr, "Unable to open SPI device\n\r");exit(1);
if (!init(syncwords)) printf("init failed");else
printf("Settings...\n");printf("\tFrequency is %.3fMHz\n",getCarrierFrequency()/1E6f);printf("\tFH Step is
%.3fkHz\n",getFrequencyHoppingStepSize()/1E3f);printf("\tChannel is %d\n",getChannel());printf("\tFrequency deviation is
%.3fkHz\n",getFrequencyDeviation()/1E3f);printf("\tData rate is %.3fkbps\n",getDataRate()/1E3f);printf("\tModulation Type %d\n",getModulationType());printf("\tModulation Data Source
%d\n",getModulationDataSource());printf("\tData Clock Configuration
%d\n",getDataClockConfiguration());printf("\tTransmission Power is %ddBm\n",getTransmissionPower());printf("\tSyncWord is %d\n",syncwords);// Listen for a packetprintf("Send a message...\n");
while(1) printf("Type [y] to send [n] to end: ");scanf("%c",&cmd);if (cmd==’y’)
sprintf(output,"Wiberry Client Message");printf("Sending ’%s’\n",output);send(output,strlen(output));if (receive(input,MAX_PACKET_LENGTH,5000)>0)
printf("%s\n", input);
12
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 13 — #23 ii
ii
ii
4.2 Wiberry-Server Application Main
else printf("No Message Received!!\n");
else
if (cmd==’n’)printf("\nEnd!!\n");break;
4.2 Wiberry-Server Application Main
Following is reported the main.c of the Wiberry-Server Application:
//Server Example Code by Industrialberry to use with WiBerry Board#include "rfm22.h"#include <wiringPi.h>#include <stdio.h>#include <stdlib.h>#include <time.h>#include <unistd.h>#include <fcntl.h>#include <string.h>#include <pthread.h>#include <errno.h>
char received[63];int rssi;char datalen;char senderId;int ret;// Should be a message for us now
unsigned char buf[RH_RF22_MAX_MESSAGE_LEN];unsigned char len = sizeof(buf);
int main(int argc, char* argv[])
int i;
13
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 14 — #24 ii
ii
ii
Chapter 4 Software implementation
unsigned char input[MAX_PACKET_LENGTH];unsigned char output[MAX_PACKET_LENGTH];unsigned short syncwords=0x2DD4;
// Initialize SPI device 1if(wiringPiSPISetup(SPI_DEVICE, SPI_SPEED) < 0)
fprintf(stderr, "Unable to open SPI device\n\r");exit(1);
if (!init(syncwords)) printf("init failed");else
printf("Settings...\n");printf("\tFrequency is %.3fMHz\n",getCarrierFrequency()/1E6f);printf("\tFH Step is
%.3fkHz\n",getFrequencyHoppingStepSize()/1E3f);printf("\tChannel is %d\n",getChannel());printf("\tFrequency deviation is
%.3fkHz\n",getFrequencyDeviation()/1E3f);printf("\tData rate is %.3fkbps\n",getDataRate()/1E3f);printf("\tModulation Type %d\n",getModulationType());printf("\tModulation Data Source
%d\n",getModulationDataSource());printf("\tData Clock Configuration
%d\n",getDataClockConfiguration());printf("\tTransmission Power is %ddBm\n",getTransmissionPower());printf("\tSyncWord is %d\n",syncwords);// Listen for a packetprintf("Listening to a message...\n");
while(1) if (receive(input,MAX_PACKET_LENGTH,5000)>0)
printf("%s\n", input);sprintf(output,"Wiberry - Message Received!");printf("Sending ’%s’\n",output);
send(output,strlen(output));
14
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 15 — #25 ii
ii
ii
4.3 Real Time Clock
4.2.1 Projects CompilationTo compile the Client project it is possible to use the command:
$ gcc main.c rfm22.c -o Wiberry-Client -lwiringPi -lpthread -lm
To compile the Server project it is possible to use the command:
$ gcc main.c rfm22.c -o Wiberry-Server -lwiringPi -lpthread -lm
4.3 Real Time ClockIt is possible use the RTC IC with the terminal or with a compiled program.The DS3231 is a device I2C, and then we must install i2c-tool
sudo aptitude install i2c-tool
and libi2c-dev before use it.
sudo aptitude install libi2c-dev
4.3.1 RTC with shellThe following code allow the management of the RTC with the i2c-tool directlyfrom the shell. Verify the DS3231 address 0x68 with
sudo i2cdetect -y 0
for Raspberry Rev 1 or
sudo i2cdetect -y 1
for Rev 2 and B+, because the I2C bus address changed from 0 to 1.Run the scripts as root:
modpro be rtc-ds1307
Then, run
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-0/new_device (if you havea Rev 1 Pi)
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-1/new_device (if you havea Rev 2 Pi)
15
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 16 — #26 ii
ii
ii
Chapter 4 Software implementation
Set RTC with
hwclock -w
Read RTC with
hwclock -r
4.4 LED ControlGo to home directory:
cd /home/pi/nano gpio_on.sh
add these lines to the script
#!/bin/sh
# Set up GPIO 27 and set to outputecho "27" > /sys/class/gpio/exportecho "out" > /sys/class/gpio/gpio27/direction
# Set up GPIO 4 and set to outputecho "4" > /sys/class/gpio/exportecho "out" > /sys/class/gpio/gpio4/direction
# Write output#Led1 Onecho "1" > /sys/class/gpio/gpio27/value#Led2 Onecho "1" > /sys/class/gpio/gpio4/value
# Clean upecho "27" > /sys/class/gpio/unexportecho "4" > /sys/class/gpio/unexport
nano gpio_off.sh
add these lines to the script
16
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 17 — #27 ii
ii
ii
4.4 LED Control
#!/bin/sh
# Set up GPIO 27 and set to outputecho "27" > /sys/class/gpio/exportecho "out" > /sys/class/gpio/gpio27/direction
# Set up GPIO 4 and set to outputecho "4" > /sys/class/gpio/exportecho "out" > /sys/class/gpio/gpio4/direction
# Write output#Led1 Offecho "0" > /sys/class/gpio/gpio27/value#Led2 Offecho "0" > /sys/class/gpio/gpio4/value
# Clean upecho "27" > /sys/class/gpio/unexportecho "4" > /sys/class/gpio/unexport
Run the scripts as root:
sh gpio_on.shsh gpio_off.sh
17
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 18 — #28 ii
ii
ii
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 19 — #29 ii
ii
ii
Chapter 5
Components list
In the table 5.1 we can see the Bill of Material, all the components are availableon-line. For simplicity, every component has a DigiKey order code (www.digikey.com).
19
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 20 — #30 ii
ii
ii
Chapter 5 Components list
Qty
ValuePackage
PartsDigikey-cod
Cost
NCost
I$2
Yellow1206
LED1,LED
2754-1144-1-N
D0,21
0,422
499Ω
0603R13,R
14RMCF0603FT
499RCT-
ND
0,040,08
210
kΩ1206
RN1,R
N2
CAT
16-103J4LFCT-
ND
0,100,20
3100nf
0603C1,C
2,C8
445-1316-1-ND
0,100,30
11uf
0603C9
445-1322-1-ND
0,100,10
110uf
1206C10
311-1466-1-ND
0,300,30
1RFMODULE
4432IC
1Aliexpress
3,503,50
1DS3231
SOIC
16IC
4DS3231S-N
D8,35
8,351
CAT
24C32W
I-GT3
SOIC
8IC
6CAT
24C32W
I-GT3C
T-N
D0,57
0,57
1RETA
INER
COIN
12MM
BAT
1BAT
100BAT
-HLD
-012-SMT-
ND
0,270,27
1Ant-C
onnectorMML
X1
A118077C
T-N
D0,60
0,601
Header
40pos
2x20
RPI
SAM1086-20-N
D3,30
3,301
PCB
3,203,20
3,20Tot
20,59
Table5.1:W
irelessBerry
PiV1.0
20
ii
“industrialberry_datasheet” — 2015/12/21 — 11:14 — page 21 — #31 ii
ii
ii
Bibliography
[1] Silabs. SI4432 Datasheet. https://www.silabs.com/Support
[2] Maxim. DS3231 Datasheet. http://datasheets.maximintegrated.com/en/ds/DS3231-DS3231S.pdf.
21