ESP32 Bluetooth Mesh

For general Flowcode discussion that does not belong in the other sections.
Post Reply
mnfisher
Valued Contributor
Posts: 1462
http://meble-kuchenne.info.pl
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 713 times

ESP32 Bluetooth Mesh

Post by mnfisher »

The background:

I want to create some 'linked' Christmas decorations and had a choice of a wire, wifi, wifi mesh and Bluetooth mesh. Having just done some work integrating C into FC for esp32 - I went with BT Mesh.

(Second time typing this after I got hit by the 'and it's gone' website feature :-( )

So - I'd consider this fairly advanced - so if you want to play along, get a nice fresh mug of tea first :?

1) Create a new esp32 project in fc - save (for this I'll assume you've called it 'mesh' - but use whatever you like and type that where you see mesh.)
2) Save and compile to create it's directory structure.
3) Find the directory with the esp32 examples (so my esp directory is esp-idf and the directory is \examples\bluetooth\esp_ble_mesh\ble_mesh_node\onoff_server and copy all the files in this directory and main to your project directory (this will be called 'mesh')
4) In 'mesh' edit CMakeLists.txt - the final line should be project(esp-project) (instead of project(onoff_server) )
5) In mesh/main edit CMakeLists.txt to read:

Code: Select all

set(COMPONENT_SRCS "esp-project.c" "main.c"
                   "board.c")

set(COMPONENT_ADD_INCLUDEDIRS ".")

register_component()
6) Edit mesh/main/main.c - change the name of the final function from app_main to start_app
7) Create a file main.h (should probably rename these)

Code: Select all

#ifndef main_h_
#define main_h_

void start_app();

#endif

8) In your FC project - supplementary code add

Code: Select all

#include "esp_ble_mesh_defs.h"
#include "esp_ble_mesh_common_api.h"
#include "esp_ble_mesh_networking_api.h"
#include "esp_ble_mesh_provisioning_api.h"
#include "esp_ble_mesh_config_model_api.h"
#include "esp_ble_mesh_generic_model_api.h"
#include "esp_ble_mesh_local_data_operation_api.h"
#include "ble_mesh_example_init.h"

#include "board.h"
#include "main.h"
Note - I'm not sure these are all necessary, but they do no harm.

9) Add a C block to call start_app()

Code: Select all

start_app();
And a delay loop to stop wdt errors (I added a UART and printed a message before and after calling start_app() and used feedthe dog.
Note this necessitate a new partition map :-)
10) Now we hit a snag - FC should compile this okay - but fails with error 1 when it tries to upload. Compiling using idf.py works well - but need to use FC to compile to hex to create new C file (I expected compile to C to do this - so try this too)
11) Open a cmd prompt.
12) cd 'mesh'
13) esp-idf\export
14) esp-idf\tools\idf.py menuconfig - set esp32 flash to 4mb if using esp32-wroom Check ble-mesh enabled
15) esp-idf\tools\idf.py clean
16) esp-idf\tools\idf.py build (if building outwith fc)
17) - if all is good then esp-idf\tools\idf.py -p COMn flash (where n is for com port esp32 is attached to)
18) Install nrfMesh on a phone and test - you should be able to control LEDs attached (see board.h for pins) or just use

Martin

mnfisher
Valued Contributor
Posts: 1462
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 713 times

Re: ESP32 Bluetooth Mesh

Post by mnfisher »

Testing with nrfMesh.

One of my boards worked well - one did not :-( Not sure why - both worked well using the 'native' app.

Add Node
Identify
Provision

Click on board
Element
Generic onoff server.

Bind Key

Controls at bottom....


Good luck !


MArtin

Post Reply