Bonjour a tous.

Je suis en un petit nouveau sur le forum mais aussi en développement.

j'ai acheté un arduino récemment pour faire un petite station météo pour un projet futur d'observatoire astronomique.

j'ai réussi a coder mon arduino pour qu'il récupère les données de la sonde et j'ai réussi a créer une petite interface en c#

la voici:
Nom : meteo.jpg
Affichages : 162
Taille : 57,1 Ko
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO.Ports;
using System.Text.RegularExpressions;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        SerialPort port;
 
 
 
        public Form1()
        {
            InitializeComponent();
 
        }
 
 
 
        private void button1_Click(object sender, EventArgs e)
        {
            if (button1.Text == "Connecter") 
            {
 
                port = new SerialPort();
                port.BaudRate = 9600;
                port.DataBits = 8;
                port.StopBits = StopBits.One;
                port.Parity = Parity.None;
                port.PortName = comboPort.SelectedItem.ToString();
                port.ReadTimeout = 200;
                port.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
                port.Open(); 
                button1.Text = "Deconnecter";
            }
            else 
            {
               port.Close(); 
               button1.Text = "Connecter";
            }
        }
 
        private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
 
            String texte = port.ReadExisting();
            SetText(texte);
        }
 
        delegate void SetTextCallback(string text);
        private void SetText(string text)
        {
 
            if (textBox4.InvokeRequired)
            {
 
 
                SetTextCallback d = new SetTextCallback(SetText);               
              textBox4.Invoke(d, new object[] {text});
 
            }
            else
            {
                textBox4.Text += text;
 
                string[] newData = textBox4.Text.Split(new char[] { });
                textBox1.Text = newData[0] + " %";
                textBox2.Text = newData[1] + " °C";
                textBox3.Text = newData[2] + " °C";
 
 
            }
le problème c'est que les données arrivent toutes les 2sec sur le port série et que la ce code ne s'actualise pas il me prend juste la première chaine arrivant et c'est tout.

j'avais pensé a un timer mais je ne sais pas du tout comme le mettre en œuvre. ou est ce qu'il existe un fonction pour lire juste la dernière ligne de la textbox, si cela existe je n'ai rien trouver sur le net pouvant m'aider.

cordialement

Damien