fojek / ProjetCabane

MIT License
0 stars 0 forks source link

Capteurs de pression de bout de ligne #9

Open fojek opened 8 years ago

fojek commented 8 years ago

Exemples pris de http://www.airspayce.com/mikem/arduino/RF22/index.html

Serveur :

// rf22_server_softwarespi.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing server
// with the RF22 class. RF22 class does not provide for addressing or reliability.
// It is designed to work with the other example rf22_client
#include <SPI.h>
#include <RF22.h>
#include <SoftwareSPI.h>
// Software SPI class allows us to talk to the radio
// via bit-bang software instead of a hardware SPI driver
SoftwareSPIClass Software_spi;
// Singleton instance of the radio, using softwaer SPI
RF22 rf22(SS, 0, &Software_spi);
void setup() 
{
  Serial.begin(9600);

    // Configure SoftwareSPI for the same pins as usual hardware
  Software_spi.setPins(12, 11, 13);
  if (!rf22.init())
    Serial.println("RF22 init failed");
  // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
}
void loop()
{
  if (rf22.available())
  {
    // Should be a message for us now   
    uint8_t buf[RF22_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (rf22.recv(buf, &len))
    {
      Serial.print("got request: ");
      Serial.println((char*)buf);

      // Send a reply
      uint8_t data[] = "And hello back to you";
      rf22.send(data, sizeof(data));
      rf22.waitPacketSent();
      Serial.println("Sent a reply");
    }
    else
    {
      Serial.println("recv failed");
    }
  }
}

Client :

// rf22_client_softwarespi.pde
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messageing client
// with the RF22 class using Software SPI instead of the
// usual Hardware SPI. 
#include <SPI.h>
#include <RF22.h>
#include <SoftwareSPI.h>
// Software SPI class allows us to talk to the radio
// via bit-bang software instead of a hardware SPI driver
SoftwareSPIClass Software_spi;
// Singleton instance of the radio, using softwaer SPI
RF22 rf22(SS, 0, &Software_spi);
void setup() 
{
  Serial.begin(9600);
  // Configure SoftwareSPI for the same pins as usual hardware
  Software_spi.setPins(12, 11, 13);
  if (!rf22.init())
    Serial.println("RF22 init failed");
  // Defaults after init are 434.0MHz, 0.05MHz AFC pull-in, modulation FSK_Rb2_4Fd36
}
void loop()
{
  while (1)
  {
    Serial.println("Sending to rf22_server");
    // Send a message to rf22_server
    uint8_t data[] = "Hello World!";
    rf22.send(data, sizeof(data));

    rf22.waitPacketSent();
    // Now wait for a reply
    uint8_t buf[RF22_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);
    if (rf22.waitAvailableTimeout(500))
    { 
      // Should be a message for us now   
      if (rf22.recv(buf, &len))
      {
        Serial.print("got reply: ");
        Serial.println((char*)buf);
      }
      else
      {
        Serial.println("recv failed");
      }
    }
    else
    {
      Serial.println("No reply, is rf22_server running?");
    }
  }
}
fojek commented 8 years ago

Le programme est sur github : https://github.com/PaulStoffregen/RadioHead

RadioHead supporte le Mesh! @ considérer, il faudra voir l'usage de la batterie que ça représente. Possibilité d'utiliser des radio + puissantes pour les bouteilles, et des moins puissantes pour les extrémités de ligne.

fojek commented 8 years ago

Hier j'ai réussi à faire un lien bidirectionnel fiable sur une distance de 530m, entre deux radios numériques et avec des dipoles homemade. Le lien était entre le balcon chez nous et le dépanneur au coin Galt-Galvin, soit à travers une dizaine de maisons et une multitude de feuillus. La force du lien était d'environ -80dB, et les radios descendent de façon assez fiable à -95dB. J'utilisais un peu moins de 10% de la puissance d'émission, alors je suis confiant que le lien sera fiable à travers une forêt sans feuilles, tant que le terrain descend.

Les radios étaient à 3.3V et 20dB.

fojek commented 8 years ago

Résultats de l'essai : rssi marche.txt graphRSSI.xlsx