Can i transmit a PWM signal through Bluetooth ?

Hi guys,

I'm using this BT board as slave:
http://wiki.seeed.cc/Grove-BLE-dual_model-v1.0/

and this one as master:
http://wiki.seeedstudio.com/wiki/Bluetooth_Shield_V2.0

with this code on the master Arduino uno:
blueToothSerial.print(state);

i'm sending the state of the digital pin 9, which i set high or low manually.

On the Slave code, i use blueToothSerial.read and serial.print to see the received value on the monitor,
i indeed see 0 or 1 depending what i set the pin 9 to on the master side.

Now, my final goal is to send a PWM signal from the master, so a series of high and low values, and receive them on the slave side. BUT ! I would like to receive this PWM signal WITHOUT using the Arduino on the slave side and only use the BT board and simply read the PWM signal on the Rx pin of the BT board.

Is this possible ?

In my test above, when i send 0, so low value one pin 9, i still read +5v on the Rx pin. Actually the Rx pin is always pretty much at +5V whatever it receives a 0 or a 1.

I hope my question makes sense and is clear enough.

You should not try to send the PWM pulses. If, for example, you are using analogWrite(9, 87); to generate the PWM output then you should just send the number 87 and allow the receiving Arduino to generate the PWM pulses.

...R

Robin2:
You should not try to send the PWM pulses. If, for example, you are using analogWrite(9, 87); to generate the PWM output then you should just send the number 87 and allow the receiving Arduino to generate the PWM pulses.

...R

Thanks Robin for your input. Yes it could work that way.

But i would like to avoid using an Arduino on the receiving side, and i'm curious to understand what is actually received on the Rx pin of a bluetooth board. WHen i send a series of 0, why i still measure 5 V on the Rx pin ?

I'm really curious to know how this works.

You need to use a logic analyzer to know what exact voltage is on the RX pin at any given time. If you're sending all zeros, you will not always see 5V. You also should post you code in case your sending ASCII 0 instead of decimal 0.

hlalibe:
But i would like to avoid using an Arduino on the receiving side, and i'm curious to understand what is actually received on the Rx pin of a bluetooth board. WHen i send a series of 0, why i still measure 5 V on the Rx pin ?

I'm really curious to know how this works.

Bluetooth is like serial-by-wireless.

When you send a byte it will appear at the receiving end (on the pin that would normally connect to the RX pin on the receiving Arduino) as a series of HIGHs and LOWs with a timing dictated by the chosen baud rate. Broadly speaking a byte is sent as 10 "bits" - the start bit, the 8 data bits and the stop bit.

I guess you could send byte values that, in a crude way, simulate a PWM signal. For example 0 should be mostly LOW and 255 should be mostly HIGH. 15 (binary 00001111) would be about 50% duty cycle and 31 (00011111) would be a little more than 50%. Note that all the numbers between 15 and 31 are irrelevant. And the start and stop bits will probably screw things up anyway. And during all the time between bytes the output will be HIGH.

I suspect this is totally impractical. You really need to look at the output with an oscilloscope.

...R

ok good, now i better understand how it works, and indeed with the stop and end bits that will not work without an Arduino on the receiving end,

my code on master:
int state = 0;
blueToothSerial.print(state);

I tried different data types, i coud receive 0 and 1 , or 48 or 49, depending on data type.

For the fun of it, i would like to receive and print on serial monitor or serial plotter the 10 bits separately. Is there a way to do this ? I tried different data types but could not find the right one.

You need to write your own code to receive the bits if you want to see them. My Yet Another Software Serial could be adapted to do that.

...R

thanks a lot guys, i learned a lot.