I am new and I would really need your experience and your help Here is my project:
I'm trying to make 2 Arduino nano 33 ble sense communicate with each other, For example : I send the accelerations and gyro data from the first one and receive them in the second (the central)
The idea would then be to make 6 Arduino nano 33 ble sense each associate with an electrochemical technology sensor (UART), and send the data to the central board which will retrieve all the data from the sensors via BLE on each board.
Then I will associate with the central card (the one which recovers all the data of the 6 cards) a LORA module to send the data to a PC (I would like to do it in real time).
Connecting two Nanos by Bluetooth is a reasonable thing to do. Connecting six isn't, so you might conclude that you are on the wrong tram. If you already have the Nanos, an NRF24 network would be a better option. Otherwise use ESP8266 devices, and dispense with the Nanos.
Did you look at the examples that come with the ArduinoBLE library?
In BLE you do not send data from the application layer. In BLE a peripheral/server stores data in some characteristics which are combined into a service. A central/client can connect to the peripheral and read the data. The client can be notified of changes.
Can you please post a link to a datasheet of the sensor?
How much data do you expect to get from the sensor? e.g., what type/size, at what interval?
@Nick_Pyner It looks like the support for multiple connections has improved. I currently have a Arduino Nano 33 BLE as central connected to two peripherals. I need to port my peripheral code to some other boards to test how many peripherals I can handle realistically. The datasheet says 20, but I do not know whether there are limitations in the ArduinoBLE library.
Hi,
In first, I want to do the test between the 2 arduinos nano 33 ble sense:
For example, detect the temperature of the first card and receive the informations in the second card in real time?
so that afterwards I order the remaining cards, for the sending of information in real time, as soon as it detects it sends to the central card, CityTech-1CO-Analog-DTS-EN-LTR-0520-1_ECN-NPI_FINAL.PDF (296 Ko) here is the datasheet of the electrochemical sensor
Thank you (and pardon the hijack) I was wondering if I has been missing things. This BLE stuff does seem to be nebulous. For all that I would still be suss about the approach. This sort of thing might be better, and surely more cheaply, done with ESP-01s
I had a look at the sensor datasheet. It is an analog sensor. Do you have a module that will convert the sensor signal for you?
The good part is the sensor only creates small amounts of data. So, data handling should not be any issue.
@Nick_Pyner I agree, if you do not use a phone or a tablet for interaction with your devices, BLE hardware is quite expensive. I guess the fees for Bluetooth SiG need to be recovered somehow. When you sell many millions units then its not so much of an issue. I doubt Arduino or Adafruit have sold BLE boards in these amounts so far.
About BLE being nebulous, you are right because BLE is quite modern it adds a couple of abstraction layers. Similar to UART vs USB. With the ArduinoBLE library getting more mature I think it has a good chance of being used more widely in the Arduino community.
Thanks, your examples work for me perfectly (LED EXAMPLES and also BatteryMonitor),
For the analog sensor that I showed you I don't have a converter, can I use it directly? i.e. the output of the sensor connect to the analog input of my nano 33 card,
it's up to the arduino board to do the conversion knowing it has analog inputs or I need a converter module?
This document should be used in conjunction with the 1CO Characterisation Note, the Operating Principles (OP08), and the Product Safety Datasheet (PSDS 12.1).
Do you have any of these documents? I have not used these types of sensors before.
Most semiconductor companies provide some more information about their products, like application notes that show typical circuits and other useful information.
Where do you get the sensor from?
I chose this sensor type because they have good selectivity, and I couldn’t find another sensor with small dimensions like the 1CO.
I have not yet purchased these sensors, I want to be sure about the software part (programming of sensors on IDE) and integration with my NANO BLE 33 card.
For the moment it is my first choice, but at the same time I am looking for other type of sensor which have small dimensions or the same as (1CO) and also where I can easily associate with my NANO 33 card. If I find other sensors, I won’t take those from city Technology.
For the Operating Principles (OP08), the manufacturer still hasn’t given me anything, I find that: not professional on their part (They are not recative).
I have done a few more experiments and I cannot tell you that connecting six of the boards might work. I got one central to connect to two peripherals but the third one will not connect so far. Maybe there is a limit set in the software. Maybe I get lucky and find something. No promises.
Thanks. That document is not useful for our purpose.
I am quite certain you will need some external components for the sensor. Maybe its is just a few passive components. An example circuit from the manufacturer would be nice.
They might not be interested in you as a customer. And that is not meant as a bad thing for your or the company. Companies must manage resources. They might not have the resources to help unless you can provide them with the right business opportunity. Some companies can afford to help a few makers from time to time but not all companies can.
If this is not a hobby project you need to find a way to let them know. Maybe they have a representative or distributor in your country that can help you.
For the moment I will communicate an Arduino nano sense (MASTER) with the 5 others as a peripheral, but not all at the same time I understood that it is not yet possible.
I want to make a central which receives the information in turn.
Knowing that I have already connected the example of the central and peripheral LEDs, and also Baterry monitor connected to my phone ,
The question I have :
How to send the gas sensor DATA on IDE from the first nano BLE SENSE to the second nano BLE SENSE , knowing that for the example of the LED there was already everything on Arduino ble ?
That is to say : how can I integrate the program for my gaz sensor in Arduino ble, so that I can send data, I don’t know the process?
The idea is to detect a gas which is connected to the first card and to send the data to the second nano BLE 33 sense.
For the BLE side you need to think about the characteristics that you will need for the service.
At the minimum you need one for the gas value, I guess.
What information do you think you will need? e.g., data type and what do you call that?
What will be the range of valid values?
Do you need any additional parameters that you would like to configure? e.g., an update interval or change the ID of the sensor?
The data types do not have to be the same as the sensor. The value can be converted before it is sent. This will allow you to change the sensor later and still send the same type of data.
Have a look at the available characteristics types.
Regarding your sensor you will need some more information about the sensor you would like to use. I recommend we build the BLE part first. We can prepare for the sensor without it for now.
Thank you for your answer, I managed to send for example a character type data between the two cards (example of LEDCONTROL AND LED)
My goal is to send the numerical value of the gas detected to the 2nd card.
Regarding the citytechnology sensor I will not take it because I had no response from them, I found another sensor (Micro) that I will take it, here is the datasheet + SS PCB transmitter can be combined with a size sensor micro with 3 electrodes one sensor of size 4 series (3.3 V power supply)+ circuit for micro sensor
The question: where can I write the sensor program?
That is to say always: we need to use the example LED CONTROL / LED for send data ? SS_PCB_2.pdf (250,7 Ko) CO_SS_Micro_100.pdf (257,2 Ko)
I wrote a basic example you can use for your sensor. I have created a 32-bit unsigned characteristic to provide the sensor value as PPM of CO.
Because I do not have a sensor, I use the ADC to create some values. You can use the sensorTask to read the values from the sensor. You will need to add code depending on how the sensor is connected to your Arduino e.g., analog trough the ADC or better with the external board reading trough I2C.
You can then use the gasCoConvertToPPM function as a basis to convert the values to PPM. If the data is not linear you will need to use some math to convert. The map function will only work for linear mapping.
/*
This example creates a BLE peripheral with a service for a gas sensor.
The yellow LED shows the BLE module connected to a central.
The circuit:
- Arduino Nano 33 BLE.
You can use a generic BLE central app, like LightBlue (iOS and Android) or
nRF Connect (Android), to interact with the services and characteristics
created in this sketch.
This example code is in the public domain.
*/
#include <ArduinoBLE.h>
//----------------------------------------------------------------------------------------------------------------------
// BLE UUIDs
//----------------------------------------------------------------------------------------------------------------------
#define BLE_UUID_SENSOR_SERVICE "60AE0000-5B20-51E4-E0F5-E53ACA93E022"
#define BLE_UUID_GAS_CO_PPM "60AE0001-5B20-51E4-E0F5-E53ACA93E022"
//----------------------------------------------------------------------------------------------------------------------
// BLE
//----------------------------------------------------------------------------------------------------------------------
#define BLE_DEVICE_NAME "Arduino Nano 33 BLE"
#define BLE_LOCAL_NAME "Arduino Nano 33 BLE"
BLEService sensorService( BLE_UUID_SENSOR_SERVICE );
BLEUnsignedIntCharacteristic gasCOCharacteristic( BLE_UUID_GAS_CO_PPM, BLERead | BLENotify );
//----------------------------------------------------------------------------------------------------------------------
// I/O and App
//----------------------------------------------------------------------------------------------------------------------
#define BLE_LED_PIN LED_BUILTIN
#define GAS_CO_SENSOR_PIN A0
#define SENSOR_INTERVAL 2000
#define MIN_CO_PPM 0
#define MAX_CO_PPM 100000
uint32_t gasCoPPM = 0;
bool updateGasCoCharacteristic = false;
void setup()
{
Serial.begin( 9600 );
while ( !Serial );
pinMode( BLE_LED_PIN, OUTPUT );
pinMode( GAS_CO_SENSOR_PIN, INPUT );
analogReadResolution( 10 );
if ( !setupBleMode() )
{
Serial.println( "Failed to initialize BLE!" );
while ( 1 );
}
else
{
Serial.println( "BLE initialized. Waiting for clients to connect." );
}
}
void loop()
{
bleTask();
sensorTask();
}
void sensorTask()
{
static uint32_t previousMillis = 0;
uint32_t currentMillis = millis();
if ( currentMillis - previousMillis >= SENSOR_INTERVAL )
{
previousMillis = currentMillis;
uint16_t gasCoRaw = analogRead( GAS_CO_SENSOR_PIN );
gasCoPPM = gasCoConvertToPPM( gasCoRaw );
updateGasCoCharacteristic = true;
}
}
uint32_t gasCoConvertToPPM( uint16_t gasRaw )
{
return map( gasRaw, 0, 1023, MIN_CO_PPM, MAX_CO_PPM );
}
bool setupBleMode()
{
if ( !BLE.begin() )
{
return false;
}
// set advertised local name and service UUID
BLE.setDeviceName( BLE_DEVICE_NAME );
BLE.setLocalName( BLE_LOCAL_NAME );
BLE.setAdvertisedService( sensorService );
// add characteristics
sensorService.addCharacteristic( gasCOCharacteristic );
// add service
BLE.addService( sensorService );
// set the initial value for the characeristics
gasCOCharacteristic.writeValue( 0 );
// set BLE event handlers
BLE.setEventHandler( BLEConnected, blePeripheralConnectHandler );
BLE.setEventHandler( BLEDisconnected, blePeripheralDisconnectHandler );
// start advertising
BLE.advertise();
return true;
}
void bleTask()
{
#define BLE_UPDATE_INTERVAL 10
static uint32_t previousMillis = 0;
uint32_t currentMillis = millis();
if ( currentMillis - previousMillis >= BLE_UPDATE_INTERVAL )
{
previousMillis = currentMillis;
BLE.poll();
}
if ( updateGasCoCharacteristic )
{
updateGasCoCharacteristic = false;
gasCOCharacteristic.writeValue( gasCoPPM );
}
}
void blePeripheralConnectHandler( BLEDevice central )
{
digitalWrite( BLE_LED_PIN, HIGH );
Serial.print( "Connected to central: " );
Serial.println( central.address() );
}
void blePeripheralDisconnectHandler( BLEDevice central )
{
digitalWrite( BLE_LED_PIN, LOW );
Serial.print( "Disconnected from central: " );
Serial.println( central.address() );
}
Thank you very much for your help, now I am waiting for the delivery of my sensor so that I can use this code.
On the other hand I received a radiation sensor, I even tested it with its electronic diagram it works perfectly, but in the programming part I find difficulties,
can you guide me please,
It's always the same method: detect with the first arduino nano and to send the numeric values to the second card