Dear Arduino Forum!
I’ve tried my best to read enough material on this topic to be able to do it myself but unfortuantely I was unsuccessful.
Currently my Arduino is only connected to a HC-05 bluetooth module on pins 10 and 11. What I’d like to achieve is to be able to send numbers or other data periodically to my raspberry which I would eventually store in a text file.
Ultimately it would be thermometer numbers but in order for me to do it a simple loop’d i++ is enough as an example since only the variable’s calculation would differ the rest would stay the same.
This is the code on the Arduino’s end.
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);
int i;
void setup()
{
Serial.begin(9600);
i = 0;
delay(800);
mySerial.begin(9600);
}
void loop() // run over and over
{
Serial.println(i);
i++;
delay(800);
mySerial.println(i);
}
This is the python code
#! /usr/bin/python
import serial
ser = serial.Serial('/dev/rfcomm0' , 9600)
print(ser.name)
ser_bytes = ser.readline()
print = ser_bytes
I have no prior knowledge to this so apologies if I’m missing something obvious. I have managed to establish the connection between the 2 devices and with a different project I have tested and double checked.
My issue is that while the loop’d numbers are showing nicely on COM3 the result on my Raspberry on the other hand is but a single number with the delay added.
So ultimately my question would be how to achieve this:
and not just a single number like so:
I’ve already tried it with while True: but unfortunately I get an error in that case.
As I’m not experienced with python cannot help but think the print line is missing something but cannot firgure it out.
Sincerely,
Nyanpasu