When I upload my code I have two errors:
at processing.app.Serial.dispose(Serial.java:163)
... 4 more
^~~~~~~~~~~~~~
But my sketch upload and I have some bugs with my program and I don't know why.
Can you help me please?
When I upload my code I have two errors:
at processing.app.Serial.dispose(Serial.java:163)
... 4 more
^~~~~~~~~~~~~~
But my sketch upload and I have some bugs with my program and I don't know why.
Can you help me please?
If you have errors, the code will not upload. Perhaps you mean that you have warnings.
Post the entire text of the warnings or errors. Paraphrasing leaves out important information.
**Post the Code. **We cannot help with code that we cannot see.
if there are problems with the code at runtime, describe what the code actually does and how that differs from what you want the code to do.
Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.
Here my code:
#include <VirtualWire.h>
#include <avr/wdt.h>
int ThermistorPin = 0;
int tension;
int valeurTableau;
int tempPourEnvoyer;
const bool okR = 1;
const bool okE = 0 ;
float R1 = 10000;
float logR2, R2, T, Tc ;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
void setup() {
Serial.begin(9600);
vw_set_tx_pin(12);
vw_set_rx_pin(11);
vw_setup(2000);
vw_rx_start();
}
void loop() {
int temp[2001];
unsigned long valeur;
int msg = 0;
Serial.println("Attente réception");
vw_wait_rx();
if (vw_get_message((byte *) &valeur, sizeof(unsigned long))) {
Serial.println(valeur);
}
if (valeur == 10 || valeur == 30 || valeur == 60 || valeur == 120 || valeur == 300)
{
vw_send((byte *)&okR, sizeof(okR));
vw_wait_tx();
Serial.println(okR);
unsigned long incrementTemps = valeur * 1000;
unsigned long moment = millis();
Serial.print("Temps nécessaire avant de commencer le relevé : ");
Serial.println(moment);
for (unsigned long n = 0; n < 2000; n++)
{
tension = analogRead(ThermistorPin);
R2 = R1 * (1023.0 / (float)tension - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc = T - 273.15;
tempPourEnvoyer = Tc * 100;
temp[n + 1] = tempPourEnvoyer;
Serial.print("Temperature ");
Serial.print(n);
Serial.print(" ");
Serial.println(tempPourEnvoyer);
Serial.print("Increment : ");
Serial.println(incrementTemps);
unsigned long calcul = moment + ((n + 1) * incrementTemps);
while ( millis() <= calcul || msg != 477)
{ Serial.print("Calcul : ");
Serial.println(calcul);
Serial.print("Millis : ");
Serial.println(millis());
vw_wait_rx();
if (vw_get_message((byte *) &msg, sizeof(int)))
{
Serial.println(msg);
}
}
if (msg == 477) //à définir pour collecter
{ Serial.println(okR);
vw_send((byte *) & okR, sizeof(okR));
vw_wait_tx();
temp[0] = n;
for (int a = 0; a < n + 1; a++)
{ valeurTableau = temp[a];
Serial.print("Temperature ");
Serial.print(a);
Serial.println(temp[a]);
vw_send((byte *) &valeurTableau, sizeof(valeurTableau));
vw_wait_tx();
}
vw_wait_rx_max(2000);
if (vw_get_message((byte *) msg, sizeof(int)))
{
if (msg == okE)
{ break;
}
}
}
}
}
if (valeur == 477)//à définir pour collecter
{
Serial.println(okR);
vw_send((byte *) & okR, sizeof(okR));
vw_wait_tx();
temp[0] = 1000;
for (int a = 0; a < 1000; a++)
{ valeurTableau = temp[a];
vw_send((byte *) &valeurTableau, sizeof(valeurTableau));
vw_wait_tx();
}
}
if (valeur == 666 )//à définir pour reset carte
{ vw_send((byte *) & okR, sizeof(okR));
vw_wait_tx();
Serial.println("Reset");
wdt_enable(WDTO_15MS);
while (1)
{
}
}
}
My arduino receive instruction in 433MHz and take temperature.
The warnings are just when I check (compile) my program.
(deleted)
The OP has 60 posts and still has no idea how to post an intelligent question.
I compiled your posted code. There are several warnings, no errors. I do not know what your "bugs" are as I cannot duplicate your project from the information that you have provided so cannot run the code. You need to tell us what is wrong.
From the VirtualWire reference.
This VirtualWire library has now been superceded by the RadioHead library RadioHead: RadioHead Packet Radio library for embedded microprocessors RadioHead and its RH_ASK driver provides all the features supported by VirtualWire, and much more besides, including Reliable Datagrams, Addressing, Routing and Meshes. All the platforms that VirtualWire supported are also supported by RadioHead.
I suggest that you use the latest library (RadioHead). The warnings may have been fixed in the newer library.
groundFungus:
I compiled your posted code. There are several warnings, no errors. I do not know what your "bugs" are as I cannot duplicate your project from the information that you have provided so cannot run the code. You need to tell us what is wrong.From the VirtualWire reference.
I suggest that you use the latest library (RadioHead). The warnings may have been fixed in the newer library.
Thanks