Showing posts with label Arduino. Show all posts
Showing posts with label Arduino. Show all posts

Wednesday, October 7, 2015

Uploaded Arduino blink example to a STM32 board - M3S STM32F103ZET6

M3S STM32F103ZET6


In my quest for higher speed, more pins,  more flash and more RAM for my SVTrackR and yet keeping the cost low, I started exploring other ARM 32-bit boards.

Before this, I'm already using  DigiX from Digistump, an Arduino  DUE compatible board but they are in Mega form factor, kinda big and most important factor for me, high price. The DigiX are 32bit ARM Cortex-M3 microcontroller running at 84Mhz.

DigiX Comparison Table

While shopping at taobao, the development boards from STM32 really stand out as they are low cost, lots of pins and similar form factors as Arduino Nano. My most important criteria is that I should not have to port my codes to another platform or learn another new development environment. As a hobbyists, the development software must also be free.

STM32 dev board
A search for STM32 will results in so many STM32 development boards from any shapes, colours and sizes with price range from RMB25.70 to thousands of RMB. Compared to the above chart for DigiX, the lowest price are 59 in US Dollars.

All these cheap and powerful boards are no good to me unless they runs on Arduino IDE as my SVTrackR codes uses a lot of open source libraries from GPS, OLED and SoftSerial.

Some background and history on STM32 on the Arduino platform. It was started very early by leaflabs producing the Maple and Maple Mini back in 2008. You can read all the details are the links provided below. Good thing it was an open source projects so all the work done by them can be taken up some others to continue the development. If this were a closed sourced project, all these would be gone.
http://www.leaflabs.com/device-details/


Arduino Forum :-
http://forum.arduino.cc/index.php?topic=265904.0 with 2625 messages.

New STM32duino home :-
http://www.stm32duino.com/

Roger Clarke from Melbourne did a great job to continue the developement.
https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Credits-and-history

If you are a newbie and just want to make some STM32 board purchases without reading all the histories, click on  Guide: "I'm new here - which board should I buy?"


More pictures of the M3S STM32 development board I purchased. I've also purchased the 3.2" touchscreen TFT that can attached to this board. It also comes in a nice looking plastic box.

M3S with box



M3S with 3.2" TFT



M3S STM32F103ZET6 with 3.2" TFT




From the image the seller posted, this board have a lot of items on board like 2 USB port (mine comes with Micro-USB ), DB9 on MAX3232, JTAG, SWD, DS18B20 slots, mini buzzer, nRF24L01 slots, SPI flash on SD, SDIO, 2 LEDs, 4 buttons, BOOT0/BOOT1 jumpers,  EEPROM 24C02, OV7670 camera module and other that I could not translate the chinese.


Summary Links










Wednesday, March 6, 2013

Migrated RF24 codes to github

I've migrated my previous static codes to github's RF24 libs at https://github.com/stanleyseow/RF24
This is a fork from gnulnulf codes that uses dynamic rf24 RPi libraries...

This will be using the Arduino maniacbug's RF24 libraries in additional to the Raspberry Pi codes under a different folder...

Changes to take note from my initial instructions  :-

- CE is now using GPIO25
- CSN is now using GPIO8 (CE0)

Thanks to gnulnulf, you can specify the devices inside of the codes as below :-


RF24 radio("/dev/spidev0.0",8000000 , 25);

The files are located at RF24/librf24-rpi

Instructions on using github version for RPi :-

Using git, issue the following instructions :-

git clone https://github.com/gnulnulf/RF24.git
$ cd RF24
$ cd librf24-rpi/librf24
$ make                                <--- Compile the files
$ sudo make install             <--- This will install the librf24.so.1.0 into the shared libraries
$ sudo ldconfig -v | grep librf

     librf24.so.1 -> librf24.so.1.0

$ cd examples
$ make

To run the programs, type sudo ./rpi-hub or sudo ./scanner

*** You need sudo to access the spidev0.0 device
Instruction on Arduino :-

Got examples/RF24/rpi_hub_arduino

Compile and upload to the Arduino

Connect a small buzzer to digital Pin2

If everything is working, you should hear a short beep ...


Summary Links :-

https://github.com/stanleyseow/RF24 ( Arduino RF24 and RaspberryPi libs codes all in one )












Tuesday, February 19, 2013

Setup Nordic nRF24L01 RF modules to both Arduino UNO and Raspberry Pi


In my process of building a Wireless Sensor Network, I obtained  a few low cost RF module from Inhaos that are compatible with Nordic Semiconductor nRF24L01. My plans are to have these low cost RF modules replaces the wires for my sensor network on Arduino and connect them to Raspberry Pi as the IP gateway to the rest of the Internet.

Raspberry Pi with nRF24L01-PA-LNA with BT module and USB Wifi


This entry will show you on how to setup both Arduino UNO & Raspberry Pi to connect to these nRF24L01 modules.

Some basic information on these low cost RF modules, they communicate using SPI to the microcontroller and works on raw speed of 250Kbps, 1Mbps and 2Mbps.

I'm using the following hardware & software:-


Raspberry Pi Model B running Adafruit's Occidentalis V0.2 ( http://learn.adafruit.com/adafruit-raspberry-pi-educational-linux-distro/occidentalis-v0-dot-2 ) that support SPI.


RF modules used here :-
------------------

nRF24L01+ PA+LNA+2dBi ant

nRF24L01+ with PA & LNA and 2 dBi antenna ( http://www.elecfreaks.com/wiki/index.php?title=2.4G_Wireless_nRF24L01p_with_PA_and_LNA ), these are long range RF modules acting as hub on the Raspberry Pi.

Inhaos RF2400P


Inhaos RF2400P (with 5dBm RF power output) on BEKEN Chipset ( http://www.inhaos.com/product_info.php?products_id=35 ). They are compatible with the nRF24L01 but with higher output power of 5dBm.

nRF24L01+


Too many to choose from, just google for the above keyword on eBay or choose the cheapest as they sells in bulk of 10 pieces for a very low cost...

*** The main differences between the regular nRF24L01+ modules and the Inhaos RF2400P modules are that the RF2400P have a higher output power of 5dBm but could not do 250Kbps speed.

I'm running my setup using 1Mbps speed.

Setting up Arduino 

Connect using jumper wires from the above pin to the nRF24L01+ modules
Upload the sketches/program to the Arduino, download it here from Dropbox. 


Arduino UNO with nRF24L01+/PA/LNA/2dBi ant


Arduino connections to the nRF24L01 modules :-

Arduino Pin 11 to RF Module Pin 6 ( MOSI)
Arduino Pin 12 to RF Module Pin 7 ( MISO )
Arduino Pin 13 to RF Module Pin 5 ( SCK )
Arduino Pin 7 to RF Module Pin 4 ( CSN )
Arduino Pin 8 to RF Module Pin 3 ( CE )
Arduino 3.3V to RF Module Pin 2 ( VCC / 3.3V ) *** RF Module can only take 3.3V 
Arduino GND to RF Module Pin 1 ( GND )
RF Module Pin 8 (IRQ) is not connected

*** All the other pins are 5V tolerant

Optional LCD Module to display the received payload & payload length :-

I'm using Arduino Pin 7 & 8 for the SPI because my LCD module is using the following pins :-

Arduino Pin 9 - LCD Pin 4
Arduino Pin 10 - LCD Pin 6
Arduino Pin 3 - LCD Pin 11
Arduino Pin 4 - LCD Pin 12
Arduino Pin 5 - LCD Pin 13
Arduino Pin 6 - LCD Pin 14

Arduino Pin 2 - connect to buzzer ( for sound feedback when it received a valid packet )


Setting up Raspberry Pi

Upgrade your Raspberry Pi firmware to Adafruit Occidentalis V0.2 that support hardware SPI.

Download the above firmware and flash your SD card according to the instruction on Adafruit/Raspberry Pi website.

Refer to the two Raspberry Pi GPIO pinout and the physical pinout.

Raspberry Pi GPIO
GPIO with pin functions


RPi GPIO9    (Pin 21)  to RF Module Pin 7 ( MISO )
RPi GPIO10  (Pin 19)  to RF Module Pin 6 ( MOSI )
RPi GPIO 11 (Pin 23)  to RF Module Pin 5 ( SCK )
RPi GPIO8    (Pin 24)  to RF Module Pin 3 ( CE )
RPi GPIO 25 (Pin 22)  to RF Module Pin 4 ( CSN )
RPI 3.3V       (Pin 17)  to RF Module Pin 2 ( VCC/3.3V )
RPi Gnd        (Pin 25)  to RF Module Pin 1 (GND)



Instructions on using github version for RPi :-

Using git, issue the following instructions on Raspberry Pi command prompt :-

$ git clone https://github.com/stanleyseow/RF24.git
$ cd RF24
$ cd librf24-rpi/librf24
$ make                                <--- Compile the files
$ sudo make install              <--- This will install the librf24.so.1.0 into the shared libraries
$ sudo ldconfig -v | grep librf
     librf24.so.1 -> librf24.so.1.0

$ cd ../examples/
$ make

To run the programs, type 

$ sudo ./rpi-hub 
or 
$ sudo ./scanner

*** You need sudo/root to access the spidev0.0 device

Instruction on Arduino :-

Got examples/RF24/rpi_hub_arduino ( make sure the pins matches the above Arduino pinout )

Compile and upload to the Arduino

Optional :- Connect a small buzzer to digital Pin2 to hear a beep when the packet is returned to sender


If everything is working, you should see a screenshot below :-

rpi-hub screenshot


Summary Links :-

- Raspberry Pi firmware :- Adafruit Occidentalis-v0.2

- RF24 library (Arduino & RPi libs) on Github https://github.com/stanleyseow/RF24

Datasheets :-
- Nordic nRF24L01+ Datasheet :- nRF24L01+ DS

Forum :-
- Raspberry Pi Forum on nRF24L01 Click here
- Arduino Forum on maniacbug nRf24L01 driver Click here


LinkWithin

Related Posts Plugin for WordPress, Blogger...