Tuesday 26 December 2023

Bluetooth Low Energy motion sensor with nRF 51822 module

NRF 51822 is a very low power BLE System On Chip , that allows to use as Bluetooth Low Energy peripheral connected to Passive Infrared Receiver module.


PIR module used:


Schematic diagram of ble motion sensor:

HW build to 3D printed case:






Software for NRF51822 was developed with Arduino IDE:



NRF connect android application could be used  to check Bluetooth Low Energy  UART services and characteristics:



BleCameraNRF  android application is used to start motion detection  from Nrf51 module, check battery, temp and solar log.




Project files can be found from github:

https://github.com/joukohak/nrf51pir




Saturday 2 July 2022

NRF 51822 BLE module sensor with Arduino IDE

Radioland  BLE beacon module datasheet:


can be reprogrammed with Arduino IDE and ST Link V2  to special remote button  application.

SWDIO     ->   SWDIO
SWCLK    ->   SWCLK
3.3V         ->   BAT+
GND        ->   BAT-














3D printed cover for BLE module:






 Arduino IDE libraries for NRF51822  and instructions can be found from:

https://github.com/sandeepmistry/arduino-nRF5


Nrf51822 Bluetooth low energy stack (Softdevice)  version S130 is required to download and flash to device before BLE application software can be programmed :

Selecting a SoftDevice

SoftDevices contain the BLE stack and housekeeping, and must be downloaded once before a sketch using BLE can be loaded. The SD consumes ~5k of Ram + some extra based on actual BLE configuration.

  • SoftDevice S130 v2.0.1 supports Revision 3 of nRF51 in peripheral and central role. It is 108k in size.

Flashing a SoftDevice

  1. cd <SKETCHBOOK>, where <SKETCHBOOK> is your Arduino Sketch folder:
  • OS X: ~/Documents/Arduino
  • Linux: ~/Arduino
  • Windows: ~/Documents/Arduino
  1. Create the following directories: tools/nRF5FlashSoftDevice/tool/
  2. Download nRF5FlashSoftDevice.jar to <SKETCHBOOK>/tools/nRF5FlashSoftDevice/tool/
  3. Restart the Arduino IDE
  4. Select your nRF board from the Tools -> Board menu
  5. Select a SoftDevice from the Tools -> "SoftDevice: " menu
  6. Select a Programmer (J-Link, ST-Link V2, or CMSIS-DAP) from the Tools -> "Programmer: " menu
  7. Select Tools -> nRF5 Flash SoftDevice
  8. Read license agreement
  9. Click "Accept" to accept license and continue, or "Decline" to decline and abort
  10. If accepted, SoftDevice binary will be flashed to the board

There are some examples in

Arduino BLEPeripheral library:





My own Arduino projects for NRF51822 can be downloaded from:



The project real time clock button is nrf51822_sensor_rtc   and it requires to modify delay.h and delay.c in Sandeep Mistry's nRF51 library, because it is using nRF51822 device RTC1  counter, that is also used in Sandeep's library ( millis() and delay() ).


With nRF Connect  Android application nrf51822_sensor_rtc  project features can verified:




Services and Characteristics defined in Arduino code:


BLEService mainBleService("c83e0fa6-f5b7-473a-a2a2-3957117a2f58");
BLEUnsignedIntCharacteristic sensorCharacteristic("8afc0cf0-19bf-4bd2-9413-6e7259765edf", BLERead | BLEWrite | BLENotify); BLEService batteryService("180F"); BLEUnsignedCharCharacteristic batteryLevelCharacteristic("2A19", BLERead);



Can be verified on nRF Connect application:     - battery level is actually 20x mV instead %     - sensorCharacteristic when button pressed shows 32 bit (4 bytes) data including:         - seconds,minutes,hours and button counter value(byte)











Tuesday 8 March 2022

Simple digital wireless BLE oscilloscope


Cheap and simple DIY bluetooth low energy digital oscilloscope made with JDY-08 BLE module and STM8S103 module and Li ION battery.
Android application is developed to display oscilloscope data. 


STM8S103 is 8-bit microcontroller with 1024 bytes RAM and 8 kbytes Flash memory. It stores 300 samples of 10 bit ADC data to RAM memory. Minimum sampling period is 5 us (200 kSamples/s).  ADC data is sent trough BLE link to Android smartphone application. 

Circuit diagram








Tuesday 28 April 2020

BLE dslr camera motion sensor and remote control

How to create new life for old DSLR camera like Canon EOS 350D. 
It can be used as motion sensor activated camera , time lapse image capture , wireless remote image capture  ...

EOS350D has on left side middle remote connection plug input for focus and shutter interface.










EOS350D can now be controlled trough this simple wired interface from PIR motion sensor box with BLE module wireless interface to Android device.




PIR motion sensor box has small solar cell to keep its Li-Ion battery charged.
BLE module is JDY-08 with firmware version 3.3844 , MCU is STM8S103 and PIR sensor is HC-SR501. Case and solar cell holder is 3D- printed.

 






PIR motion sensor box can be controlled with Android application.
Box can operate 4 different modes with Android device or without it.
Modes can be changed from application:

Mode 0:  Android device as wireless PIR motion sensor camera.

Mode 1: DSLR Camera as PIR motion sensor camera.

Mode 2.  DSLR camera remote shutter with Android app.

Mode 3  DSLR  camera time lapse image capture.

Application includes buttons for
- Android open camera start
- Halt /Wake MCU for power save
- Proximity screen off /on switch
- Battery voltage, Solar voltage, Temperature Log graph display
- Mode selection button
- Dslr remote shutter button
- Dslr time lapse start button






Sunday 6 October 2019

Digital Oscilloscope Demo

Low cost digital scope demo

What is needed for 200 ksamples/s low cost digital oscilloscope?
- STM8S103  8 bit microcontroller board
- JDY-08 or HM-10 Bluetooth Low Energy module


  BLE module JDY-08 baud rate configured from 115200 to 9600 baud with  AT+BOUD4
and connect  UART interface to  STM8S103 module D5 , D6 pins. Also connect 3V3 and GND pins.  Pin D3 is analog input and sample square wave signal from pin D4 can be connected to D3 pin.


  and flash the STM8S module with  STLINK V2 
     


- Android version higher than 4.4 tablet or phone

- Android application: 






Monday 23 September 2019

BLE wireless motion sensor for surveillance camera

BLE wireless surveillance camera with Android smartphone

If you own Android smartphone with Bluetooth 4.0 and Android version min. 4.4(KitKat), you can easily change it to surveillance or hunting camera. 
   Just make PIR sensor(HC-SR501), BLE module (JDY-08) and STM8S103 microcontroller based   wireless movement detector .
  aeProduct.getSubject()
This could be done easily without STM8S microcontroller using another BLE module with embedded IDE to develope software to communicate to Android application.


Bluetooth Low Energy  wireless motion sensor

Low power motion sensor consumes about 0,5 mA  on active BLE connection sleep mode. But it consumes 9 mA in active connection state, when motion is detected.

Prototype hardware looks like this:































Android applications(2 pcs)

I have developed 2 Android applications one to handle  BLE link to motion sensor and another to handle camera features (based to Open Camera app).
BLE link application has the feature of proximity screen off to reduce power consumption to typically 30 mA.  It also launches , controls and stops camera application.





Camera application has the main features of Open Camera and allows good quality video and still images.




Sample still image:





Files to download:

STM8S workspace:

Android applications:
BLE Camera application interface to BLE PIR sensor HW,that launhes on motion detected BLE Remote Camera

BLE Remote Camera application is Open Camera based app with remote BLE interface
https://drive.google.com/open?id=1aKUMfCTwR2doMtDItCjhgTB09jX1SzoP

Monday 7 January 2019

DIY STM8S103 BLE Solar Fridge controller PCB

 Low Energy Solar Fridge controller DIY

My target was to make very cheap and  very low energy  refridgerator controller to 12V solar system. Low energy fridge can be implemented with container type freezer with AC power and inverter (1000W) to be controlled by designed controller.




Schematic diagram and PCB


 Circuit diagram and printed circuit board was made with KiCad developement tool.
Main components of the controller are STM8S103 (module or IC), BLE module JDY-08 and
LCD display 16x2 lines.



Printed circuit board as KiCad 3D:


























STM8S103  program was developed with ST Visual Studio Developer and COSMIC STM8 C-compiler.




3D printed case


3D printed cover using PLA filament:








Android application


Android application developed with Android Studio. Android phone can be used to adjust temperature setting, control inverter and display temperature / battery voltage information.








Link to design files:
https://github.com/joukohak/solarfreezer