nRF24l01

Тема в разделе "Закажу проект", создана пользователем dreadfull, 30 янв 2015.

  1. dreadfull

    dreadfull Гик

    мне вот интересно, а сколько денег вообще-то будет стоить скетч для пары ардуино и их связи через радио-модуль???
     
  2. vvr

    vvr Инженерище

    Наверно всё зависит от ваших хотелок.
    A просто связать кнопку и светодиод через модуль можно и по форумным темам бесплатно.
     
  3. dreadfull

    dreadfull Гик

    все намного сложнее....
    необходимо связать 2-3 ардуино считывающих с датчиков показатели, которые через беспроводную связь будут предавать данные на ардуино подключенные к компьютеру...
    где-то так...
     
  4. m_t

    m_t Нерд

    могу помочь, пишите подробнее о задаче на
    m_t01@mail.ru
     
  5. микрочип

    микрочип Нерд

    код в сендере, для примера использован термистор
    #include <math.h>
    #include <SPI.h>
    #include "nRF24L01.h"
    #include "RF24.h"
    // Параметр конкретного типа термистора (из datasheet):
    #define TERMIST_B 4300
    #define VIN 5.0

    int temp = 1;

    int serial_putc( char c, FILE * )
    {
    Serial.write( c );
    return c;
    }

    //nRF24 set the pin 9 to CE and 10 to CSN/SS
    // Cables are:
    // SS -> 10
    // MOSI -> 11
    // MISO -> 12
    // SCK -> 13

    RF24 radio(9,10);

    const uint64_t pipes[2] = { 0xF0F0F0F0E1LL,0xF0F0F0F0D2LL };

    // here we can send up to 30 chars
    char SendPayload[31] = "blog.riyas.org";

    void setup(void) {
    Serial.begin(57600); //Debug
    printf_begin();
    //nRF24 configurations
    radio.begin();
    radio.setChannel(0x4c);
    radio.setAutoAck(1);
    radio.setRetries(15,15);
    radio.setDataRate(RF24_250KBPS);
    radio.setPayloadSize(32);
    radio.openReadingPipe(1,pipes[0]);
    radio.openWritingPipe(pipes[1]);
    radio.startListening();
    radio.printDetails(); //for Debugging
    }

    void loop() {
    float temperature = getTemp();
    dtostrf(temperature,2,2,SendPayload);
    //add a tag
    strcat(SendPayload, "X"); // add first string

    //send a heartbeat
    radio.stopListening();
    bool ok = radio.write(&SendPayload,strlen(SendPayload));
    radio.startListening();
    Serial.println(SendPayload);

    // slow down a bit
    delay(5000);
    }

    float getTemp(){

    float voltage = analogRead(A0) * VIN / 1023.0;
    float r1 = voltage / (VIN - voltage);
    float temperature = 1./( 1./(TERMIST_B)*log(r1)+1./(25. + 273.) ) - 273;
    float TemperatureSum = temperature ;
    return TemperatureSum;
    }
    void printf_begin(void)
    {
    fdevopen( &serial_putc, 0 );
    }
     
  6. микрочип

    микрочип Нерд

    код приемника принимаем строковый массив
    #include <SPI.h>
    #include "nRF24L01.h"
    #include "RF24.h"

    int serial_putc( char c, FILE * )
    {
    Serial.write( c );
    return c;
    }
    //nRF24 set the pin 9 to CE and 10 to CSN/SS
    // Cables are:
    // SS -> 10
    // MOSI -> 11
    // MISO -> 12
    // SCK -> 13

    RF24 radio(9, 10);

    //we only need a write pipe, but am planning to use it later
    const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };

    // here we can send up to 30 chars
    char SendPayload[31] = "blog.riyas.org";

    void setup(void) {
    Serial.begin(57600); //Debug
    printf_begin();
    //nRF24 configurations
    radio.begin();
    radio.setChannel(0x4c);
    radio.setAutoAck(1);
    radio.setRetries(15, 15);
    radio.setDataRate(RF24_250KBPS);
    radio.setPayloadSize(32);
    radio.openReadingPipe(1, pipes[0]);
    radio.openWritingPipe(pipes[1]);
    radio.startListening();
    radio.printDetails(); //for Debugging
    }

    void loop() {
    radio.startListening();
    char massive[1];
    if (radio.available()) {
    bool done = false;
    {
    // int recv_buffer = [3];
    radio.read(massive,sizeof(massive) );
    Serial.println(massive[0]);
    Serial.println(massive[1]);
    }

    // slow down a bit
    delay(5000);
    }

    }
    void printf_begin(void)
    {
    fdevopen( &serial_putc, 0 );
    }