Nano ESP32 BLE Scanner

7,692

60

14

About: Make it yourself if you cannot buy one!

Intro: Nano ESP32 BLE Scanner

This instructables show how to use ESP32 to make wireless BLE signal scanner, all scanned data will send to the HTTP server via WiFi.

Step 1: Why BLE Scanner?

BLE (Bluetooth Low Energy) signal is very common for current digital device, mobile phone, wrist band, iBeacon, assets tag. This signal not only help you pair up the devices, it also can report the device status, such as battery level, heart rate, motion (walking, running, falling), temperature, panic button, anti-loss ... etc.

It is a valuable big data for location tracking if we can collect the BLE signal at certain number of position.

In long run, the BLE scanner should fix in selected position. However, selecting a right place require trial and error. A tiny wireless BLE scanner is handy to help you check where is the right place.

Step 2: Preparation

ESP32 board

I am using ESP-WROOM-32 board this time.

A Tiny Container

Any small container should be ok, I have some tiny TicTac box in hand and it just fit an ESP32 board in it, what a coincidence!

Lipo Battery

ESP32 peak current is around 250 mA. For not drawing over 1C current at anytime, Lipo Battery should over 250 mAh capacity. 852025 is the maximum size that can fit into the Tictac box and it claim it have 300 mAh, it's good enough.

Power Regulator Circuit

A 3.3 V LDO regulator, some capacitors, I have some HT7333A regulator, 22 uf and 100 uf capacitor in hand

Others

A 10k Ohm SMD resistor for pull up EN pin, a small piece of multi purpose PCB, a power switch, some coated wires, 7 pins header

ESP32 Dev Dock

In program process, it also require a ESP32 Development Dock, you may find how to make it in my previous instructables:

https://www.instructables.com/id/Battery-Powered-E...

Step 3: Trim the PCB

Measure the dimension of your tiny container and trim the PCB to fit into it.

Step 4: Soldering Pin Header

Let's start soldering work from the 7 pins header and PCB.

Step 5: Soldering Power Circuit

Here is the connection summary:

LDO Vin  -> Vcc pin header(1) -> power switch -> Lipo V+, Charge pin header(7)
LDO GND  -> GND pin header(2), capacitors V- pins, ESP32 GND
LDO Vout -> capacitors V+ pins, ESP32 Vcc

Step 6: Soldering Pull Up Resistor

It is the most difficult soldering work in this project, the pin width in ESP32 board is only 1.27 mm. Fortunately, Vcc and EN pin is nearby, it can direct soldering resistor between both pin without wire.

ESP32 Vcc pin -> 10k Ohm resistor -> ESP32 EN pin

Step 7: Soldering Program Pins

Here are the connection summary:

Tx pin header(3)      -> ESP32 Tx pin
Rx pin header(4)      -> ESP32 Rx pin
Program pin header(5) -> ESP32 GPIO 0 pin
RST pin header(6)     -> ESP32 EN pin

Step 8: Cleaning Up the TicTac Box

  • Eat all sweets
  • Remove the stickers

Step 9: Squeeze Into the Box

Squeeze all component into the TicTac box, be careful don't tear off any wires.

Step 10: Prepare Software

Arduino IDE

Download and install Arduino IDE if not yet:

https://www.arduino.cc/en/Main/Software

arduino-esp32

Install hardware support for ESP32

Detailed instructions for installation in popular operating systems.

For Linux: https://www.arduino.cc/en/Guide/Linux (see also the Arduino playground page https://www.arduino.cc/en/Guide/Linux

For macOS X: https://www.arduino.cc/en/Guide/Linux

For Windows: https://www.arduino.cc/en/Guide/Linux

Ref.: https://github.com/espressif/arduino-esp32/compar...

Step 11: Program the ESP32

#define WIFI_SSID "YOURAPSSID"

#define WIFI_PASSWORD "YOURAPPASSWORD"

#define POST_URL "http://YOURSERVERNAMEORIP:3000/"
  • Select Board: Any ESP32 board
  • Select Partition: No OTA / Minimal SPIFFS
  • Upload

Step 12: Receive Data

If you are not yet have any HTTP server to receive the POST data, you may try to use this simple Node.js program: https://github.com/moononournation/post_data_rece...

Here are the sample data received:

Tue Mar 20 2018 08:44:41 GMT+0000 (UTC): [

{

  "Address": "6e:3d:f0:a0:00:36",

  "Rssi": -65,

  "ManufacturerData": "4c0010050b1047f0b3"

 },

 {

  "Address": "f8:04:2e:bc:51:97",

  "Rssi": -94,

  "ManufacturerData": "75004204018020f8042ebc5197fa042ebc519601000000000000"

 },

 {

  "Address": "0c:07:4a:fa:60:dd",

  "Rssi": -96,

  "ManufacturerData": "4c0009060304c0a80105"

 }

]

Step 13: Power Measurement

The program scan BLE signal for 30 seconds, then deep sleep 300 seconds and then scan again. For each loop, it consume around 3.9 mWh.

Theoretically, it can run: (I will update the testing result later on my Twitter)

300 mAh Lipo / 3.9 mWh @ 330 seconds

= [(300 mA * 3.3 V) mWh / 3.9 mWh * 330] seconds

~83769 seconds

~23 hours

2018-04-08 Update:

I have changed to use XC6503D331 LDO regulator and made 2 measurements:

Round 1: 12:43:28 - 16:42:10 (~20 hours) 210 BLE scan POST received

Round 2: 10:04:01 - 05:36:47 (~19.5 hours) 208 BLE scan POST received

Step 14: Happy Scanning!

It time to find a place to setup you BLE tracking network!

Share

    Recommendations

    • Metalworking Contest

      Metalworking Contest
    • Fix It! Contest

      Fix It! Contest
    • Furniture Contest 2018

      Furniture Contest 2018

    14 Discussions

    0
    None
    kaefert

    2 months ago

    Thank you very much for this! It works fine at first, but after a few hours it stops posting data, and only prints this repeated on the serial console until I power cycle:

    Task watchdog got triggered. The following tasks did not reset the watchdog in time:
    - IDLE (CPU 0)
    Tasks currently running:
    CPU 0: wifi
    CPU 1: IDLE

    1 reply
    0
    None
    陳亮kaefert

    Reply 7 weeks ago

    I guess it stucked at connecting WiFi...

    1
    None
    billp119

    5 months ago

    I am having issues with the Arduino sketch being too big. I am using Arduino IDE V1.8.5 on windows 10. Here is the error message I receive. Can you help?

    "Sketch uses 1357670 bytes (103%) of program storage space. Maximum is 1310720 bytes.
    Global variables use 72828 bytes (24%) of dynamic memory, leaving 222084 bytes for local variables. Maximum is 294912 bytes.
    Sketch too big; see http://www.arduino.cc/en/Guide/Troubleshooting#size for tips on reducing it.
    Error compiling for board ESP32 Dev Module."

    7 replies
    0
    None
    billp119billp119

    Reply 5 months ago

    okay, I didn't follow step 10. Once I did I did receive a different error...."Error at line 7: CSV flag column contains unknown flag
    '</p>'". Once I removed the </p> from the same line it all worked fine. I am working on the HTTP server connections next so please disregard my earlier comment- you did a great job here!!

    0
    None
    陳亮billp119

    Reply 5 months ago

    Hi billp119,
    Yes step 10 is very important, thats why I need clone the main branch and amend it.

    0
    None
    陳亮kaefert

    Reply 2 months ago

    If you are using latest library, it have a “no ota” option, it can fit 2 MB firmware in it.

    0
    None
    kaefert陳亮

    Reply 2 months ago

    thanks for the reply. can you tell me how to set that option in arduino IDE or in some textfile in ~/Arduino/hardware/espressif/esp32/* or how else?

    1
    None
    陳亮kaefert

    Reply 2 months ago

    Updated step 10 and 11, please take a look

    0
    None
    kaefert陳亮

    Reply 2 months ago

    Thanks! That worked! However, I observe 2 strange things now:

    1.) The serial output cuts off 36 chars before the end of the http reply (tried modifying it and always the last 36 characters are not printed to serial) - afterwards there's nothing printed, also not the "Enter deep sleep .." message.

    2.) My Post Data PHP-Script doesn't receive any parameters, If I call it with `curl --data "param1=value1&m2=value2"` it works, but from the ESP32 it doesn't get any data. (even though I can see it printing some Payload on the serial console)

    UPDATE: add 1.) problem vanishes when I disable the sleep by setting it to 0. So I guess the serial printline is forked and does not blocks the processing and the sleep then kills the forked serial write process. But maybe you can help me explain problem 2.)

    UPDATE2: okey, made it work for me. See https://github.com/kaefert/Arduino_BLE_Scanner/blob/master/Arduino_BLE_Scanner.ino

    0
    None
    陳亮

    5 months ago

    Hi FabriceV1, I have revised the calculation. The theoretic live time should around 23 hours and the actual measured time is near 20 hours.

    0
    None
    raphan

    Question 5 months ago

    I can't even imagine how to work without a shematic, have you got one ? Thx

    1 more answer
    0
    None
    raphanraphan

    Answer 5 months ago

    I meant "schematic" !

    0
    None
    FabriceV1

    Tip 5 months ago on Step 13

    Hi Sir!
    Excellent and very detailled build, but I'm affraid your battery autonomy calculus is wrong.
    And in terms of power management, it could be much upgraded!
    You use a linear voltage regulator, these components are made to theoriticaly only be abble to lower the voltage, and come with no safety, so it will drain the battery until the integrated safety of the cell cuts out (around 3V this type). It means very deep discharge each time, not good for it.
    The available energy is not to be computed with the average 3.7V!! The true capacity is depending on the discharge curve, but can be roughly estimated by the capacity (mAh) over the difference between full voltage and empty voltage (4.2-3V = 1.2V this type), not 3.7!
    Also, just putting your calculus in a calculator doesn't match the 11h.
    Very clean on other aspects, I like your programmer and charger.