Thursday, December 25, 2014

Raspberry Pi + Arduino i2c communication, write block and read byte

In this example Raspbery Pi (programmed with Python) is connected with Arduino Uno via I2C. The Raspberry Pi act as i2c master, and Arduino act as i2c slave. Raspberry Pi send block of data to Arduino, and read byte echo from Arduino.

Read my another blog for the source code:

Monday, December 22, 2014

Generate sin wave on Arduino Due

Example to generate sin wave on DAC pin of Arduino Due.

#define maxSamplesNum 120

static int sinwave[maxSamplesNum] = {
  0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,
  0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,
  0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,
  0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,
  0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,
  0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,
  0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,
  0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,
  0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,
  0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,
  0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,
  0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794

int i = 0;

void setup() {

void loop() {
  if(i == maxSamplesNum)
    i = 0;
  analogWrite(DAC1, sinwave[i]);

Sunday, December 21, 2014

Assemble, test, align and power-up DSO138, Open-sourced Oscilloscope DIY kit

Just purchased a Open-source Oscilloscope DIY kit DSO138, with surface mount components soldered. Here how I assembled it in 2 hours.

After assembled, check voltage on TP22. Make sure it is arround 3.3V. Then short JP4 and install LCD module.

Notice: This video recorded after my final tested, so JP4 have been shorted at beginning. Actually, you have to keep it open after 3.3V on TP22 confirmed.

After the kit worked, align the 0V line and calibrate the probe.

For details and update of the DSO 138 DIY Kit, read Users Manual on the website.

Tested with Arduino Due generated sin wave.

Tuesday, December 16, 2014

Raspberry Pi send block of data to Arduino using I2C

Raspberry Pi act as I2C master to send block of data to Arduino Uno. In Arduino side, act as I2C slave, display received message on 16x2 LCD display.

Sunday, December 14, 2014

Raspberry Pi write I2C data to Arduino Uno

A step-by-step example to implement communiation between Raspberry Pi and Arduino using I2C. Here Raspberry Pi, programmed with Python, act as I2C host and Arduino Uno act as slave.

Wednesday, December 10, 2014

Open-sourced DSO (Digital Storage Oscilloscope) DIY kit - DSO138

Interesting open-sourced digital oscilloscope DIY kit, DSO138, think about buying one. But I can't find the source in the web-site, and instruction to flash the firmware!

DSO138 was designed as a training oscilloscope kit. It contains only the basical oscilloscope functions with no fancy features. Simplicity in structure and easiness in assembly/operation are among the main targets of the design. For these purpose DSO138 uses mostly through-hole parts. The heart of DSO138 is a Cortex-M3 ARM processor (STM32F103C8) from ST. It uses 2.4-inch TFT LCD (320 X 240 dotmatrix, 262K colors) as its display element and displays nice and clear waveforms. Detailed assembly instructions are provided in combination with troubleshooting guide and schematc. Source codes are also available to allow user to add their own features.

DSO138 kits are solded in two configurations. One is with all SMD parts pre-soldered (PN: 13801K). The other is with only the main IC (the MCU) pre-soldered (PN: 13802K). The latter serves also as a SMD soldering training kit. For both configurations the MCU has been pre-programmed and no re-programming required.

DSO138 is partially open-sourced. This opens the possibility for users to add different features or develop new applications on the hardware.

Major features of DSO138: 
  • Analog bandwidth: 0 - 200KHz
  • Sampling rate: 1Msps max
  • Sensitivity: 10mV/Div - 5V/Div
  • Sensitivity error: < 5%
  • Vertical resolution: 12-bit
  • Timebase: 10us/Div - 500s/Div
  • Record length: 1024 points
  • Built-in 1KHz/3.3V test signal
  • Waveform frozen (HOLD) function available

Finally I bought my own DSO138 kit, read Assemble, test, align and power-up DSO138, Open-sourced Oscilloscope DIY kit.

Monday, December 8, 2014

Program Arduino Pro Mini with USB-to-Serial adapter

This is a good video tutorial for programming (or flash) Arduino Pro Mini with USB-to-Serial adapter. Using 3 different USB to Serial modules to program a clone Arduino Pro Mini. The chips are the FTDI FT232RL, the Silicon Labs CP2102 and the Prolific Technologies PL2032HX.

HC-05 Serial Port Bluetooth Module (Master/Slave)

HC-05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for transparent wireless serial connection setup.

Serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio transceiver and baseband. It uses CSR Bluecore 04-External single chip Bluetooth system with CMOS technology and with AFH(Adaptive Frequency Hopping Feature). It has the footprint as small as 12.7mmx27mm. Hope it will simplify your overall design/development cycle.

Sunday, December 7, 2014

Arduino ISP

The Arduino ISP ( is a tiny AVR-ISP (in-system programmer) based on David Mellis' project FabISP ( With this programmer you can upload sketches and burn the bootloader on any AVR based boards, including Arduinos. By uploading a sketch with an external programmer you can remove the bootloader and use the extra space for your sketch. The Arduino ISP can also be used to burn the Arduino bootloader, so you can recover your chip if you accidentally corrupt the bootloader. Burning the bootloader is also necessary when you use a new ATmega microcontroller in your Arduino, and you wish to use the bootloader to upload a sketch via the USB-Serial connection.

For more details about using the Arduino ISP please visit the Getting Started page.