Statistics
| Branch: | Tag: | Revision:

mongoose / examples / STM32F4_CC3100 / README.md @ eaef5bd1

History | View | Annotate | Download (2.63 KB)

1
# STM32F4 example project
2

    
3
This example shows how to use mongoose on STM32 boards.
4
To run it you will need:
5
- [STM32F429-Discovery](http://www.st.com/content/st_com/en/products/evaluation-tools/product-evaluation-tools/mcu-eval-tools/stm32-mcu-eval-tools/stm32-mcu-discovery-kits/32f429idiscovery.html) dev board
6
- [CC3100](http://www.ti.com/product/CC3100) WiFi network processor
7

    
8
## Wiring scheme
9

    
10
By default, example uses SPI4 for communication with CC3100 and UART1 for 
11
the debug output. All parameters are described in file `stm32f4xx_hal_msp.h`,
12
they can be changed to use another SPI and/or UART
13

    
14
To use default scheme connect (CC3100 -> STM32-DISCO) connect:
15
```
16
DO  -> PE5
17
DIN -> PE6
18
CLK -> PE2
19
CS  -> PB12
20
IRQ -> PA0
21
HIB -> PB0
22
```
23

    
24
## Building firmware
25

    
26
Change `user_params.h`, put correct WiFi SSID and password there,
27
also change `MQTT_BROKER_ADDRESS` to the real broker address. 
28

    
29
`make` in `mongoose/STM32F4_CC3100` will download required docker image and make
30
firmware. Result will be in `STM32F4_CC3100/out` folder.
31

    
32
## Uploading firmare
33

    
34
Uploading firmware method depends on how you connected STM32 board to your
35
computer. If it is connected via USB ST-LINK connected it is appears as
36
a flash drive and in order to upload firmware just copy `out/example.bin`
37
to that drive.
38

    
39
## Running
40

    
41
Compile two additional samples: `mqtt_broker` and `mqtt_client` and run them 
42
in different terminals.
43
Press `reset` (or repower) STM board.
44
The board will connect to broker and will start to publish its uptime in 
45
`/stuff` channel. `mqtt_client` is subscribed on this channel as well, so 
46
it should start to print 
47

    
48
```
49
Got incoming message /stuff: Current tick: 99000
50
Forwarding to /test
51
Got incoming message /stuff: Current tick: 100120
52
Forwarding to /test
53
Got incoming message /stuff: Current tick: 101250
54
Forwarding to /test
55
...
56

    
57
```
58

    
59
If you connect UART to serial port monitor (pin PA9 or ST-LINK device, like /dev/ttyACM0)
60
you should see device output:
61
```
62
**** Hello ****
63
Initializing CC3100 on SPI4
64
Starting WiFi connect
65
Done, waiting for events
66
Connected to WiFi
67
Got IP
68
Connected to 192.168.1.108:1883
69
Connected to broker
70
Subscribing to /test
71
Subscription acknowledged
72
Publishing message with tick=1
73
Got incoming message /test: Current tick: 4487
74
Publishing message with tick=2
75
Got incoming message /test: Current tick: 5597
76
Publishing message with tick=3
77
Got incoming message /test: Current tick: 6717
78
...
79

    
80
```
81

    
82
This output looks like this because the device sends messages `Current tick: ....`
83
into `/stuff` channel, `mqtt_client` receives all messages in this channel
84
and sends them to `/test` channel. But the device is subscribed to this channel
85
so, it receives it back.